class EdMainWindow(): def __init__(self, fname, parent, names): self.full = False self.fcount = 0 self.statuscount = 0 self.alt = False register_stock_icons() global mained mained = self # Create the toplevel window window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window = window www = gtk.gdk.screen_width() hhh = gtk.gdk.screen_height() if pedconfig.conf.full_screen: window.set_default_size(www, hhh) else: xx = gconf.client_get_default().get_int(pedconfig.conf.config_reg + "/xx") yy = gconf.client_get_default().get_int(pedconfig.conf.config_reg + "/yy") ww = gconf.client_get_default().get_int(pedconfig.conf.config_reg + "/ww") hh = gconf.client_get_default().get_int(pedconfig.conf.config_reg + "/hh") if ww == 0 or hh == 0: window.set_position(gtk.WIN_POS_CENTER) window.set_default_size(7 * www / 8, 5 * hhh / 8) window.move(www / 32, hhh / 10) else: window.set_default_size(ww, hh) window.move(xx, yy) window.set_icon_from_file(get_img_path("pyedit.png")) merge = gtk.UIManager() window.set_data("ui-manager", merge) aa = create_action_group(self) merge.insert_action_group(aa, 0) window.add_accel_group(merge.get_accel_group()) try: mergeid = merge.add_ui_from_string(ui_info) except gobject.GError, msg: print "Building menus failed: %s" % msg # Add MRU for cnt in range(6): ss = "/sess_%d" % cnt fname = gconf.client_get_default().get_string\ (pedconfig.conf.config_reg + ss) if fname != "": self.add_mru(merge, aa, fname, ss) merge_id = merge.new_merge_id() merge.add_ui(merge_id, "ui/MenuBar/FileMenu/SaveAs", "", None, gtk.UI_MANAGER_SEPARATOR, False) mbar = merge.get_widget("/MenuBar") mbar.show() window.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK | gtk.gdk.FOCUS_CHANGE_MASK) #window.set_events( gtk.gdk.ALL_EVENTS_MASK) global notebook # Create note for the main window, give access to it for all notebook = gtk.Notebook() self.notebook = notebook notebook.popup_enable() notebook.set_scrollable(True) #notebook.add_events(gtk.gdk.FOCUS_CHANGE_MASK) notebook.add_events(gtk.gdk.ALL_EVENTS_MASK) notebook.connect("switch-page", self.note_swpage_cb) notebook.connect("focus-in-event", self.note_focus_in) # Futile attempts #notebook.connect("change-current-page", self.note_page_cb) #notebook.connect("grab-focus", self.note_grab_focus_cb) #notebook.connect("focus", self.note_focus_cb) #notebook.connect("create-window", self.note_create_cb) #notebook.connect("enter-notify-event", self.note_enter_notify) window.connect("window_state_event", self.update_resize_grip) window.connect("destroy", OnExit) window.connect("key-press-event", self.area_key) window.connect("key-release-event", self.area_key) #window.connect("set-focus", self.area_focus) window.connect("focus-in-event", self.area_focus_in) window.connect("focus-out-event", self.area_focus_out) window.connect("window-state-event", self.area_winstate) #window.connect("area-focus-event", self.area_focus_in) #window.connect("event", self.area_event) #window.connect("enter-notify-event", self.area_enter) #window.connect("leave-notify-event", self.area_leave) #window.connect("event", self.unmap) table = gtk.Table(2, 4, False) window.add(table) table.attach( mbar, # X direction # # Y direction 0, 1, 0, 1, gtk.EXPAND | gtk.FILL, 0, 0, 0) tbar = merge.get_widget("/ToolBar") tbar.set_tooltips(True) tbar.show() table.attach( tbar, # X direction # # Y direction 0, 1, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 0) hpaned = gtk.HPaned() hpaned.set_border_width(5) scroll = gtk.ScrolledWindow() treeview = self.create_tree() treeview.connect("row-activated", self.tree_sel) treeview.connect("cursor-changed", self.tree_sel_row) self.treeview = treeview scroll.add(treeview) frame2 = gtk.Frame() frame2.add(scroll) hpaned.add(frame2) self.hpanepos = gconf.client_get_default(). \ get_int(pedconfig.conf.config_reg + "/hpaned") if self.hpanepos == 0: self.hpanepos = 200 hpaned.set_position(self.hpanepos) hpaned.pack2(notebook) self.hpaned = hpaned # Create statusbars self.statusbar = gtk.Statusbar() self.statusbar2 = gtk.Statusbar() slab = gtk.Label(" ") hpane2 = gtk.HPaned() hpane2.set_position(self.get_width() - 250) hpane2.pack2(self.statusbar2) shbox = gtk.HBox() shbox.pack_start(slab, False) shbox.pack_start(self.statusbar) hpane2.pack1(shbox) # Main Pane table.attach( hpaned, # X direction Y direction 0, 1, 2, 3, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0) table.attach( hpane2, #table.attach(self.statusbar, # X direction Y direction 0, 1, 3, 4, gtk.EXPAND | gtk.FILL, 0, 0, 0) window.show_all() # ---------------------------------------------------------------- cnt = 0 # Read in buffers for aa in names: aaa = os.path.realpath(aa) #print "loading file: ", aaa vpaned = edPane() ret = vpaned.area.loadfile(aaa) if not ret: self.update_statusbar("Cannot read file '{0:s}'".format(aaa)) continue ret = vpaned.area2.loadfile(aaa) cnt += 1 notebook.append_page(vpaned) vpaned.area.set_tablabel() if cnt == 0: #print "No file on command line, creating new", os.getcwd() fcnt = gconf.client_get_default().get_int\ (pedconfig.conf.config_reg + "/cnt") # Load old session for nnn in range(fcnt): ss = "/sess_%d" % nnn fff = gconf.client_get_default().get_string\ (pedconfig.conf.config_reg + ss) #print "loading ", fff vpaned = edPane() ret = vpaned.area.loadfile(fff) if not ret: self.update_statusbar( "Cannot read file '{0:s}'".format(fff)) continue vpaned.area2.loadfile(fff) notebook.append_page(vpaned) vpaned.area.set_tablabel() # Show newly created buffers: window.show_all() # Set last file fff = gconf.client_get_default().get_string\ (pedconfig.conf.config_reg + "/curr") #print "curr file", fff cc = notebook.get_n_pages() for mm in range(cc): vcurr = notebook.get_nth_page(mm) if vcurr.area.fname == fff: #print "found buff", fff notebook.set_current_page(mm) self.window.set_focus(vcurr.vbox.area) break # Set the signal handler for 1s tick signal.signal(signal.SIGALRM, handler) signal.alarm(1) self.update_statusbar("Initial")
def dialog_tablehandle(self, title, is_insert): """Opens the Table Handle Dialog""" dialog = gtk.Dialog(title=title, parent=self.dad.window, flags=gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_default_size(300, -1) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) label_rows = gtk.Label(_("Rows")) adj_rows = gtk.Adjustment(value=self.dad.table_rows, lower=1, upper=10000, step_incr=1) spinbutton_rows = gtk.SpinButton(adj_rows) spinbutton_rows.set_value(self.dad.table_rows) label_columns = gtk.Label(_("Columns")) adj_columns = gtk.Adjustment(value=self.dad.table_columns, lower=1, upper=10000, step_incr=1) spinbutton_columns = gtk.SpinButton(adj_columns) spinbutton_columns.set_value(self.dad.table_columns) hbox_rows_cols = gtk.HBox() hbox_rows_cols.pack_start(label_rows, expand=False) hbox_rows_cols.pack_start(spinbutton_rows, expand=False) hbox_rows_cols.pack_start(label_columns, expand=False) hbox_rows_cols.pack_start(spinbutton_columns, expand=False) hbox_rows_cols.set_spacing(5) size_align = gtk.Alignment() size_align.set_padding(6, 6, 6, 6) size_align.add(hbox_rows_cols) size_frame = gtk.Frame(label="<b>"+_("Table Size")+"</b>") size_frame.get_label_widget().set_use_markup(True) size_frame.set_shadow_type(gtk.SHADOW_NONE) size_frame.add(size_align) label_col_min = gtk.Label(_("Min Width")) adj_col_min = gtk.Adjustment(value=self.dad.table_col_min, lower=1, upper=10000, step_incr=1) spinbutton_col_min = gtk.SpinButton(adj_col_min) spinbutton_col_min.set_value(self.dad.table_col_min) label_col_max = gtk.Label(_("Max Width")) adj_col_max = gtk.Adjustment(value=self.dad.table_col_max, lower=1, upper=10000, step_incr=1) spinbutton_col_max = gtk.SpinButton(adj_col_max) spinbutton_col_max.set_value(self.dad.table_col_max) hbox_col_min_max = gtk.HBox() hbox_col_min_max.pack_start(label_col_min, expand=False) hbox_col_min_max.pack_start(spinbutton_col_min, expand=False) hbox_col_min_max.pack_start(label_col_max, expand=False) hbox_col_min_max.pack_start(spinbutton_col_max, expand=False) hbox_col_min_max.set_spacing(5) col_min_max_align = gtk.Alignment() col_min_max_align.set_padding(6, 6, 6, 6) col_min_max_align.add(hbox_col_min_max) col_min_max_frame = gtk.Frame(label="<b>"+_("Column Properties")+"</b>") col_min_max_frame.get_label_widget().set_use_markup(True) col_min_max_frame.set_shadow_type(gtk.SHADOW_NONE) col_min_max_frame.add(col_min_max_align) checkbutton_table_ins_from_file = gtk.CheckButton(label=_("Import from CSV File")) content_area = dialog.get_content_area() content_area.set_spacing(5) if is_insert: content_area.pack_start(size_frame) content_area.pack_start(col_min_max_frame) if is_insert: content_area.pack_start(checkbutton_table_ins_from_file) content_area.show_all() def on_key_press_tablehandle(widget, event): keyname = gtk.gdk.keyval_name(event.keyval) if keyname == cons.STR_KEY_RETURN: spinbutton_rows.update() spinbutton_columns.update() spinbutton_col_min.update() spinbutton_col_max.update() try: dialog.get_widget_for_response(gtk.RESPONSE_ACCEPT).clicked() except: print cons.STR_PYGTK_222_REQUIRED return True return False def on_checkbutton_table_ins_from_file_toggled(checkbutton): size_frame.set_sensitive(not checkbutton.get_active()) col_min_max_frame.set_sensitive(not checkbutton.get_active()) dialog.connect('key_press_event', on_key_press_tablehandle) checkbutton_table_ins_from_file.connect('toggled', on_checkbutton_table_ins_from_file_toggled) response = dialog.run() dialog.hide() if response == gtk.RESPONSE_ACCEPT: self.dad.table_rows = int(spinbutton_rows.get_value()) self.dad.table_columns = int(spinbutton_columns.get_value()) self.dad.table_col_min = int(spinbutton_col_min.get_value()) self.dad.table_col_max = int(spinbutton_col_max.get_value()) ret_csv = checkbutton_table_ins_from_file.get_active() return [True, ret_csv] return [False, None]
def __init__(self): debug.mainthreadTest() self.built = False layereditor.LayerEditor.__init__(self) gtklogger.checkpoint("layereditor layerset changed") self.suppressCallbacks = 0 widgetscope.WidgetScope.__init__(self, None) self.setData("gfxwindow", None) # widgetscope data, that is self.sbcallbacks = [ switchboard.requestCallbackMain('open graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('close graphics window', self.gfxwindowChanged) ] self.menu.File.Quit.gui_callback = quit.queryQuit subWindow.SubWindow.__init__(self, title="%s Graphics Layer Editor" % subWindow.oofname(), menu=self.menu) ## self.gtk.set_policy(1, 1, 0) self.gtk.set_default_size(600, 250) self.gtk.connect('destroy', self.destroyCB) mainpane = gtk.HPaned() mainpane.set_border_width(3) mainpane.set_position(300) self.mainbox.pack_start(mainpane, expand=1, fill=1) # The left side of the layer editor is for choosing the object # being drawn. whoframe = gtk.Frame('Displayed Object') mainpane.pack1(whoframe, resize=1, shrink=0) wscroll = gtk.ScrolledWindow() gtklogger.logScrollBars(wscroll, "ObjectScroll") wscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) whoframe.add(wscroll) vbox = gtk.VBox() wscroll.add_with_viewport(vbox) cmd = self.menu.LayerSet.DisplayedObject # This creates a table containing a WhoClassWidget and a WhoWidget: ptable = parameterwidgets.ParameterTable( [cmd.get_arg('category'), cmd.get_arg('object')], scope=self) vbox.pack_start(ptable.gtk, expand=0, fill=0) # The right side of the layer editor lists the display methods # for the object on the left side. methframe = gtk.Frame('Display Methods') gtklogger.setWidgetName(methframe, "DisplayMethods") mainpane.pack2(methframe, resize=1, shrink=0) mvbox = gtk.VBox() methframe.add(mvbox) mhbox = gtk.HBox() mvbox.pack_start(mhbox, expand=1, fill=1) self.methodList = chooser.ScrolledChooserListWidget( callback=self.singleClickMethodCB, dbcallback=self.doubleClickMethodCB, comparator=lambda x, y: (not x.inequivalent(y)), name="List") mhbox.pack_start(self.methodList.gtk, expand=1, fill=1, padding=3) # The who widget is replaced each time the who class widget is # activated, so its switchboard callback must be reset often, # and is done in findWidget(). self.whowidgetsignal = None self.findWhoWidget() buttonbox = gtk.HBox() mvbox.pack_start(buttonbox, expand=0, fill=0, padding=3) self.newMethodButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...') buttonbox.pack_start(self.newMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.newMethodButton, "New") gtklogger.connect(self.newMethodButton, 'clicked', self.newMethodButtonCB) self.editMethodButton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Edit...') buttonbox.pack_start(self.editMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.editMethodButton, "Edit") gtklogger.connect(self.editMethodButton, 'clicked', self.editMethodButtonCB) self.copyMethodButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy') buttonbox.pack_start(self.copyMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.copyMethodButton, "Copy") gtklogger.connect(self.copyMethodButton, 'clicked', self.copyMethodButtonCB) self.deleteMethodButton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') buttonbox.pack_start(self.deleteMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.deleteMethodButton, "Delete") gtklogger.connect(self.deleteMethodButton, 'clicked', self.deleteMethodButtonCB) self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0) # Buttons at the bottom governing LayerSet operations: # New LayerSet, Send to Gfx Window, etc. mainbuttonbox = gtk.HBox() self.mainbox.pack_start(mainbuttonbox, expand=0, fill=0, padding=3) newLayerButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New Layer') mainbuttonbox.pack_start(newLayerButton, expand=0, fill=0, padding=3) gtklogger.setWidgetName(newLayerButton, "NewLayer") gtklogger.connect(newLayerButton, 'clicked', self.newLayerButtonCB) self.sendButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, 'Send', reverse=1) ## self.sendButton.set_usize(80, -1) mainbuttonbox.pack_end(self.sendButton, expand=0, fill=0, padding=3) gtklogger.setWidgetName(self.sendButton, "Send") gtklogger.connect(self.sendButton, 'clicked', self.sendCB) self.destinationMenu = chooser.ChooserWidget([], name="Destination") mainbuttonbox.pack_end(self.destinationMenu.gtk, expand=0, fill=0) self.updateDestinationMenu() label = gtk.Label('Destination=') tooltips.set_tooltip_text( label, 'The graphics window(s) that will display the layer(s).') label.set_alignment(1.0, 0.5) mainbuttonbox.pack_end(label, expand=0, fill=0) self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3) # When the lhs widgets change state the rhs might have to # change too. The widgets referred to here are inside the # ParameterTable constructed above. self.whoclasswidget = self.findWidget( lambda w: isinstance(w, whowidget.WhoClassParameterWidget)) self.whoclasswidgetsignal = switchboard.requestCallbackMain( self.whoclasswidget, self.whoClassChangedCB) self.sbcallbacks.append(self.whoclasswidgetsignal) self.built = True self.sensitize() self.gtk.show_all()
def __init__(self, title_text, parent_widget, instream, outstream, name, length): self.state = self.PENDING self.dialog = gtk.Dialog(title=title_text, parent=parent_widget) self.dialog.set_has_separator(False) self.instream = instream self.outstream = outstream self.name = name self.length = length self.bytes_read = 0.0 self.name_label = gtk.Label(self.name) self.progress_bar = gtk.ProgressBar() self.progress_bar.set_fraction(0.0) if not self.length: self.length = '?' self.progress_bar.set_text('0.00 kb') else: self.length = float(self.length) self.progress_bar.set_text( '%.02f/%.02f kb (%d%%)' % (self.bytes_read / 1024.0, self.length / 1024.0, 100 * self.bytes_read / self.length)) self.cancel_button = gtk.Button('Cancel') self.cancel_button.connect('clicked', self.cancel_button_event) self.cancel_box = gtk.HBox() self.cancel_box.pack_start(self.cancel_button, expand=True, fill=False) self.dialog.vbox.pack_start(self.name_label, padding=5) self.dialog.vbox.pack_start(self.progress_bar, padding=5) self.dialog.vbox.pack_start(self.cancel_box) self.dialog.show_all() try: while (self.state == self.PENDING and (self.instream.fp is not None)): line = self.instream.read(1024) if line == '': break self.bytes_read += len(line) if self.length != '?': self.progress_bar.set_fraction(self.bytes_read / self.length) self.progress_bar.set_text( '%.02f/%.02f kb (%d%%)' % (self.bytes_read / 1024.0, self.length / 1024.0, 100 * self.bytes_read / self.length)) else: self.progress_bar.set_text('%.02f kb' % (self.bytes_read / 1024.0)) self.outstream.write(line) while gtk.events_pending(): gtk.main_iteration() if self.state != self.CANCEL: self.instream.close() self.outstream.close() self.state == self.SUCCESS self.progress_bar.set_fraction(1.0) self.progress_bar.set_text('%.02f kb' % (self.bytes_read / 1024.0)) self.delete_event() except: self.status = self.FAILURE self.delete_event()
def create_misc(self): self.songs_count = gtk.Label("Songs") self.separator = gtk.VSeparator()
def parse_filter(self, xml_data, max_width, root_node, call=None): psr = expat.ParserCreate() psr.StartElementHandler = self.dummy_start psr.EndElementHandler = self._psr_end psr.CharacterDataHandler = self._psr_char self.notebooks = [] dict_widget = {} psr.Parse(xml_data) self.name_lst += self.name_lst1 container = _container(max_width) attrs = tools.node_attributes(root_node) container.new() self.container = container for node in root_node: attrs = tools.node_attributes(node) if attrs.get('invisible', False): visval = eval(attrs['invisible'], {'context': call[0].context}) if visval: continue if node.tag == 'field': field_name = str(attrs['name']) field_dic = self.fields[field_name] type = attrs.get('widget', field_dic['type']) field_dic.update(attrs) field_dic['model'] = self.model if type not in widgets_type: continue widget_act = widgets_type[type][0](field_name, self.parent, field_dic, screen=call[0]) if 'string' in field_dic: label = field_dic['string'] + ' :' else: label = None if not self.focusable: self.focusable = widget_act.widget mywidget = widget_act.widget if node is not None and len(node): mywidget = gtk.HBox(homogeneous=False, spacing=0) mywidget.pack_start(widget_act.widget, expand=True, fill=True) for node_child in node: attrs_child = tools.node_attributes(node_child) if attrs_child.get('invisible', False): visval = eval(attrs_child['invisible'], {'context': call[0].context}) if visval: continue if node_child.tag == 'filter': widget_child = widgets_type['filter'][0]( '', self.parent, attrs_child, call) mywidget.pack_start(widget_child.widget) dict_widget[str(attrs['name']) + str(uuid.uuid1())] = (widget_child, mywidget, 1) elif node_child.tag == 'separator': if attrs_child.get('orientation', 'vertical') == 'horizontal': sep = gtk.HSeparator() sep.set_size_request(30, 5) mywidget.pack_start(sep, False, True, 5) else: sep = gtk.VSeparator() sep.set_size_request(3, 40) mywidget.pack_start(sep, False, False, 5) # mywidget.pack_start(widget_act.widget,expand=False,fill=False) xoptions = gtk.SHRINK wid = container.wid_add(mywidget, 1, label, int(self.fields[str( attrs['name'])].get('expand', 0)), xoptions=xoptions) dict_widget[str(attrs['name'])] = (widget_act, wid, 1) elif node.tag == 'filter': name = str(attrs.get('string', 'filter')) widget_act = filter.filter(name, self.parent, attrs, call) help = attrs.get('help', False) or name wid = container.wid_add(widget_act.butt, xoptions=gtk.SHRINK, help=help) dict_widget[name + str(uuid.uuid1())] = (widget_act, widget_act, 1) elif node.tag == 'separator': if attrs.get('orientation', 'vertical') == 'horizontal': sep_box = gtk.VBox(homogeneous=False, spacing=0) sep = gtk.HSeparator() sep.set_size_request(30, 5) sep_box.pack_start(gtk.Label(''), expand=False, fill=False) sep_box.pack_start(sep, False, True, 5) else: sep_box = gtk.HBox(homogeneous=False, spacing=0) sep = gtk.VSeparator() sep.set_size_request(3, 45) sep_box.pack_start(sep, False, False, 5) wid = container.wid_add(sep_box, xoptions=gtk.SHRINK) wid.show() elif node.tag == 'newline': container.newline(node.getparent() is not None and node.getparent().tag == 'group') elif node.tag == 'group': if attrs.get('invisible', False): continue if attrs.get('expand', False): attrs['expand'] = tools.expr_eval( attrs.get('expand', False), {'context': call[0].context}) frame = gtk.Expander(attrs.get('string', None)) frame.set_expanded(bool(attrs['expand'])) else: frame = gtk.Frame(attrs.get('string', None)) if not attrs.get('string', None): frame.set_shadow_type(gtk.SHADOW_NONE) frame.attrs = attrs frame.set_border_width(0) container.wid_add(frame, colspan=1, expand=int(attrs.get('expand', 0)), ypadding=0) container.new() widget, widgets = self.parse_filter(xml_data, max_width, node, call=call) dict_widget.update(widgets) if isinstance(widget, list): tb = gtk.Table(1, 1, True) row = 1 for table in widget: tb.attach(table, 0, 1, row - 1, row) row += 1 frame.add(tb) else: frame.add(widget) if not attrs.get('string', None): container.get().set_border_width(0) container.pop() self.widget = container.pop() self.container = container return self.widget, dict_widget
def pen_audio(self, *args): if not self.connected: dlg = gtk.MessageDialog(self.window, 0, "error", gtk.BUTTONS_OK, "Connect to a pen first") dlg.run() dlg.destroy() return dlg = gtk.FileChooserDialog(title="Save As...", action=gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,gtk.RESPONSE_OK)) resp = dlg.run() dirname = dlg.get_filenames()[0] dlg.destroy() if resp != gtk.RESPONSE_OK: return done = [ False ] def copy_fds(f_in, f_out): while True: data = f_in.read(4096) if not data: break f_out.write(data) def background_thread(done): fd, tmpfile = tempfile.mkstemp() self.pen.get_paperreplay(tmpfile, 0) z = zipfile.ZipFile(tmpfile, "r") i = 0 for name in z.namelist(): if not name.endswith('.aac'): continue f_in = z.open(name) f_out = file(os.path.join(dirname, "recording-%d.aac" % i), "wb") copy_fds(f_in, f_out) i += 1 done[0] = True dlg = gtk.Dialog("Downloading Audio...", None, 0, tuple()) box = dlg.get_child() widget = gtk.Label("Downloading audio, this may take several minutes.") box.pack_start(widget, False, False, 0) widget = gtk.ProgressBar() box.pack_start(widget, False, False, 0) dlg.show_all() while gtk.events_pending(): gtk.main_iteration() args = (done,) self.audio_thread = thread.start_new_thread(background_thread, args) while done[0] is False: # wait for thread to finish import time time.sleep(0.25) while gtk.events_pending(): gtk.main_iteration() widget.pulse() dlg.destroy() dlg = gtk.MessageDialog(self.window, 0, "info", gtk.BUTTONS_OK, "Audio download complete") dlg.run() dlg.destroy() return
def create_prefs_page(self): #Select Widget hover = gtk.Label() self.scheduler_select = SchedulerSelectWidget(hover) vbox = gtk.VBox(False, 5) hbox = gtk.HBox(False, 5) vbox_days = gtk.VBox() for day in DAYS: vbox_days.pack_start(gtk.Label(day)) hbox.pack_start(vbox_days, False, False) hbox.pack_start(self.scheduler_select, True, True) frame = gtk.Frame() label = gtk.Label() label.set_markup("<b>Schedule</b>") frame.set_label_widget(label) frame.set_shadow_type(gtk.SHADOW_NONE) frame.add(hbox) vbox.pack_start(frame, True, True) vbox.pack_start(hover) frame = gtk.Frame() label = gtk.Label() label.set_markup(_("<b>Scheduler Override</b>")) frame.set_label_widget(label) ignoreSchedulerVBox = gtk.VBox(False, 1) self.chkIgnoreScheduler = gtk.CheckButton("Ignore Scheduler") ignoreSchedulerVBox.pack_start(self.chkIgnoreScheduler) frame.add(ignoreSchedulerVBox) vbox.pack_start(frame, False, False) frame = gtk.Frame() label = gtk.Label() label.set_markup(_("<b>Forced Settings</b>")) frame.set_label_widget(label) forcedvbox = gtk.VBox(False, 1) self.chkIndividual = gtk.CheckButton("Use Individual Scheduling") forcedvbox.pack_start(self.chkIndividual) self.chkUnforceFinished = gtk.CheckButton("Un-Force on Finished") forcedvbox.pack_start(self.chkUnforceFinished) frame.add(forcedvbox) vbox.pack_start(frame, False, False) table = gtk.Table(3, 4) label = gtk.Label(_("Download Limit:")) label.set_alignment(0.0, 0.6) table.attach(label, 0, 1, 0, 1, gtk.FILL) self.spin_download = gtk.SpinButton() self.spin_download.set_numeric(True) self.spin_download.set_range(-1.0, 99999.0) self.spin_download.set_increments(1, 10) table.attach(self.spin_download, 1, 2, 0, 1, gtk.FILL) label = gtk.Label(_("Upload Limit:")) label.set_alignment(0.0, 0.6) table.attach(label, 0, 1, 1, 2, gtk.FILL) self.spin_upload = gtk.SpinButton() self.spin_upload.set_numeric(True) self.spin_upload.set_range(-1.0, 99999.0) self.spin_upload.set_increments(1, 10) table.attach(self.spin_upload, 1, 2, 1, 2, gtk.FILL) label = gtk.Label(_("Active Torrents:")) label.set_alignment(0.0, 0.6) table.attach(label, 2, 3, 0, 1, gtk.FILL) self.spin_active = gtk.SpinButton() self.spin_active.set_numeric(True) self.spin_active.set_range(-1, 9999) self.spin_active.set_increments(1, 10) table.attach(self.spin_active, 3, 4, 0, 1, gtk.FILL) label = gtk.Label(_("Active Downloading:")) label.set_alignment(0.0, 0.6) table.attach(label, 2, 3, 1, 2, gtk.FILL) self.spin_active_down = gtk.SpinButton() self.spin_active_down.set_numeric(True) self.spin_active_down.set_range(-1, 9999) self.spin_active_down.set_increments(1, 10) table.attach(self.spin_active_down, 3, 4, 1, 2, gtk.FILL) label = gtk.Label(_("Active Seeding:")) label.set_alignment(0.0, 0.6) table.attach(label, 2, 3, 2, 3, gtk.FILL) self.spin_active_up = gtk.SpinButton() self.spin_active_up.set_numeric(True) self.spin_active_up.set_range(-1, 9999) self.spin_active_up.set_increments(1, 10) table.attach(self.spin_active_up, 3, 4, 2, 3, gtk.FILL) eventbox = gtk.EventBox() eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#EDD400")) eventbox.add(table) frame = gtk.Frame() label = gtk.Label() label.set_markup(_("<b>Slow Settings</b>")) frame.set_label_widget(label) frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#CDB400")) frame.set_border_width(2) frame.add(eventbox) vbox.pack_start(frame, False, False) vbox.show_all() component.get("Preferences").add_page(_("MyScheduler"), vbox)
def __init__(self, WinMain): # Set main window self.WinMain = WinMain # Build the window self.winOptions = gtk.Fixed() self.winOptions.set_has_window(True) self.imgBackground = gtk.Image() self.lblHeading = gtk.Label() self.lblSettingHeading = gtk.Label() self.lblSettingValue = gtk.Label() self.sclOptions = ScrollList(self.WinMain) self.winOptions.add(self.imgBackground) self.winOptions.add(self.lblHeading) self.winOptions.add(self.lblSettingHeading) self.winOptions.add(self.lblSettingValue) self.winOptions.add(self.sclOptions.fixd) WinMain.fixd.add(self.winOptions) self.imgBackground.show() self.lblHeading.show() self.lblSettingHeading.show() self.lblSettingValue.show() self.winOptions.show() # Build list self.lsOptions = [] self.sclOptions.auto_update = True # Get keyboard & mouse events self.sclOptions.connect('update', self.on_sclOptions_changed) self.sclOptions.connect('mouse-left-click', self.on_sclOptions_changed) self.sclOptions.connect('mouse-double-click', self.menu_selected) # Setup menu self.current_menu = 'main' self._menus = { 'main': [ [_('Select Platform'), 'emu_list'], [_('Select Game List'), 'game_list'], [_('Find Game'), 'find'], [_('Select Random Game'), 'random'], [_('Games List Options'), 'list_options'], #['Launch External Application', 'external'], [_('Music Options'), 'music'], [_('Video Recording Options'), 'record_video'], [_('About'), 'about'], [_('Change Cabinet Name'), 'change'], [_('Exit Wah!Cade'), 'exit'] ], #[_('Close Arcade'), 'shutdown']], 'list_options': [[_('Add Game to List'), 'add_to_list'], [_('Remove Game from List'), 'remove_from_list'], [_('Generate List...'), 'generate_list']], 'music': [[_('Play / Pause'), 'music_play'], [_('Next Track'), 'next_track'], [_('Previous Track'), 'previous_track'], [_('Select Track / Directory'), 'show_music_dir']], 'record_video': [[_('On'), 'recording_launch'], [_('Off'), 'recording_off']], 'exit': [[_('Exit to Desktop'), 'exit_desktop'], [_('Exit & Reboot'), 'exit_reboot'], [_('Exit & Shutdown'), 'exit_shutdown']], } self._display_clones = [[_('No'), 'no'], [_('Yes'), 'yes'], [_('Only if better than Parent'), 'better']] self._display_clone_idx = 0 # Init window #self.lblHeading.set_ellipsize(pango.ELLIPSIZE_START) self.record = False
__copyright__ = 'Copyright 2006 Andrew Pennebaker' from ProgressDialog import ProgressDialog from FileSelectionDialog import FileSelectionDialog import downloader import gtk import os WINDOW = gtk.Window(gtk.WINDOW_TOPLEVEL) WINDOW.set_size_request(400, 70) WINDOW.set_title('Downloader') WINDOW.connect('delete-event', gtk.main_quit) URL_LABEL = gtk.Label('URL') URL_ENTRY = gtk.Entry(max=0) # no max chars HBOX = gtk.HBox() HBOX.pack_start(URL_LABEL, expand=False, fill=False, padding=5) HBOX.pack_start(URL_ENTRY, expand=True, fill=True, padding=5) DOWNLOAD_BUTTON = gtk.Button('Download') def download_button_event(widget=None, event=None, data=None): '''Download''' url = URL_ENTRY.get_text() try: url, length = downloader.createDownload(url, None)
def add_top_bar_widgets(self, hbox): label = gtk.Label("hello") hbox.add(label)
def _addTag(self, text): l = gtk.Label(text[0:len(text) - 1]) l.set_alignment(0, 0) self._box.pack_start(l, expand=False) l.show()
def __init__(self, message="UNCLASSIFIED", fgcolor="#000000", bgcolor="#00CC00", face="liberation-sans", size="small", weight="bold", x=0, y=0, esc=True, opacity=0.75, sys_info=False): """Set up and display the main window Keyword arguments: message -- The classification level to display fgcolor -- Foreground color of the text to display bgcolor -- Background color of the banner the text is against face -- Font face to use for the displayed text size -- Size of font to use for text weight -- Bold or normal hres -- Horizontal Screen Resolution (int) [ requires vres ] vres -- Vertical Screen Resolution (int) [ requires hres ] opacity -- Opacity of window (float) [0 .. 1, default 0.75] """ self.hres = x self.vres = y # Dynamic Resolution Scaling self.monitor = gtk.gdk.Screen() self.monitor.connect("size-changed", self.resize) # Newer versions of pygtk have this method try: self.monitor.connect("monitors-changed", self.resize) except: pass # Create Main Window self.window = gtk.Window() self.window.set_position(gtk.WIN_POS_CENTER) self.window.connect("hide", self.restore) self.window.connect("key-press-event", self.keypress) self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor)) self.window.set_property('skip-taskbar-hint', True) self.window.set_property('skip-pager-hint', True) self.window.set_property('destroy-with-parent', True) self.window.stick() self.window.set_decorated(False) self.window.set_keep_above(True) self.window.set_app_paintable(True) try: self.window.set_opacity(opacity) except: pass # Set the default window size self.window.set_default_size(int(self.hres), 5) # Create Main Horizontal Box to Populate self.hbox = gtk.HBox() # Create the Center Vertical Box self.vbox_center = gtk.VBox() self.center_label = gtk.Label( "<span font_family='%s' weight='%s' foreground='%s' size='%s'>%s</span>" % (face, weight, fgcolor, size, message)) self.center_label.set_use_markup(True) self.center_label.set_justify(gtk.JUSTIFY_CENTER) self.vbox_center.pack_start(self.center_label, True, True, 0) # Create the Right-Justified Vertical Box to Populate for hostname self.vbox_right = gtk.VBox() self.host_label = gtk.Label( "<span font_family='%s' weight='%s' foreground='%s' size='%s'>%s</span>" % (face, weight, fgcolor, size, get_host())) self.host_label.set_use_markup(True) self.host_label.set_justify(gtk.JUSTIFY_RIGHT) self.host_label.set_width_chars(20) # Create the Left-Justified Vertical Box to Populate for user self.vbox_left = gtk.VBox() self.user_label = gtk.Label( "<span font_family='%s' weight='%s' foreground='%s' size='%s'>%s</span>" % (face, weight, fgcolor, size, get_user())) self.user_label.set_use_markup(True) self.user_label.set_justify(gtk.JUSTIFY_LEFT) self.user_label.set_width_chars(20) # Create the Right-Justified Vertical Box to Populate for ESC message self.vbox_esc_right = gtk.VBox() self.esc_label = gtk.Label( "<span font_family='liberation-sans' weight='normal' foreground='%s' size='xx-small'> (ESC to hide temporarily) </span>" % (fgcolor)) self.esc_label.set_use_markup(True) self.esc_label.set_justify(gtk.JUSTIFY_RIGHT) self.esc_label.set_width_chars(20) # Empty Label for formatting purposes self.vbox_empty = gtk.VBox() self.empty_label = gtk.Label( "<span font_family='liberation-sans' weight='normal'> </span>") self.empty_label.set_use_markup(True) self.empty_label.set_width_chars(20) if not esc: if not sys_info: self.hbox.pack_start(self.vbox_center, True, True, 0) else: self.vbox_right.pack_start(self.host_label, True, True, 0) self.vbox_left.pack_start(self.user_label, True, True, 0) self.hbox.pack_start(self.vbox_right, False, True, 20) self.hbox.pack_start(self.vbox_center, True, True, 0) self.hbox.pack_start(self.vbox_left, False, True, 20) else: if esc and not sys_info: self.empty_label.set_justify(gtk.JUSTIFY_LEFT) self.vbox_empty.pack_start(self.empty_label, True, True, 0) self.vbox_esc_right.pack_start(self.esc_label, True, True, 0) self.hbox.pack_start(self.vbox_esc_right, False, True, 0) self.hbox.pack_start(self.vbox_center, True, True, 0) self.hbox.pack_start(self.vbox_empty, False, True, 0) if sys_info: self.vbox_right.pack_start(self.host_label, True, True, 0) self.vbox_left.pack_start(self.user_label, True, True, 0) self.hbox.pack_start(self.vbox_right, False, True, 20) self.hbox.pack_start(self.vbox_center, True, True, 0) self.hbox.pack_start(self.vbox_left, False, True, 20) self.window.add(self.hbox) self.window.show_all() self.width, self.height = self.window.get_size()
def __init__(self, parent): RenameExtension.__init__(self, parent) # default option needs to be active by default self._checkbox_active.set_active(True) # create expressions self._regexp_name = re.compile( '\[(N|E|C)([\d][^-]*)?-?([\d][^\]]*)?\]', re.I | re.U) self._template = '[N][E]' self._counter = 0 self._counter_start = 0 self._counter_step = 1 self._counter_digits = 1 # create user interface hbox = gtk.HBox(True, 15) vbox_left = gtk.VBox(False, 5) vbox_right = gtk.VBox(False, 5) # help label_help = gtk.Label() label_help.set_alignment(0, 0) label_help.set_use_markup(True) label_help.set_markup( _('<b>Template syntax</b>\n' '[N]\tItem name\n' '[E]\tExtension\n' '[C]\tCounter\n\n' 'For name and extension you can\n' 'use range in format [N#-#].')) # template vbox_template = gtk.VBox(False, 0) hbox_template = gtk.HBox(False, 2) label_template = gtk.Label(_('Template:')) label_template.set_alignment(0, 0.5) self._entry_template = gtk.Entry() self._entry_template.set_text(self._template) self._entry_template.connect('changed', self.__template_changed) style = gtk.RcStyle() style.xthickness = 0 style.ythickness = 0 image_add = gtk.Image() image_add.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) button_add = gtk.Button() button_add.set_image(image_add) button_add.modify_style(style) button_add.connect('clicked', self.__button_add_clicked) # create popup menu self._add_menu = gtk.Menu() item_add_name = gtk.MenuItem(label=_('Name')) item_add_name.connect('activate', self.__add_to_template, 'N') item_add_name_part = gtk.MenuItem(label=_('Part of name')) item_add_name_part.connect('activate', self.__add_range_to_template, 'N') item_separator1 = gtk.SeparatorMenuItem() item_add_extension = gtk.MenuItem(label=_('Extension')) item_add_extension.connect('activate', self.__add_to_template, 'E') item_add_extension_part = gtk.MenuItem(label=_('Part of extension')) item_add_extension_part.connect('activate', self.__add_range_to_template, 'E') item_separator2 = gtk.SeparatorMenuItem() item_add_counter = gtk.MenuItem(label=_('Counter')) item_add_counter.connect('activate', self.__add_to_template, 'C') self._add_menu.append(item_add_name) self._add_menu.append(item_add_name_part) self._add_menu.append(item_separator1) self._add_menu.append(item_add_extension) self._add_menu.append(item_add_extension_part) self._add_menu.append(item_separator2) self._add_menu.append(item_add_counter) self._add_menu.show_all() # counter frame_counter = gtk.Frame(label=_('Counter')) table_counter = gtk.Table(3, 2) table_counter.set_border_width(5) table_counter.set_col_spacings(5) label_start = gtk.Label(_('Start:')) label_start.set_alignment(0, 0.5) adjustment = gtk.Adjustment(0, 0, 10**10, 1, 10) self._entry_start = gtk.SpinButton(adjustment, 0, 0) self._entry_start.connect('value-changed', self.__counter_changed) label_step = gtk.Label(_('Step:')) label_step.set_alignment(0, 0.5) adjustment = gtk.Adjustment(1, 1, 10**10, 1, 10) self._entry_step = gtk.SpinButton(adjustment, 0, 0) self._entry_step.connect('value-changed', self.__counter_changed) label_digits = gtk.Label(_('Digits:')) label_digits.set_alignment(0, 0.5) adjustment = gtk.Adjustment(1, 1, 20, 1, 5) self._entry_digits = gtk.SpinButton(adjustment, 0, 0) self._entry_digits.connect('value-changed', self.__counter_changed) # repack 'active' check box self.vbox.remove(self._checkbox_active) vbox_left.pack_start(self._checkbox_active, False, False, 0) # pack interface table_counter.attach(label_start, 0, 1, 0, 1) table_counter.attach(self._entry_start, 0, 1, 1, 2, xoptions=gtk.EXPAND | gtk.FILL) table_counter.attach(label_step, 1, 2, 0, 1) table_counter.attach(self._entry_step, 1, 2, 1, 2, xoptions=gtk.EXPAND | gtk.FILL) table_counter.attach(label_digits, 2, 3, 0, 1) table_counter.attach(self._entry_digits, 2, 3, 1, 2, xoptions=gtk.EXPAND | gtk.FILL) frame_counter.add(table_counter) hbox_template.pack_start(self._entry_template, True, True, 0) hbox_template.pack_start(button_add, False, False, 0) vbox_template.pack_start(label_template, False, False, 0) vbox_template.pack_start(hbox_template, False, False, 0) vbox_left.pack_start(vbox_template, False, False, 0) vbox_left.pack_start(frame_counter, False, False, 0) vbox_right.pack_start(label_help, True, True, 0) hbox.pack_start(vbox_left, True, True, 0) hbox.pack_start(vbox_right, True, True, 0) self.vbox.pack_start(hbox, True, True, 0) self.vbox.show_all()
gtk.Frame.__init__(self) self.set_shadow_type(gtk.SHADOW_NONE) self._flabel = gtk.Label() self._set_label(label) self.set_label_widget(self._flabel) def _set_label(self, label): self._flabel.set_markup("<b>%s</b>" % label) # Demo if __name__ == "__main__": w = gtk.Window() hframe = HIGFrame("Sample HIGFrame") aalign = gtk.Alignment(0, 0, 0, 0) aalign.set_padding(12, 0, 24, 0) abox = gtk.VBox() aalign.add(abox) hframe.add(aalign) w.add(hframe) for i in xrange(5): abox.pack_start(gtk.Label("Sample %d" % i), False, False, 3) w.connect('destroy', lambda d: gtk.main_quit()) w.show_all() gtk.main()
def __init__(self, gui): Simulation.__init__(self, gui) self.set_title(_("Homogeneous scaling")) self.scaling_is_ready = False vbox = gtk.VBox() self.packtext(vbox, scaling_txt) self.packimageselection(vbox, txt1="", txt2="") self.start_radio_nth.set_active(True) pack(vbox, gtk.Label("")) # Radio buttons for choosing deformation mode. tbl = gtk.Table(4,3) for i, l in enumerate([_('3D deformation '), _('2D deformation '), _('1D deformation ')]): lbl = gtk.Label(l) tbl.attach(lbl, i, i+1, 0, 1) self.radio_bulk = gtk.RadioButton(None, _("Bulk")) tbl.attach(self.radio_bulk, 0, 1, 1, 2) self.radio_xy = gtk.RadioButton(self.radio_bulk, _("xy-plane")) tbl.attach(self.radio_xy, 1, 2, 1, 2) self.radio_xz = gtk.RadioButton(self.radio_bulk, _("xz-plane")) tbl.attach(self.radio_xz, 1, 2, 2, 3) self.radio_yz = gtk.RadioButton(self.radio_bulk, _("yz-plane")) tbl.attach(self.radio_yz, 1, 2, 3, 4) self.radio_x = gtk.RadioButton(self.radio_bulk, _("x-axis")) tbl.attach(self.radio_x, 2, 3, 1, 2) self.radio_y = gtk.RadioButton(self.radio_bulk, _("y-axis")) tbl.attach(self.radio_y, 2, 3, 2, 3) self.radio_z = gtk.RadioButton(self.radio_bulk, _("z-axis")) tbl.attach(self.radio_z, 2, 3, 3, 4) tbl.show_all() pack(vbox, [tbl]) self.deformtable = [ (self.radio_bulk, (1,1,1)), (self.radio_xy, (1,1,0)), (self.radio_xz, (1,0,1)), (self.radio_yz, (0,1,1)), (self.radio_x, (1,0,0)), (self.radio_y, (0,1,0)), (self.radio_z, (0,0,1))] self.allow_non_pbc = gtk.CheckButton( _("Allow deformation along non-periodic directions.")) pack(vbox, [self.allow_non_pbc]) self.allow_non_pbc.connect('toggled', self.choose_possible_deformations) # Parameters for the deformation framedef = gtk.Frame(_("Deformation:")) vbox2 = gtk.VBox() vbox2.show() framedef.add(vbox2) self.max_scale = gtk.Adjustment(0.010, 0.001, 10.0, 0.001) max_scale_spin = gtk.SpinButton(self.max_scale, 10.0, 3) pack(vbox2, [gtk.Label(_("Maximal scale factor: ")), max_scale_spin]) self.scale_offset = gtk.Adjustment(0.0, -10.0, 10.0, 0.001) self.scale_offset_spin = gtk.SpinButton(self.scale_offset, 10.0, 3) pack(vbox2, [gtk.Label(_("Scale offset: ")), self.scale_offset_spin]) self.nsteps = gtk.Adjustment(5, 3, 1000, 1) nsteps_spin = gtk.SpinButton(self.nsteps, 1, 0) pack(vbox2, [gtk.Label(_("Number of steps: ")), nsteps_spin]) self.pull = gtk.CheckButton(_("Only positive deformation")) pack(vbox2, [self.pull]) self.pull.connect('toggled', self.pull_toggled) # Atomic relaxations framerel = gtk.Frame(_("Atomic relaxations:")) vbox2 = gtk.VBox() vbox2.show() framerel.add(vbox2) self.radio_relax_on = gtk.RadioButton(None, _("On ")) self.radio_relax_off = gtk.RadioButton(self.radio_relax_on, _("Off")) self.radio_relax_off.set_active(True) pack(vbox2, [self.radio_relax_on, self.radio_relax_off]) self.make_minimize_gui(vbox2) for r in (self.radio_relax_on, self.radio_relax_off): r.connect("toggled", self.relax_toggled) self.relax_toggled() pack(vbox, [framedef, gtk.Label(" "), framerel]) pack(vbox, gtk.Label("")) # Results pack(vbox, [gtk.Label(_("Results:"))]) self.radio_results_keep = gtk.RadioButton( None, _("Keep original configuration")) self.radio_results_optimal = gtk.RadioButton( self.radio_results_keep, _("Load optimal configuration")) self.radio_results_all = gtk.RadioButton( self.radio_results_optimal, _("Load all configurations")) self.radio_results_keep.set_active(True) pack(vbox, [self.radio_results_keep]) pack(vbox, [self.radio_results_optimal]) pack(vbox, [self.radio_results_all]) # Output field #label = gtk.Label("Strain\t\tEnergy [eV]\n") outframe = self.makeoutputfield(None, heading=_("Strain\t\tEnergy [eV]")) fitframe = gtk.Frame(_("Fit:")) fitframe.set_size_request(100,150) vbox2 = gtk.VBox() vbox2.show() fitframe.add(vbox2) self.radio_fit_2 = gtk.RadioButton(None, _("2nd")) self.radio_fit_3 = gtk.RadioButton(self.radio_fit_2, _("3rd")) self.radio_fit_2.connect("toggled", self.change_fit) self.radio_fit_3.connect("toggled", self.change_fit) self.radio_fit_3.set_active(True) pack(vbox2, [gtk.Label(_("Order of fit: ")), self.radio_fit_2, self.radio_fit_3]) pack(vbox2, [gtk.Label("")]) scrwin = gtk.ScrolledWindow() scrwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.fit_output = gtk.TextBuffer() txtview = gtk.TextView(self.fit_output) txtview.set_editable(False) scrwin.add(txtview) scrwin.show_all() self.fit_win = scrwin vbox2.pack_start(scrwin, True, True, 0) hbox = gtk.HBox(homogeneous=True) for w in [outframe, fitframe]: hbox.pack_start(w) w.show() pack(vbox, hbox) pack(vbox, gtk.Label("")) # Status field self.status_label = gtk.Label("") pack(vbox, [self.status_label]) # Activate the right deformation buttons self.choose_possible_deformations(first=True) # Run buttons etc. self.makebutbox(vbox, helptext=help_txt) vbox.show() if self.use_scrollbar: self.scrwin = gtk.ScrolledWindow() self.scrwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrwin.add_with_viewport(vbox) self.scrwin.show() self.add(self.scrwin) self.scaling_is_ready = True self.set_reasonable_size() else: self.add(vbox) self.show() self.gui.register_vulnerable(self)
def __init__(self): # widgets self._widget = None self._model = None self._status = None self._label = None # other self._NumId = 0 self._NumBbl = 0 self._NumIns = 0 self._SizeCode = 0 self._SizeStub = 0 self._SizeX = 0 self._breakpoints = [] # vbox = gtk.VBox() vbox.show() self._widget = vbox #<<<<<<<<<<<<< ############################################################################ ## title row ############################################################################ hbox = gtk.HBox() hbox.show() vbox.pack_start(hbox,0,0) label = gtk.Label() label.set_markup("<b>ha!</b>") label.show() self._status = label #<<<<<<<<<<<<< hbox.pack_start(label,0,0) def button_reload(widget): self._model.clear() if self._mode == "plain": for (addr,trace) in Trace.CodeCache: if trace._type == "X": continue self.add_trace(trace) elif self._mode == "detailed": for (addr,trace) in Trace.CodeCache: self.add_trace(trace) else: assert(0) self.update_status() return button = gtk.Button("Refresh Display") button.show() hbox.pack_end(button,0,0) button.connect("clicked", button_reload) self._mode = None def combobox_changed(widget): self._mode = widget.get_text() return combo = gtk.Combo() combo.set_use_arrows_always(1) # combo.disable_activate() combo.entry.set_editable(0) combo.set_popdown_strings(CodeCacheWidget.DisplayModes) combo.entry.connect("changed", combobox_changed) combo.show() combobox_changed(combo.entry) hbox.pack_end(combo,0,0,0) ############################################################################ ## table ############################################################################ self._model = apply(gtk.ListStore,[obj for (obj,title) in CodeCacheWidget.TableRows]) if 1: window = self.create_list_widget() vbox.pack_start(window) else: hpane = gtk.HPaned() hpane.show() vbox.pack_start(hpane) window = self.create_list_widget() hpane.add1(window) window = self.create_list_widget() hpane.add2(window) ############################################################################ ## individual trace ############################################################################ frame = gtk.Frame("Individual Trace") # frame.set_shadow_type( gtk.SHADOW_ETCHED_IN) frame.show() vbox.pack_start(frame,0,0) hbox = gtk.HBox() hbox.show() frame.add(hbox) button = gtk.Button(" Flush ") button.show() hbox.pack_end(button,0,0) label = gtk.Label(" id ") label.show() hbox.pack_start(label,0,0) adjustment = gtk.Adjustment(value=0, lower=0, upper=1000000000, step_incr=1, page_incr=100, page_size=100) spinbutton = gtk.SpinButton(adjustment, climb_rate=1.0, digits=0) spinbutton.show() hbox.pack_start(spinbutton,0,0) label = gtk.Label() label.set_markup("") label.show() self._label = label #<<<<<<<<<<<<< hbox.pack_start(label,0,0) def id_change(widget): id = int(widget.get_value()) trace = FindTraceById(id) self._label.set_markup( trace and trace.trace2markup() or "<b>trace not found</b>") return adjustment.connect("value_changed", id_change) adjustment.set_value(0) ############################################################################ ## action ############################################################################ frame = gtk.Frame("Trace Cache") frame.show() vbox.pack_start(frame,0,0) hbox = gtk.HBox() hbox.show() frame.add(hbox) button = gtk.Button(" Flush ") button.show() hbox.pack_end(button,0,0) def button_stats(widget): print self._status.get_text() return button = gtk.Button(" Print Stats ") button.show() hbox.pack_end(button,0,0) button.connect("clicked", button_stats) self._dump_counter = 0 def inc_and_set_count(widget): self._dump_counter += 1 widget.set_label(" Save As: dump.%d.trace " % self._dump_counter) return def button_dump_trace(widget): DumpTraceFile( "dump.%d.trace" % self._dump_counter) inc_and_set_count(widget) return button = gtk.Button("") inc_and_set_count( button ) button.show() hbox.pack_end(button,0,0) button.connect("clicked", button_dump_trace) ############################################################################ ## breakpoints ############################################################################ frame = gtk.Frame("Break Points") frame.show() vbox.pack_start(frame,0,0) hbox = gtk.HBox() hbox.show() frame.add(hbox) self._tracing = 0 def button_resume(widget): if self._tracing: return self._tracing = 1 widget.set_label("Tracing ...") gobject.io_add_watch(self._tf, gobject.IO_IN , TrackFile) return button = gtk.Button("Start Tracing") button.show() hbox.pack_end(button,0,0) button.connect("clicked", button_resume) self._trace_button = button #<<<<<<<<<<<<< button = gtk.CheckButton("Break on Flush") button.show() hbox.pack_end(button,0,0) def breakpoint_changed(widget): self._breakpoints = [string.strip(s) for s in string.split(widget.get_text(),",")] for (index,value) in enumerate(self._breakpoints): try: self._breakpoints[index] = long(value,0) except: pass print "breakpoints: ", self._breakpoints return entry = gtk.Entry() entry.show() # entry.connect("activate", breakpoint_changed) entry.connect("changed", breakpoint_changed) hbox.pack_start(entry) return
def __init__(self, activity, channels): #Se utiliza para contralar que no se ejecute dos veces self._butia_context_id = None gtk.Toolbar.__init__(self) self.activity = activity self._channels = channels self.mode = 'butia' # Set up Sensores Button self.time = RadioToolButton(group=None) # Mantiene la lista de botones (de sensores) # agregados a la ButiaToolbar self.lista_sensores_button = [] self.we_are_logging = False self._log_this_sample = False self._logging_timer = None self._logging_counter = 0 self._image_counter = 0 self._logging_interval = 0 self._channels_logged = [] self._busy = False self._take_screenshot = True # BUTIA Se detectan sensores log.debug('se agrega el boton refrescar') self.refrescar_button = RadioToolButton(group=None) self.refrescar_button.set_named_icon('recargar') self.refrescar_button.connect('clicked', self.update_buttons) self.insert(self.refrescar_button, -1) separator = gtk.SeparatorToolItem() separator.props.draw = True self.insert(separator, -1) self.robot = pybot_client.robot() self.detect_sensors() self.load_buttons() separator = gtk.SeparatorToolItem() separator.props.draw = True self.insert(separator, -1) self._log_value = LOG_TIMER_VALUES[1] self.log_label = gtk.Label(self._log_to_string(self._log_value)) toolitem = gtk.ToolItem() toolitem.add(self.log_label) self.insert(toolitem, -1) self._log_button = ToolButton('timer-10') self._log_button.set_tooltip(_('Select logging interval')) self._log_button.connect('clicked', self._log_selection_cb) self.insert(self._log_button, -1) self._setup_log_palette() # Set up Logging/Stop Logging Button self._record = ToolButton('media-record') self.insert(self._record, -1) self._record.set_tooltip(_('Start Recording')) self._record.connect('clicked', self.record_control_cb) log.debug('***showing all*****') self.show_all() gobject.timeout_add(1000, self.update_buttons)
def add(self, notebook): tab = gtk.Label(self.title) tab.show() notebook.append_page(self.contents, tab)
def __init__(self): super(PyApp, self).__init__() #self.set_icon_from_file("icon.png") #taskbar icon added self.set_size_request(650, 400) self.set_position(gtk.WIN_POS_CENTER) self.connect("destroy", gtk.main_quit) self.set_title("ProjectX") self.current_directory = '/' self.copy_dir = ["/home/ayush/Music"] self.paste_dir = "/home" vbox = gtk.VBox(False, 0) #MenuBar declarations main_menu_bar = gtk.MenuBar() file_menu = gtk.Menu() file_menu_dropdown = gtk.MenuItem("File") file_new = gtk.MenuItem("New Folder") file_open = gtk.MenuItem("Open") file_exit = gtk.MenuItem("Exit") file_menu_dropdown.set_submenu(file_menu) file_menu.append(file_new) file_menu.append(file_open) file_menu.append(file_exit) main_menu_bar.append(file_menu_dropdown) vbox.pack_start(main_menu_bar, False, False, 0) file_exit.connect("activate", gtk.main_quit) file_open.connect("activate", self.on_open_clicked, "Open") file_new.connect("activate", self.on_newfolder_clicked) edit_menu = gtk.Menu() edit_menu_dropdown = gtk.MenuItem("Edit") edit_cut = gtk.MenuItem("Cut") edit_copy = gtk.MenuItem("Copy") edit_paste = gtk.MenuItem("Paste") edit_rename = gtk.MenuItem("Rename") edit_delete = gtk.MenuItem("Delete") edit_menu_dropdown.set_submenu(edit_menu) edit_menu.append(edit_cut) edit_menu.append(edit_copy) edit_menu.append(edit_paste) edit_menu.append(edit_rename) edit_menu.append(edit_delete) main_menu_bar.append(edit_menu_dropdown) edit_cut.connect("activate", self.on_cut, "Cut") edit_copy.connect("activate", self.on_copy, "Copy") edit_paste.connect("activate", self.on_paste, "Paste") edit_rename.connect("activate", self.on_rename_clicked, "Rename") edit_delete.connect("activate", self.on_delete, "Delete") terminal_menu = gtk.Menu() terminal_menu_dropdown = gtk.MenuItem("Terminal") terminal_launchterminal = gtk.MenuItem("Launch Terminal") terminal_launchterminal_pwd = gtk.MenuItem( "Launch Terminal in Current Directory") terminal_menu_dropdown.set_submenu(terminal_menu) terminal_menu.append(terminal_launchterminal) terminal_menu.append(terminal_launchterminal_pwd) main_menu_bar.append(terminal_menu_dropdown) terminal_launchterminal.connect("activate", self.on_launch_terminal_clicked) terminal_launchterminal_pwd.connect( "activate", self.on_launch_terminal_pwd_clicked) help_menu = gtk.Menu() help_menu_dropdown = gtk.MenuItem("Help") help_about = gtk.MenuItem("About") help_menu_dropdown.set_submenu(help_menu) help_menu.append(help_about) main_menu_bar.append(help_menu_dropdown) help_about.connect("activate", self.on_about_clicked) #ends here #Toolbars for bifurcation title_toolbar = gtk.Toolbar() vbox.pack_start(title_toolbar, False, False, 0) bookmarks_toolbar = gtk.Toolbar() vbox.pack_start(bookmarks_toolbar, False, False, 0) infobar_toolbar = gtk.Toolbar() vbox.pack_end(infobar_toolbar, False, False, 0) #ends here #current directory bar self.pwd = gtk.Label() self.pwd.set_markup(self.current_directory) item3 = gtk.ToolItem() item3.add(self.pwd) infobar_toolbar.insert(item3, -1) #ends here #bookmarks bar bookmarks_label = gtk.Label("Go To :") item1 = gtk.ToolItem() item1.add(bookmarks_label) bookmarks_toolbar.insert(item1, -1) sep1 = gtk.SeparatorToolItem() #seperator bookmarks_toolbar.insert(sep1, 1) self.desktop_Button = gtk.ToolButton(label="Desktop") self.desktop_Button.set_is_important(True) bookmarks_toolbar.insert(self.desktop_Button, -1) self.documents_Button = gtk.ToolButton(label="Documents") self.documents_Button.set_is_important(True) bookmarks_toolbar.insert(self.documents_Button, -1) self.downloads_Button = gtk.ToolButton(label="Downloads") self.downloads_Button.set_is_important(True) bookmarks_toolbar.insert(self.downloads_Button, -1) self.music_Button = gtk.ToolButton(label="Music") self.music_Button.set_is_important(True) bookmarks_toolbar.insert(self.music_Button, -1) self.pictures_Button = gtk.ToolButton(label="Pictures") self.pictures_Button.set_is_important(True) bookmarks_toolbar.insert(self.pictures_Button, -1) self.videos_Button = gtk.ToolButton(label="Videos") self.videos_Button.set_is_important(True) bookmarks_toolbar.insert(self.videos_Button, -1) #ends here #up home forward back search toolbar declaration toolbar = gtk.Toolbar() vbox.pack_start(toolbar, False, False, 0) #ends here #home and up buttons self.upButton = gtk.ToolButton(gtk.STOCK_GO_UP) self.upButton.set_is_important(True) self.upButton.set_sensitive(False) toolbar.insert(self.upButton, -1) homeButton = gtk.ToolButton(gtk.STOCK_HOME) homeButton.set_is_important(True) toolbar.insert(homeButton, -1) #ends here # Back and Forward buttons self.backButton = gtk.ToolButton(gtk.STOCK_GO_BACK) self.backButton.set_is_important(True) self.backButton.set_sensitive(False) toolbar.insert(self.backButton, -1) self.forwardButton = gtk.ToolButton(gtk.STOCK_GO_FORWARD) self.forwardButton.set_is_important(True) self.forwardButton.set_sensitive(False) toolbar.insert(self.forwardButton, -1) #ends here #search bar sep = gtk.SeparatorToolItem() #seperator toolbar.insert(sep, 4) self.searchfile = gtk.Entry() self.searchfile.set_text("") item = gtk.ToolItem() item.add(self.searchfile) toolbar.insert(item, -1) self.searchButton = gtk.ToolButton(gtk.STOCK_FIND) self.searchButton.set_is_important(True) toolbar.insert(self.searchButton, -1) self.searchButton.connect("clicked", self.searchfunc) #ends here self.fileIcon = self.get_icon(gtk.STOCK_FILE) self.dirIcon = self.get_icon(gtk.STOCK_DIRECTORY) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vbox.pack_start(sw, True, True, 0) self.store = self.create_store() self.fill_store() ####### eventbox = gtk.EventBox() iconView = gtk.IconView(self.store) iconView.set_selection_mode(gtk.SELECTION_MULTIPLE) #bookmarks toolbar signal connection self.desktop_Button.connect("clicked", self.on_desktop_clicked) self.documents_Button.connect("clicked", self.on_documents_clicked) self.downloads_Button.connect("clicked", self.on_downloads_clicked) self.music_Button.connect("clicked", self.on_music_clicked) self.pictures_Button.connect("clicked", self.on_pictures_clicked) self.videos_Button.connect("clicked", self.on_videos_clicked) #ends here #signal connection of up,home,forward and back buttons self.upButton.connect("clicked", self.on_up_clicked) homeButton.connect("clicked", self.on_home_clicked) self.backButton.connect("clicked", self.on_back_clicked) self.forwardButton.connect("clicked", self.on_forward_clicked) #ends iconView.set_text_column(COL_PATH) iconView.set_pixbuf_column(COL_PIXBUF) iconView.connect("item-activated", self.on_item_activated) #extra iconView.connect("selection-changed", self.on_item_clicked) #extra # extra eventbox.add(iconView) # Right Click Popup menu rightClickMenu = gtk.Menu() item1 = gtk.MenuItem("Open") rightClickMenu.append(item1) item1.connect("activate", self.on_open_clicked, "Open") item2 = gtk.MenuItem("Copy") rightClickMenu.append(item2) item2.connect("activate", self.on_copy, "Copy") item3 = gtk.MenuItem("Cut") rightClickMenu.append(item3) item3.connect("activate", self.on_cut, "Cut") item4 = gtk.MenuItem("Paste") rightClickMenu.append(item4) item4.connect("activate", self.on_paste, "Paste") item5 = gtk.MenuItem("Delete") rightClickMenu.append(item5) item5.connect("activate", self.on_delete, "Delete") # Terminal submenu terminalMenu = gtk.Menu() item6 = gtk.MenuItem("Launch Terminal") terminalMenu.append(item6) item6.connect("activate", self.on_launch_terminal_clicked) item7 = gtk.MenuItem("Launch Terminal in Current Directory") terminalMenu.append(item7) item7.connect("activate", self.on_launch_terminal_pwd_clicked) item8 = gtk.MenuItem("Terminal") rightClickMenu.append(item8) item8.set_submenu(terminalMenu) #Properties item9 = gtk.MenuItem("Properties") rightClickMenu.append(item9) item9.connect("activate", self.on_properties_clicked) item10 = gtk.MenuItem("Rename") rightClickMenu.append(item10) item10.connect("activate", self.on_rename_clicked) item1.show() item2.show() item3.show() item4.show() item5.show() item6.show() item7.show() item8.show() item9.show() item10.show() terminalMenu.show() rightClickMenu.show() eventbox.connect_object("button-press-event", self.on_button_press_event, rightClickMenu) #iconView.connect("button-press-event", self.on_button_press_event_iconView) # RIght Click ends sw.add_with_viewport(eventbox) # extra ends iconView.grab_focus() self.add(vbox) self.show_all()
def _dynamic_tab(self, notebook, text): s = gtk.Socket() notebook.append_page(s, gtk.Label(" " + text + " ")) return s.get_id()
def showSelect(self): selLabel=gtk.Label("Please select the test items") scrollWin=gtk.ScrolledWindow() scrollWin.set_size_request(300,400) scrollWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.vbox.pack_start(selLabel, False,False, 20) store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_INT ) self.con_db() self.get_type_from_db() self.typeNum = 0 #self.get_kblayout() for item in self.alltype: store.append((item[0], None, item[1])) self.typeNum += 1 treeView = gtk.TreeView(store) cell2 = gtk.CellRendererToggle() cell2.set_property('activatable', True) cell2.connect( 'toggled', self.on_item_clicked, store) cell1 = gtk.CellRendererText() cell1.set_property( 'editable', False ) #cell1.connect( 'edited', self.col0_edited_cb, store ) column1 = gtk.TreeViewColumn("Test type\t\t\t\t\t\t\t", cell1, text=0) column2 = gtk.TreeViewColumn("\t\t\t\t\tSelect", cell2 ) column2.add_attribute( cell2, "active", 1) #cell.connect("toggled", self.on_item_clicked) treeView.append_column(column1) treeView.append_column(column2) treeView.columns_autosize() scrollWin.add(treeView) #select all self.chkAll = gtk.CheckButton("Check All") self.chkAll.set_active(False) self.chkAll.unset_flags(gtk.CAN_FOCUS) self.chkAll.connect("clicked", self.on_chkAll_clicked, store) #just all automatic test item self.chkOnlyAuto = gtk.CheckButton("Auto test all automatic items") self.chkOnlyAuto.set_active(False) self.chkOnlyAuto.unset_flags(gtk.CAN_FOCUS) self.chkOnlyAuto.connect("clicked", self.on_chkOnlyAuto_clicked, store) #total select label self.selMsgLabel = gtk.Label() hbox1 = gtk.HBox() hbox1.pack_end(self.selMsgLabel, False, False,5) hbox2 = gtk.HBox() hbox2.pack_start(self.chkAll, False, False, 0) hbox2.pack_start(self.chkOnlyAuto, False, False, 30) #start button startBtn = gtk.Button("Start") startBtn.connect("clicked", self.start_test_clicked, store) startBtn.set_size_request(100, 30) startBtn.set_tooltip_text("Click me,start test") self.set_button_bg_color(startBtn, button_bg_color) hbox3 = gtk.HBox() hbox3.pack_start(startBtn, True, False, 0) startBtn.set_size_request(100, 30) treeView.set_rules_hint(True) self.vbox.pack_start(scrollWin, False,False, 2) self.vbox.pack_start(hbox1, False,False, 0) self.vbox.pack_start(hbox2, False,False, 20) self.vbox.pack_start(hbox3, False,False, 20)
def ask(self, callback): self.callback = callback window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("TeX Text") window.set_default_size(600, 400) label1 = gtk.Label(u"Preamble file:") label2 = gtk.Label(u"Scale factor:") label3 = gtk.Label(u"Text:") if hasattr(gtk, 'FileChooserButton'): self._preamble = gtk.FileChooserButton("...") if os.path.exists(self.preamble_file): self._preamble.set_filename(self.preamble_file) self._preamble.set_action(gtk.FILE_CHOOSER_ACTION_OPEN) else: self._preamble = gtk.Entry() self._preamble.set_text(self.preamble_file) self._scale_adj = gtk.Adjustment(lower=0.01, upper=100, step_incr=0.1, page_incr=1) self._scale = gtk.SpinButton(self._scale_adj, digits=2) if self.scale_factor is not None: self._scale_adj.set_value(self.scale_factor) else: self._scale_adj.set_value(1.0) self._scale.set_sensitive(False) self._text = gtk.TextView() self._text.get_buffer().set_text(self.text) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) sw.add(self._text) self._ok = gtk.Button(stock=gtk.STOCK_OK) self._cancel = gtk.Button(stock=gtk.STOCK_CANCEL) # layout table = gtk.Table(3, 2, False) table.attach(label1, 0,1,0,1,xoptions=0,yoptions=gtk.FILL) table.attach(self._preamble, 1,2,0,1,yoptions=gtk.FILL) table.attach(label2, 0,1,1,2,xoptions=0,yoptions=gtk.FILL) table.attach(self._scale, 1,2,1,2,yoptions=gtk.FILL) table.attach(label3, 0,1,2,3,xoptions=0,yoptions=gtk.FILL) table.attach(sw, 1,2,2,3) vbox = gtk.VBox(False, 5) vbox.pack_start(table) hbox = gtk.HButtonBox() hbox.add(self._ok) hbox.add(self._cancel) hbox.set_layout(gtk.BUTTONBOX_SPREAD) vbox.pack_end(hbox, expand=False, fill=False) window.add(vbox) # signals window.connect("delete-event", self.cb_delete_event) window.connect("key-press-event", self.cb_key_press) self._ok.connect("clicked", self.cb_ok) self._cancel.connect("clicked", self.cb_cancel) # show window.show_all() self._text.grab_focus() # run self._window = window gtk.main() return self.text, self.preamble_file, self.scale_factor
def show_test(self): self.testVbox=gtk.VBox() #print self.nowItem label="".join("%s (%d/%d)" %(str(self.tcInfo[self.nowItem-1][1]).decode('utf-8'), self.nowItem,self.allSelItem)) self.title_label = gtk.Label(label) #hbox item strItem="".join("%s : %s" %(str(self.tcInfo[self.nowItem-1][6]).decode('utf-8'),str(self.tcInfo[self.nowItem-1][7]).decode('utf-8'))) self.item_label = gtk.Label(strItem) hbox1 = gtk.HBox(False, 2) hbox1.pack_start(self.item_label, False, False, 2) self.check_hk_tip() cmd="".join("echo %d > /tmp/.nowItem" % self.nowItem) os.system(cmd) #the file result to if not os.path.isfile(result_file): os.system("".join("echo [test_result] > %s" % result_file)) self.rsConfig = ConfigParser.ConfigParser() self.rsConfig.readfp(open(result_file), "rw") if not self.rsConfig.has_section("test_result"): self.add_section(section) # test step stepLabel=gtk.Label("test step:") self.step_buffer = gtk.TextBuffer() self.step_buffer.set_text(self.tcInfo[self.nowItem -1][2].decode('utf-8')) stepScrolledWin=gtk.ScrolledWindow() stepTextView = gtk.TextView(self.step_buffer) stepTextView.set_editable(False) stepTextView.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(514, 5140, 5140)) stepTextView.set_cursor_visible(False) stepTextView.set_wrap_mode (gtk.WRAP_CHAR) stepTextView.set_size_request(100, 150) stepScrolledWin.add(stepTextView) stepScrolledWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) # test biaozhun stdLabel = gtk.Label("standard:") self.std_buffer = gtk.TextBuffer() self.std_buffer.set_text(self.tcInfo[self.nowItem -1][3].decode('utf-8')) stdScrolledWin=gtk.ScrolledWindow() stdTextView = gtk.TextView(self.std_buffer) stdTextView.set_editable(False) stdTextView.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(514, 220, 50)) stdTextView.set_cursor_visible(False) stdTextView.set_wrap_mode (gtk.WRAP_CHAR) stdTextView.set_size_request(100, 150) stdScrolledWin.add(stdTextView) stdScrolledWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) # comment commentLabel = gtk.Label("comment:") self.comment_buffer = gtk.TextBuffer() #self.comment_buffer.set_text(self.tcInfo[0][3].decode('utf-8')) commentScrolledWin=gtk.ScrolledWindow() commentTextView = gtk.TextView(self.comment_buffer) commentTextView.set_editable(True) commentTextView.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(514, 220, 50)) commentTextView.set_cursor_visible(True) commentTextView.set_wrap_mode (gtk.WRAP_CHAR) commentTextView.set_size_request(100, 75) commentScrolledWin.add(commentTextView) commentScrolledWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.radio_pass = gtk.RadioButton() self.radio_pass.set_label("PASS") self.radio_fail = gtk.RadioButton(self.radio_pass, "FAIL", True) self.next_button = gtk.Button(TEXT_NEXT) self.next_button.set_size_request(BTN_WIDTH,BTN_HEIGHT) self.next_button.connect("clicked", self.on_next_click) self.back_button = gtk.Button(TEXT_BACK) self.back_button.set_size_request(BTN_WIDTH,BTN_HEIGHT) self.back_button.connect("clicked", self.on_back_click) self.auto_button = gtk.Button("Auto test") self.auto_button.connect("clicked", self.on_auto_click) self.auto_button.set_size_request(BTN_WIDTH,BTN_HEIGHT) self.skip_button = gtk.Button(TEXT_SKIP) self.skip_button.connect("clicked", self.on_skip_click) self.skip_button.set_size_request(BTN_WIDTH,BTN_HEIGHT) #self.set_widget_icon(self.next_button,"/home/tom/test/python/icon.png" ) #self.set_widget_icon(self.back_button,"/home/tom/test/python/start-here.png" ) #self.set_bg_image(self.skip_button,"/home/tom/Media/bg/4.jpg" ) hbox = gtk.HBox(False, 2) hbox.pack_start(self.back_button, True, False, 15) hbox.pack_start(self.radio_pass, True, False, 30) hbox.pack_start(self.radio_fail, True, False, 20) hbox.pack_start(self.next_button, True, False, 30) hbox.pack_start(self.auto_button, True, False, 30) hbox.pack_start(self.skip_button, True, False, 30) #pack the three label to hbox stepHbox = gtk.HBox() stepHbox.pack_start(stepLabel, False, False, 2) stdHbox = gtk.HBox() stdHbox.pack_start(stdLabel, False, False, 2) commentHbox = gtk.HBox() commentHbox.pack_start(commentLabel, False, False, 2) #pack to vbox self.testVbox.pack_start(self.title_label, False, False, 2) self.testVbox.pack_start(hbox1, False, False, 2) self.testVbox.pack_start(stepHbox, False, False, 2) self.testVbox.pack_start(stepScrolledWin, True, True, 2) self.testVbox.pack_start(stdHbox, False, False, 5) self.testVbox.pack_start(stdScrolledWin, True, True, 2) self.testVbox.pack_start(commentHbox, False, False, 5) self.testVbox.pack_start(commentScrolledWin, True, True, 2) self.testVbox.pack_start(hbox, False, False, 5) self.remove(self.vbox) self.set_button_bg_color(self.next_button, button_bg_color) self.set_button_bg_color(self.auto_button, button_bg_color) #self.set_button_bg_color(self.back_button, button_bg_color) #self.set_button_bg_color(self.skip_button, button_bg_color) self.set_button_bg_color(self.radio_pass, button_bg_color) self.set_button_bg_color(self.radio_fail, button_bg_color) self.set_button_bg_color(self.testVbox, button_bg_color) self.add(self.testVbox) self.modify_window_color() #stdTextView.setBackgroundColor(Color.argb(255, 0, 255, 0)); #set Alpha #stdScrolledWin.get_window().set_opacity(0.80) #stdTextView.get_window(gtk.TEXT_WINDOW_WIDGET).set_opacity(0.80) #self.set_bg_image(self,"/home/tom/Media/icon/1.jpg") #self.set_bg_image(self.skip_button,"/home/tom/test/python/icon.png") #self.set_widget_icon(self.back_button, "/home/tom/test/python/icon.png") #self.skip_button.window.set_opacity(0.5) self.show_all() self.lastTime = time.time() self.judge_show_button()
def create_window(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy", self.destroy) self.window.set_default_size(400, 300) self.window.set_border_width(20) self.window.set_title("Xpra Launcher") self.window.modify_bg(gtk.STATE_NORMAL, gdk.Color(red=65535, green=65535, blue=65535)) icon_pixbuf = self.get_icon("xpra.png") if icon_pixbuf: self.window.set_icon(icon_pixbuf) self.window.set_position(gtk.WIN_POS_CENTER) vbox = gtk.VBox(False, 0) vbox.set_spacing(15) # Title hbox = gtk.HBox(False, 0) if icon_pixbuf: logo_button = gtk.Button("") settings = logo_button.get_settings() settings.set_property('gtk-button-images', True) logo_button.connect("clicked", about) set_tooltip_text(logo_button, "About") image = gtk.Image() image.set_from_pixbuf(icon_pixbuf) logo_button.set_image(image) hbox.pack_start(logo_button, expand=False, fill=False) label = gtk.Label("Connect to xpra server") label.modify_font(pango.FontDescription("sans 14")) hbox.pack_start(label, expand=True, fill=True) vbox.pack_start(hbox) # Mode: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Mode: ")) self.mode_combo = gtk.combo_box_new_text() self.mode_combo.get_model().clear() self.mode_combo.append_text("TCP") self.mode_combo.append_text("TCP + AES") self.mode_combo.append_text("SSH") self.mode_combo.connect("changed", self.mode_changed) hbox.pack_start(self.mode_combo) vbox.pack_start(hbox) # Encoding: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Encoding: ")) self.encoding_combo = gtk.OptionMenu() def get_current_encoding(): return self.config.encoding def set_new_encoding(e): self.config.encoding = e encodings = [ x for x in PREFERED_ENCODING_ORDER if x in self.client.get_encodings() ] server_encodings = encodings es = make_encodingsmenu(get_current_encoding, set_new_encoding, encodings, server_encodings) self.encoding_combo.set_menu(es) set_history_from_active(self.encoding_combo) hbox.pack_start(self.encoding_combo) vbox.pack_start(hbox) self.encoding_combo.connect("changed", self.encoding_changed) # Quality hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.quality_label = gtk.Label("Quality: ") hbox.pack_start(self.quality_label) self.quality_combo = gtk.OptionMenu() def set_min_quality(q): self.config.min_quality = q def set_quality(q): self.config.quality = q def get_min_quality(): return self.config.min_quality def get_quality(): return self.config.quality sq = make_min_auto_menu("Quality", MIN_QUALITY_OPTIONS, QUALITY_OPTIONS, get_min_quality, get_quality, set_min_quality, set_quality) self.quality_combo.set_menu(sq) set_history_from_active(self.quality_combo) hbox.pack_start(self.quality_combo) vbox.pack_start(hbox) # Speed hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.speed_label = gtk.Label("Speed: ") hbox.pack_start(self.speed_label) self.speed_combo = gtk.OptionMenu() def set_min_speed(s): self.config.min_speed = s def set_speed(s): self.config.speed = s def get_min_speed(): return self.config.min_speed def get_speed(): return self.config.speed ss = make_min_auto_menu("Speed", MIN_SPEED_OPTIONS, SPEED_OPTIONS, get_min_speed, get_speed, set_min_speed, set_speed) self.speed_combo.set_menu(ss) set_history_from_active(self.speed_combo) hbox.pack_start(self.speed_combo) vbox.pack_start(hbox) # Username@Host:Port hbox = gtk.HBox(False, 0) hbox.set_spacing(5) self.username_entry = gtk.Entry(max=128) self.username_entry.set_width_chars(16) self.username_entry.connect("changed", self.validate) set_tooltip_text(self.username_entry, "SSH username") self.username_label = gtk.Label("@") self.host_entry = gtk.Entry(max=128) self.host_entry.set_width_chars(24) self.host_entry.connect("changed", self.validate) set_tooltip_text(self.host_entry, "hostname") self.port_entry = gtk.Entry(max=5) self.port_entry.set_width_chars(5) self.port_entry.connect("changed", self.validate) hbox.pack_start(self.username_entry) hbox.pack_start(self.username_label) hbox.pack_start(self.host_entry) hbox.pack_start(gtk.Label(":")) hbox.pack_start(self.port_entry) vbox.pack_start(hbox) # Password hbox = gtk.HBox(False, 0) hbox.set_spacing(20) self.password_entry = gtk.Entry(max=128) self.password_entry.set_width_chars(30) self.password_entry.set_text("") self.password_entry.set_visibility(False) self.password_entry.connect("changed", self.password_ok) self.password_entry.connect("changed", self.validate) self.password_label = gtk.Label("Password: "******"red") if color_obj: self.info.modify_fg(gtk.STATE_NORMAL, color_obj) vbox.pack_start(self.info) # Buttons: hbox = gtk.HBox(False, 20) vbox.pack_start(hbox) #Save: self.save_btn = gtk.Button("Save") set_tooltip_text(self.save_btn, "Save settings to a session file") self.save_btn.connect("clicked", self.save_clicked) hbox.pack_start(self.save_btn) #Load: self.load_btn = gtk.Button("Load") set_tooltip_text(self.load_btn, "Load settings from a session file") self.load_btn.connect("clicked", self.load_clicked) hbox.pack_start(self.load_btn) # Connect button: self.button = gtk.Button("Connect") self.button.connect("clicked", self.connect_clicked) connect_icon = self.get_icon("retry.png") if connect_icon: self.button.set_image(scaled_image(connect_icon, 24)) hbox.pack_start(self.button) def accel_close(*args): gtk.main_quit() add_close_accel(self.window, accel_close) vbox.show_all() self.window.vbox = vbox self.window.add(vbox)
def show_test_result(self): idLabel = gtk.Label("ID") itemLabel = gtk.Label("Test Item") rsLabel = gtk.Label("Result") self.rsVbox = gtk.VBox() self.rs_buffer = gtk.TextBuffer() rsScrolledWin=gtk.ScrolledWindow() rsTextView = gtk.TextView(self.rs_buffer) rsTextView.set_editable(False) rsTextView.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(514, 5140, 5140)) rsTextView.set_cursor_visible(False) rsTextView.set_wrap_mode (gtk.WRAP_CHAR) rsTextView.set_size_request(300, 490) rsScrolledWin.add(rsTextView) rsScrolledWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) rslist = self.get_all_result() i = 0 count = len(rslist[0]) print "count============",count rsText="" while i < count: strid="".join("%-10s" % rslist[0][i]) stritem="".join("%-80s" % rslist[1][i]) #tmp=rsText+"".join("%-15.30s %-80.90s %20s\n" %(rslist[0][i], rslist[1][i], rslist[2][i])) if str(rslist[2][i]).find("P") != -1: strrs="P" elif str(rslist[2][i]).find("F") != -1: strrs="Fail" else: strrs="" rsText = rsText + "".join(" %10s\t%5s\t\t%-80s\t\n" %(strid, strrs, stritem)) i = i+1 self.rs_buffer.set_text(rsText) strSucc=" Congratulations!\n You have completed all the test items, the following is a summary of the test results.\n Click 'submit' to upload the result." succLabel = gtk.Label(strSucc) succLabel.set_line_wrap(True) #succLabel.set_wrap_mode (gtk.WRAP_CHAR); succLabel.modify_text(gtk.STATE_NORMAL,finish_text_color) fontdesc = pango.FontDescription("Purisa 10") succLabel.modify_font(fontdesc) attr = pango.AttrList() fg_color = pango.AttrForeground(6, 60000, 0, 0, 300) size = pango.AttrSize(15000, 0, 18) attr.insert(fg_color) attr.insert(size) succLabel.set_attributes(attr) succLabel.set_size_request(WIN_WIDTH-20, 60) hbox1 = gtk.HBox() hbox1.pack_start(succLabel,False,False, 5) hbox2 = gtk.HBox() hbox2.pack_start(idLabel,False,False, 20) hbox2.pack_start(rsLabel,False,False, 40) hbox2.pack_start(itemLabel,False,False, 40) hbox3 = gtk.HBox() submit_button = gtk.Button("Submit") submit_button.set_size_request(BTN_WIDTH,BTN_HEIGHT) submit_button.connect("clicked", self.on_submit_click) exit_button = gtk.Button("Exit") exit_button.set_size_request(BTN_WIDTH,BTN_HEIGHT) exit_button.connect("clicked", self.on_exit_click) self.saveCheck = gtk.CheckButton("Delete test results when exit.") self.saveCheck.set_active(False) #if need to show the tester config = ConfigParser.ConfigParser() config.readfp(open(config_file), "rb") self.ShowTester = config.getint("Config", "show_tester") if(self.ShowTester == 1): name_label = gtk.Label("Tester:") self.name_entry = gtk.Entry() hbox3.pack_start(name_label,True,False, 1) hbox3.pack_start(self.name_entry,True,False, 1) #end hbox3.pack_start(submit_button,True,False, 10) hbox3.pack_start(exit_button,True,False, 5) hbox3.pack_start(self.saveCheck,True,True, 5) self.rsVbox.pack_start(hbox1, False, False, 2) self.rsVbox.pack_start(hbox2, False, False, 2) self.rsVbox.pack_start(rsScrolledWin, True, True, 5) self.rsVbox.pack_start(hbox3, False, False, 5) self.rsVbox.show_all() #self.remove(self.testVbox) self.add(self.rsVbox) self.show_all() return
def __init__(self): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_title(_("Titler")) self.connect("delete-event", lambda w, e:close_titler()) if editorstate.SCREEN_HEIGHT < 800: global TEXT_LAYER_LIST_HEIGHT, TEXT_VIEW_HEIGHT, VIEW_EDITOR_HEIGHT TEXT_LAYER_LIST_HEIGHT = 200 TEXT_VIEW_HEIGHT = 225 VIEW_EDITOR_HEIGHT = 550 self.block_updates = False self.view_editor = vieweditor.ViewEditor(PLAYER().profile, VIEW_EDITOR_WIDTH, VIEW_EDITOR_HEIGHT) self.view_editor.active_layer_changed_listener = self.active_layer_changed self.guides_toggle = vieweditor.GuidesViewToggle(self.view_editor) add_b = gtk.Button(_("Add")) del_b = gtk.Button(_("Delete")) add_b.connect("clicked", lambda w:self._add_layer_pressed()) del_b.connect("clicked", lambda w:self._del_layer_pressed()) add_del_box = gtk.HBox() add_del_box = gtk.HBox(True,1) add_del_box.pack_start(add_b) add_del_box.pack_start(del_b) center_h_icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "center_horizontal.png") center_v_icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "center_vertical.png") center_h = gtk.Button() center_h.set_image(center_h_icon) center_h.connect("clicked", lambda w:self._center_h_pressed()) center_v = gtk.Button() center_v.set_image(center_v_icon) center_v.connect("clicked", lambda w:self._center_v_pressed()) self.layer_list = TextLayerListView(self._layer_selection_changed, self._layer_visibility_toggled) self.layer_list.set_size_request(TEXT_LAYER_LIST_WIDTH, TEXT_LAYER_LIST_HEIGHT) self.text_view = gtk.TextView() self.text_view.set_pixels_above_lines(2) self.text_view.set_left_margin(2) self.text_view.get_buffer().connect("changed", self._text_changed) self.sw = gtk.ScrolledWindow() self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.sw.add(self.text_view) self.sw.set_size_request(TEXT_VIEW_WIDTH, TEXT_VIEW_HEIGHT) scroll_frame = gtk.Frame() scroll_frame.add(self.sw) self.tc_display = guicomponents.MonitorTCDisplay() self.tc_display.use_internal_frame = True self.pos_bar = positionbar.PositionBar() self.pos_bar.set_listener(self.position_listener) self.pos_bar.update_display_from_producer(PLAYER().producer) self.pos_bar.mouse_release_listener = self.pos_bar_mouse_released pos_bar_frame = gtk.Frame() pos_bar_frame.add(self.pos_bar.widget) pos_bar_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN) font_map = pangocairo.cairo_font_map_get_default() unsorted_families = font_map.list_families() if len(unsorted_families) == 0: print "No font families found in system! Titler will not work." self.font_families = sorted(unsorted_families, key=lambda family: family.get_name()) self.font_family_indexes_for_name = {} combo = gtk.combo_box_new_text() indx = 0 for family in self.font_families: combo.append_text(family.get_name()) self.font_family_indexes_for_name[family.get_name()] = indx indx += 1 combo.set_active(0) self.font_select = combo self.font_select.connect("changed", self._edit_value_changed) adj = gtk.Adjustment(float(DEFAULT_FONT_SIZE), float(1), float(300), float(1)) self.size_spin = gtk.SpinButton(adj) self.size_spin.connect("changed", self._edit_value_changed) self.size_spin.connect("key-press-event", self._key_pressed_on_widget) font_main_row = gtk.HBox() font_main_row.pack_start(self.font_select, True, True, 0) font_main_row.pack_start(guiutils.pad_label(5, 5), False, False, 0) font_main_row.pack_start(self.size_spin, False, False, 0) self.bold_font = gtk.ToggleButton() self.italic_font = gtk.ToggleButton() bold_icon = gtk.image_new_from_stock(gtk.STOCK_BOLD, gtk.ICON_SIZE_BUTTON) italic_icon = gtk.image_new_from_stock(gtk.STOCK_ITALIC, gtk.ICON_SIZE_BUTTON) self.bold_font.set_image(bold_icon) self.italic_font.set_image(italic_icon) self.bold_font.connect("clicked", self._edit_value_changed) self.italic_font.connect("clicked", self._edit_value_changed) self.left_align = gtk.RadioButton() self.center_align = gtk.RadioButton(self.left_align) self.right_align = gtk.RadioButton(self.left_align) left_icon = gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_LEFT, gtk.ICON_SIZE_BUTTON) center_icon = gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_CENTER, gtk.ICON_SIZE_BUTTON) right_icon = gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_RIGHT, gtk.ICON_SIZE_BUTTON) self.left_align.set_image(left_icon) self.center_align.set_image(center_icon) self.right_align.set_image(right_icon) self.left_align.set_mode(False) self.center_align.set_mode(False) self.right_align.set_mode(False) self.left_align.connect("clicked", self._edit_value_changed) self.center_align.connect("clicked", self._edit_value_changed) self.right_align.connect("clicked", self._edit_value_changed) self.color_button = gtk.ColorButton() self.color_button.connect("color-set", self._edit_value_changed) buttons_box = gtk.HBox() buttons_box.pack_start(gtk.Label(), True, True, 0) buttons_box.pack_start(self.bold_font, False, False, 0) buttons_box.pack_start(self.italic_font, False, False, 0) buttons_box.pack_start(guiutils.pad_label(5, 5), False, False, 0) buttons_box.pack_start(self.left_align, False, False, 0) buttons_box.pack_start(self.center_align, False, False, 0) buttons_box.pack_start(self.right_align, False, False, 0) buttons_box.pack_start(guiutils.pad_label(5, 5), False, False, 0) buttons_box.pack_start(self.color_button, False, False, 0) buttons_box.pack_start(gtk.Label(), True, True, 0) load_layers = gtk.Button(_("Load Layers")) load_layers.connect("clicked", lambda w:self._load_layers_pressed()) save_layers = gtk.Button(_("Save Layers")) save_layers.connect("clicked", lambda w:self._save_layers_pressed()) clear_layers = gtk.Button(_("Clear All")) clear_layers.connect("clicked", lambda w:self._clear_layers_pressed()) layers_save_buttons_row = gtk.HBox() layers_save_buttons_row.pack_start(save_layers, False, False, 0) layers_save_buttons_row.pack_start(load_layers, False, False, 0) layers_save_buttons_row.pack_start(gtk.Label(), True, True, 0) #layers_save_buttons_row.pack_start(clear_layers, False, False, 0) adj = gtk.Adjustment(float(0), float(0), float(3000), float(1)) self.x_pos_spin = gtk.SpinButton(adj) self.x_pos_spin.connect("changed", self._position_value_changed) self.x_pos_spin.connect("key-press-event", self._key_pressed_on_widget) adj = gtk.Adjustment(float(0), float(0), float(3000), float(1)) self.y_pos_spin = gtk.SpinButton(adj) self.y_pos_spin.connect("changed", self._position_value_changed) self.y_pos_spin.connect("key-press-event", self._key_pressed_on_widget) adj = gtk.Adjustment(float(0), float(0), float(3000), float(1)) self.rotation_spin = gtk.SpinButton(adj) self.rotation_spin.connect("changed", self._position_value_changed) self.rotation_spin.connect("key-press-event", self._key_pressed_on_widget) undo_pos = gtk.Button() undo_icon = gtk.image_new_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_BUTTON) undo_pos.set_image(undo_icon) next_icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "next_frame_s.png") prev_icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "prev_frame_s.png") prev_frame = gtk.Button() prev_frame.set_image(prev_icon) prev_frame.connect("clicked", lambda w:self._prev_frame_pressed()) next_frame = gtk.Button() next_frame.set_image(next_icon) next_frame.connect("clicked", lambda w:self._next_frame_pressed()) self.scale_selector = vieweditor.ScaleSelector(self) timeline_box = gtk.HBox() timeline_box.pack_start(guiutils.get_in_centering_alignment(self.tc_display.widget), False, False, 0) timeline_box.pack_start(guiutils.get_in_centering_alignment(pos_bar_frame, 1.0), True, True, 0) timeline_box.pack_start(prev_frame, False, False, 0) timeline_box.pack_start(next_frame, False, False, 0) timeline_box.pack_start(self.guides_toggle, False, False, 0) timeline_box.pack_start(self.scale_selector, False, False, 0) positions_box = gtk.HBox() positions_box.pack_start(gtk.Label(), True, True, 0) positions_box.pack_start(gtk.Label("X:"), False, False, 0) positions_box.pack_start(self.x_pos_spin, False, False, 0) positions_box.pack_start(guiutils.pad_label(10, 5), False, False, 0) positions_box.pack_start(gtk.Label("Y:"), False, False, 0) positions_box.pack_start(self.y_pos_spin, False, False, 0) positions_box.pack_start(guiutils.pad_label(10, 5), False, False, 0) #positions_box.pack_start(gtk.Label(_("Angle")), False, False, 0) #positions_box.pack_start(self.rotation_spin, False, False, 0) positions_box.pack_start(guiutils.pad_label(10, 5), False, False, 0) positions_box.pack_start(center_h, False, False, 0) positions_box.pack_start(center_v, False, False, 0) positions_box.pack_start(gtk.Label(), True, True, 0) controls_panel_1 = gtk.VBox() controls_panel_1.pack_start(add_del_box, False, False, 0) controls_panel_1.pack_start(self.layer_list, False, False, 0) controls_panel_1.pack_start(layers_save_buttons_row, False, False, 0) controls_panel_2 = gtk.VBox() controls_panel_2.pack_start(scroll_frame, True, True, 0) controls_panel_2.pack_start(font_main_row, False, False, 0) controls_panel_2.pack_start(buttons_box, False, False, 0) controls_panel = gtk.VBox() controls_panel.pack_start(guiutils.get_named_frame(_("Active Layer"),controls_panel_2), True, True, 0) controls_panel.pack_start(guiutils.get_named_frame(_("Layers"),controls_panel_1), False, False, 0) view_editor_editor_buttons_row = gtk.HBox() view_editor_editor_buttons_row.pack_start(positions_box, False, False, 0) view_editor_editor_buttons_row.pack_start(gtk.Label(), True, True, 0) keep_label = gtk.Label(_("Keep Layers When Closed")) self.keep_layers_check = gtk.CheckButton() self.keep_layers_check.set_active(_keep_titler_data) self.keep_layers_check.connect("toggled", self._keep_layers_toggled) open_label = gtk.Label(_("Open Saved Title In Bin")) self.open_in_current_check = gtk.CheckButton() self.open_in_current_check.set_active(_open_saved_in_bin) self.open_in_current_check.connect("toggled", self._open_saved_in_bin) exit_b = guiutils.get_sized_button(_("Close"), 150, 32) exit_b.connect("clicked", lambda w:close_titler()) save_titles_b = guiutils.get_sized_button(_("Save Title Graphic"), 150, 32) save_titles_b.connect("clicked", lambda w:self._save_title_pressed()) editor_buttons_row = gtk.HBox() editor_buttons_row.pack_start(gtk.Label(), True, True, 0) editor_buttons_row.pack_start(keep_label, False, False, 0) editor_buttons_row.pack_start(self.keep_layers_check, False, False, 0) editor_buttons_row.pack_start(guiutils.pad_label(24, 2), False, False, 0) editor_buttons_row.pack_start(open_label, False, False, 0) editor_buttons_row.pack_start(self.open_in_current_check, False, False, 0) editor_buttons_row.pack_start(guiutils.pad_label(24, 2), False, False, 0) editor_buttons_row.pack_start(exit_b, False, False, 0) editor_buttons_row.pack_start(save_titles_b, False, False, 0) editor_panel = gtk.VBox() editor_panel.pack_start(self.view_editor, True, True, 0) editor_panel.pack_start(timeline_box, False, False, 0) editor_panel.pack_start(guiutils.get_in_centering_alignment(view_editor_editor_buttons_row), False, False, 0) editor_panel.pack_start(guiutils.pad_label(2, 24), False, False, 0) editor_panel.pack_start(editor_buttons_row, False, False, 0) editor_row = gtk.HBox() editor_row.pack_start(controls_panel, False, False, 0) editor_row.pack_start(editor_panel, True, True, 0) alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0) alignment.set_padding(8,8,8,8) alignment.add(editor_row) self.add(alignment) self.layer_list.fill_data_model() self._update_gui_with_active_layer_data() self.show_all() self.connect("size-allocate", lambda w, e:self.window_resized()) self.connect("window-state-event", lambda w, e:self.window_resized())
def InitialiseColumns(treeview, *args): i = 0 cols = [] for c in args: if c[2] == "text": renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(c[0], renderer, text=i) elif c[2] == "number": renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(c[0], renderer, text=i) renderer.set_property("xalign", 1) elif c[2] == "colored": renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(c[0], renderer, text=i, foreground=c[3][0], background=c[3][1]) elif c[2] == "edit": renderer = gtk.CellRendererText() renderer.set_property('editable', True) column = gtk.TreeViewColumn(c[0], renderer, text=i) elif c[2] == "combo": renderer = gtk.CellRendererCombo() renderer.set_property('text-column', 0) renderer.set_property('editable', True) column = gtk.TreeViewColumn(c[0], renderer, text=i) elif c[2] == "progress": renderer = gtk.CellRendererProgress() column = gtk.TreeViewColumn(c[0], renderer, value=i) elif c[2] == "toggle": renderer = gtk.CellRendererToggle() column = gtk.TreeViewColumn(c[0], renderer, active=i) renderer.set_property("xalign", 0.5) else: renderer = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(c[0], renderer, pixbuf=i) if c[1] == -1: column.set_resizable(False) column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) else: column.set_resizable(True) if c[1] == 0: column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) else: column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) column.set_fixed_width(c[1]) column.set_min_width(0) if len(c) > 3 and type(c[3]) is not list: column.set_cell_data_func(renderer, c[3]) column.set_reorderable(True) column.set_widget(gtk.Label(c[0])) column.get_widget().show() treeview.append_column(column) cols.append(column) i += 1 return cols
def _new_notebook_page(self, widget, label): l = gtk.Label('') l.set_text_with_mnemonic(label) self.notebook.append_page(widget,l)
def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.connect("delete_event", self.delete) window.set_border_width(10) table = gtk.Table(3,6,False) window.add(table) # Create a new notebook, place the position of the tabs notebook = gtk.Notebook() notebook.set_tab_pos(gtk.POS_TOP) table.attach(notebook, 0,6,0,1) notebook.show() self.show_tabs = True self.show_border = True # Let's append a bunch of pages to the notebook for i in range(5): bufferf = "Append Frame %d" % (i+1) bufferl = "Page %d" % (i+1) frame = gtk.Frame(bufferf) frame.set_border_width(10) frame.set_size_request(100, 75) frame.show() label = gtk.Label(bufferf) frame.add(label) label.show() label = gtk.Label(bufferl) notebook.append_page(frame, label) # Now let's add a page to a specific spot checkbutton = gtk.CheckButton("Check me please!") checkbutton.set_size_request(100, 75) checkbutton.show () label = gtk.Label("Add page") notebook.insert_page(checkbutton, label, 2) # Now finally let's prepend pages to the notebook for i in range(5): bufferf = "Prepend Frame %d" % (i+1) bufferl = "PPage %d" % (i+1) frame = gtk.Frame(bufferf) frame.set_border_width(10) frame.set_size_request(100, 75) frame.show() label = gtk.Label(bufferf) frame.add(label) label.show() label = gtk.Label(bufferl) notebook.prepend_page(frame, label) # Set what page to start at (page 4) notebook.set_current_page(3) # Create a bunch of buttons button = gtk.Button("close") button.connect("clicked", self.delete) table.attach(button, 0,1,1,2) button.show() button = gtk.Button("next page") button.connect("clicked", lambda w: notebook.next_page()) table.attach(button, 1,2,1,2) button.show() button = gtk.Button("prev page") button.connect("clicked", lambda w: notebook.prev_page()) table.attach(button, 2,3,1,2) button.show() button = gtk.Button("tab position") button.connect("clicked", self.rotate_book, notebook) table.attach(button, 3,4,1,2) button.show() button = gtk.Button("tabs/border on/off") button.connect("clicked", self.tabsborder_book, notebook) table.attach(button, 4,5,1,2) button.show() button = gtk.Button("remove page") button.connect("clicked", self.remove_book, notebook) table.attach(button, 5,6,1,2) button.show() table.show() window.show()