我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用gi.repository.Gdk.color_parse()。
def set_colours(self): if gv.verbose: print("in gui set_colours") bg_colour = '#888a85' self.get_window().modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse(bg_colour)) eb_2 = self.builder.get_object("eb_2") eb_2.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(bg_colour)) # square colours are set in board.py in set_image_cairo # border surrounds the board and contains the co-ordinates #self.border_eb.modify_bg( # Gtk.StateType.NORMAL, Gdk.color_parse(border_colour)) self.border_eb.queue_draw() grid_colour = '#000000' self.grid_eb.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse(grid_colour)) gv.board.update()
def color_swatch_new(self, str_color): color = Gdk.color_parse(str_color) rgba = Gdk.RGBA.from_color(color) button = Gtk.Button() area = Gtk.DrawingArea() area.set_size_request(24, 24) area.override_background_color(0, rgba) button.add(area) return button # --------------------------------- # create_flowbox # ---------------------------------
def color_swatch_new(self, str_color): color = Gdk.color_parse(str_color) rgba = Gdk.RGBA.from_color(color) button = Gtk.Button() area = Gtk.DrawingArea() area.set_size_request(24, 24) area.override_background_color(0, rgba) button.add(area) return button # print("Pedro deconnected") # --------------------------------- # color_widget # ---------------------------------
def color_widget(widget, color): color = Gdk.color_parse(color) rgba = Gdk.RGBA.from_color(color) widget.override_background_color(0, rgba) # --------------------------------- # gtk_style # ---------------------------------
def __init__(self): self.builder = Gtk.Builder() self.builder.add_from_file("main.xml") self.win = self.builder.get_object("window_main") self.win.connect("delete-event", self.exit) self.win.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white")) self.win.show_all() self.prefix = "SolStudio" self.ws = 0 # TODO: workspaces self.ctrl = False self.completion = True self.saved = [True] self.buff = [None] self.FILE = [None] self.ident = 0 self.connect() self.check_solc() self.reopen() # check for the last opened file Gtk.main()
def confirm(parent=None, title="", text=""): dialog = Gtk.Dialog(title, parent, 0) dialog.set_default_size(150, 100) dialog.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white")) label = Gtk.Label() label.set_markup('<span foreground="#494941" face="sans">' + text + '</span>') box = dialog.get_content_area() box.add(label) box.show_all() btn1 = dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) btn1.set_relief(2) btn2 = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) btn2.set_relief(2) result = False response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.OK: result = True elif response == Gtk.ResponseType.CANCEL: result = False return result
def color_widget(widget, color): color = Gdk.color_parse(color) rgba = Gdk.RGBA.from_color(color) widget.override_background_color(0, rgba) # --------------------------------- # draw_pedro_side # ---------------------------------
def lookup_color(self, c): try: color = Gdk.color_parse(c) except ValueError: pass else: s = 1.0/65535.0 r = color.red*s g = color.green*s b = color.blue*s a = 1.0 return r, g, b, a try: dummy, scheme, index = c.split('/') r, g, b = brewer_colors[scheme][int(index)] except (ValueError, KeyError): pass else: s = 1.0/255.0 r = r*s g = g*s b = b*s a = 1.0 return r, g, b, a sys.stderr.write("warning: unknown color '%s'\n" % c) return None
def alert(parent = None, title="", text=""): dialog = Gtk.Dialog(title, parent, 0) dialog.set_default_size(150, 100) dialog.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#FAFAFA")) label = Gtk.Label() label.set_markup('<span foreground="#494941" face="sans">' + text + '</span>') box = dialog.get_content_area() box.add(label) btn = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) btn.set_relief(2) box.show_all() dialog.run() dialog.destroy()
def __init__( self, keybinder, settings ): self.keybinder = keybinder self.settings = settings self.data_path = os.path.join( '/', 'usr', 'share', 'ukui-menu' ) self.icon = "/usr/share/ukui-menu/icons/ukui-logo.svg" # Load UI file and extract widgets builder = Gtk.Builder() builder.add_from_file(os.path.join( self.data_path, "ukui-menu.glade" )) self.window = builder.get_object( "mainWindow" ) self.eventbox = builder.get_object( "eventbox1" ) self.paneholder = builder.get_object( "paneholder" ) self.border = builder.get_object( "border" ) builder.connect_signals(self) self.borderwidth = 1 self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth ) defaultStyle = self.getDefaultStyle() color = defaultStyle.lookup_color('taskbar_applet_border_color')[1] if color == Gdk.Color(red=0, green=0, blue=0): self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( "#014276" )) else: self.window.modify_bg( Gtk.StateType.NORMAL, color ) self.eventbox.set_name("EventBox") self.window.connect( "key-press-event", self.onKeyPress ) self.window.connect( "focus-in-event", self.onFocusIn ) self.loseFocusId = self.window.connect( "focus-out-event", self.onFocusOut ) self.loseFocusBlocked = False self.offset = 0 self.window.stick() self.PopulatePlugins()
def __init__(self): glade_dir = gv.jcchess.get_glade_dir() self.glade_file = os.path.join(glade_dir, "move_list.glade") Move_List.move_list_ref = self self.comments = comments.get_ref() self.saved_move_list = [] # create move list window self.builder = Gtk.Builder() self.builder.set_translation_domain(gv.domain) self.builder.add_from_file(self.glade_file) self.builder.connect_signals(self) self.window = self.builder.get_object("move_list_window") self.vbox = self.builder.get_object("vbox1") #man self.treeview = Gtk.TreeView() #man self.liststore = self.builder.get_object("liststore1") self.scrolled_window = Gtk.ScrolledWindow() #self.scrolled_window.set_size_request(150,300) self.treeview.set_model(self.liststore) self.scrolled_window.add(self.treeview) self.vbox.add(self.scrolled_window) self.comments_button = self.builder.get_object("comments_button") #self.builder.connect("button_press_event",self.comments_button_clicked_cb) cell0 = Gtk.CellRendererText() # cell0.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn0 = Gtk.TreeViewColumn("#") self.treeview.append_column(tvcolumn0) tvcolumn0.pack_start(cell0, True) tvcolumn0.set_min_width(50) tvcolumn0.set_attributes(cell0, text=0) cell1 = Gtk.CellRendererText() # cell1.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn1 = Gtk.TreeViewColumn(_("Move")) self.treeview.append_column(tvcolumn1) tvcolumn1.pack_start(cell1, True) tvcolumn1.set_min_width(100) tvcolumn1.set_attributes(cell1, text=1) cell2 = Gtk.CellRendererText() # cell1.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn2 = Gtk.TreeViewColumn(_("Cmt")) self.treeview.append_column(tvcolumn2) tvcolumn2.pack_start(cell2, True) tvcolumn2.set_min_width(20) tvcolumn2.set_attributes(cell2, text=2) self.tree_selection = self.treeview.get_selection() self.treeview.connect("button_press_event", self.treeview_button_press) self.treeview.connect("key_press_event", self.treeview_key_press) self.update() # user has closed the window # just hide it