def start_gui(datadir): if not options.profile: if cfg.get_bool("app/noprofilemanager"): options.profile = cfg.get_string("app/last_profile") elif do_profiles(): if solfege.splash_win: solfege.splash_win.hide() p = ProfileManager(cfg.get_string("app/last_profile")) ret = p.run() if ret == Gtk.ResponseType.ACCEPT: options.profile = p.get_profile() cfg.set_string("app/last_profile", "" if not options.profile else options.profile) elif ret in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT): Gtk.main_quit() return p.destroy() if solfege.splash_win: solfege.splash_win.show() cfg.set_bool('config/no_random', bool(options.no_random)) lessonfile.infocache = lessonfile.InfoCache() def f(s): if solfege.splash_win: solfege.splash_win.show_progress(s) if solfege.splash_win: solfege.splash_win.show_progress(_("Opening statistics database")) try: solfege.db = statistics.DB(f, profile=options.profile) except sqlite3.OperationalError, e: solfege.splash_win.hide() gu.dialog_ok(_(u"Failed to open the statistics database:\n«%s»") % str(e).decode(sys.getfilesystemencoding(), 'replace'), secondary_text=_("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once.")) sys.exit()
def flush_events(self): # docstring inherited Gdk.threads_enter() while Gtk.events_pending(): Gtk.main_iteration() Gdk.flush() Gdk.threads_leave()
def main(self): tdbglobal.tdblogdebug("start gtk main loop") self.window.connect("delete-event", Gtk.main_quit) self.host = self.builder.get_object("e_main_db") self.host.set_text(config.SERVERNAME) self.window.show() Gtk.main()
def drag_begin_cb(self, widget, context): color = self.get_managed_color() preview = GdkPixbuf.Pixbuf.new( GdkPixbuf.Colorspace.RGB, False, 8, 32, 32) pixel = color.to_fill_pixel() preview.fill(pixel) Gtk.drag_set_icon_pixbuf(context, preview, 0, 0)
def test_go_to_saves_current(self): self.pl.go_to(5) self.failUnlessEqual(self.pl.current, 5) self.pl.set([5, 10, 15, 20]) Gtk.main_iteration_do(False) self.pl.next() self.failUnlessEqual(self.pl.current, 10)
def __key_function(self, entry, event): log.LOG("START __key_function") if event.keyval == Gdk.KEY_Return: self.entryCommandLine.emit_stop_by_name('key_press_event') elif event.keyval in (Gdk.KEY_KP_Up, Gdk.KEY_Up, Gdk.KEY_Page_Up): self.entryCommandLine.emit_stop_by_name('key_press_event') self.historyUp() elif event.keyval in (Gdk.KEY_KP_Down, Gdk.KEY_Down, Gdk.KEY_Page_Down): self.entryCommandLine.emit_stop_by_name('key_press_event') self.historyDown() elif event.keyval in (Gdk.KEY_D, Gdk.KEY_d) and\ event.state & Gdk.ModifierType.CONTROL_MASK: self.entryCommandLine.emit_stop_by_name('key_press_event') self.setHisoryFile() gtk.main_quit() self.window.destroy() log.LOG("END __key_function")
def __expanded(self, iter, path, model): window = self.get_window() if window: window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) Gtk.main_iteration_do(False) try: try: if model is None: return while model.iter_has_child(iter): model.remove(model.iter_children(iter)) folder = model[iter][0] for path in listdir(folder): try: if not os.path.isdir(path): continue for filename in listdir(path): if os.path.isdir(filename): niter = model.append(iter, [path]) model.append(niter, ["dummy"]) break else: model.append(iter, [path]) except OSError: pass if not model.iter_has_child(iter): return True except OSError: pass finally: if window: window.set_cursor(None)
def _gtk_main(): gui = GtkRll() gui.connect("delete-event", Gtk.main_quit) signal(SIGINT, SIG_DFL) gui.show_all() # FIXME: KeyboardInterrupt here hangs it. Gtk.main()
def update_label(self): if not self.accel_string: text = _("unassigned") else: key, codes, mods = Gtk.accelerator_parse_with_keycode(self.accel_string) text = Gtk.accelerator_get_label_with_keycode(None, key, codes[0], mods) self.set_property("text", text)
def on_ChooseButton_clicked(*args): ChooseDialog.hide() while Gtk.events_pending(): Gtk.main_iteration() for row in choose_list: if row[0] is True: to_add.add(row[1].split(":")[0]) # split done in case of optdep choice
def main(db, debug=False): builder = Gtk.Builder() builder.add_from_file("view/notebook.glade") liststore = builder.get_object("liststore") view = builder.get_object("treeview_notelist") textbuffer = builder.get_object("current_note_buffer") selection = builder.get_object("treeview_notelist_selection") # Populate the liststore. Set the text buffer to the first note text if # the note db is non-empty query = db.query('') if query != []: for title, uid in query: liststore.append([title, uid]) textbuffer.set_text(db.get_text(query[0][1])) # 0,1 means first note, uid else: liststore.append(db.add_note('')) # Handle empty db # Make sure the first note is selected selection.select_iter(liststore.get_iter("0")) # 0 means first note, no search in-tree handler = Handler(liststore, selection, textbuffer, view, db) builder.connect_signals(handler) if debug is False: window = builder.get_object("main_window") window.show_all() Gtk.main() else: return handler
def log_warning(msg): WarningDialog.format_secondary_text(msg) response = WarningDialog.run() while Gtk.events_pending(): Gtk.main_iteration() if response: WarningDialog.hide()
def log_error(msg): ErrorDialog.format_secondary_text(msg) response = ErrorDialog.run() while Gtk.events_pending(): Gtk.main_iteration() if response: ErrorDialog.hide()
def test_dance_grid (): from . import gsudoku window = Gtk.Window() game = '''9 1 6 3 2 8 4 5 7 5 7 4 6 1 9 2 8 3 8 3 2 5 7 4 9 6 1 6 8 7 2 4 1 3 9 5 2 9 5 7 3 6 1 4 8 3 4 1 8 9 5 7 2 6 4 6 9 1 8 7 5 3 2 1 2 8 9 5 3 6 7 4 7 5 3 4 6 2 8 1 9''' gsd = gsudoku.SudokuGameDisplay(game) dancer = GridDancer(gsd) button = Gtk.Button('toggle') button.connect('clicked', lambda *args: dancer.stop_dancing() if dancer.dancing else dancer.start_dancing()) vbox = Gtk.VBox() vbox.pack_start(gsd, True, True, 0) vbox.pack_end(button, True, True, 0) vbox.set_focus_child(button) window.add(vbox) window.show_all() window.connect('delete-event', Gtk.main_quit) Gtk.main()
def done(self, button): """Confirm choice""" dialog = Gtk.Dialog(txt.I_CONFIRM_SELECTION, None, 0, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) dialog.set_transient_for(self) dialog.set_border_width(10) box = dialog.get_content_area() box.set_spacing(10) box.add(Gtk.Label(txt.I_USE_THESE_MIRRORS)) dialog.show_all() response = dialog.run() if response == Gtk.ResponseType.OK: # Quit GUI dialog.destroy() for line in self.custom_list: line["last_sync"] = line["last_sync"].replace(" ", ":").replace("h", "").replace("m", "") if self.random: shuffle(self.custom_list) else: self.custom_list.sort(key=itemgetter("resp_time")) self.is_done = True Gtk.main_quit() elif response == Gtk.ResponseType.CANCEL: dialog.destroy() # Go back to selection
def install(self): if self._win is not None: self._win.blur() self._win.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) if not self._download_app(): return self._end(False) if self._check_if_installed: if not self._installed_check(): return self._end(False) if not self._get_sudo_pw(): return self._end(False) # Make sure the dialogs are gone before installing while Gtk.events_pending(): Gtk.main_iteration() rv = self._install() if rv and self._report_install: self._report() return self._end(rv)
def run(server_list, random, default=False): """Run""" window = GraphicalUI(server_list, random, default) window.connect("delete-event", Gtk.main_quit) window.show_all() Gtk.main() return window
def run(screen_name): window = Gtk.Window() window.connect('destroy', Gtk.main_quit) window.set_size_request(800, 500) window.set_border_width(12) window.set_title("Cnchi - Test of %s screen" % screen_name) import config settings = config.Settings() settings.set('data', '/usr/share/cnchi/data') from desktop_environments import DESKTOPS settings.set('desktops', DESKTOPS) settings.set('language_code', 'ca') params = {} params['title'] = "Cnchi" params['ui_dir'] = "/usr/share/cnchi/ui" params['disable_tryit'] = False params['settings'] = settings params['forward_button'] = Gtk.Button.new() params['backwards_button'] = Gtk.Button.new() params['main_progressbar'] = Gtk.ProgressBar.new() params['header'] = Gtk.HeaderBar.new() params['testing'] = True params['callback_queue'] = None params['alternate_package_list'] = "" screen = get_screen(screen_name, params) if screen != None: screen.prepare('forward') window.add(screen) window.show_all() Gtk.main() else: print("Unknown screen")
def main(self): log.LOG("START main") "Run main loop" gtk.main() log.LOG("END main")
def _runSpoke(self, action): from gi.repository import Gtk # This duplicates code in widgets/src/BaseWindow.c, but we want to make sure # maximize gets called every time a spoke is displayed to prevent the 25% # UI from showing up. action.window.maximize() action.window.set_property("expand", True) action.refresh() action.window.set_beta(self.window.get_beta()) action.window.set_property("distribution", distributionText().upper()) action.window.set_transient_for(self.window) action.window.show_all() # Start a recursive main loop for this spoke, which will prevent # signals from going to the underlying (but still displayed) Hub and # prevent the user from switching away. It's up to the spoke's back # button handler to kill its own layer of main loop. Gtk.main() action.window.set_transient_for(None) action._visitedSinceApplied = True # Don't take _visitedSinceApplied into account here. It will always be # True from the line above. if action.changed and (not action.skipTo or (action.skipTo and action.applyOnSkip)): action.apply() action.execute() action._visitedSinceApplied = False
def get_cell_data_cb(self, column, cell, model, piter, user_data=None): tool = model.get_value(piter, self.TOOL_COLUMN) if tool == None or not isinstance(tool, Tool): if tool == None: label = _('All Languages') elif not isinstance(tool, GtkSource.Language): label = _('Plain Text') else: label = tool.get_name() markup = saxutils.escape(label) editable = False else: escaped = saxutils.escape(tool.name) if tool.shortcut: key, mods = Gtk.accelerator_parse(tool.shortcut) label = Gtk.accelerator_get_label(key, mods) markup = '%s (<b>%s</b>)' % (escaped, label) else: markup = escaped editable = True cell.set_properties(markup=markup, editable=editable)
def on_botonVer_clicked(self, widget): ''' Evento del boton Ver para mostrar los datos del evento. Llama a la clase Evento que crea una ventana con las tablas de la BD ''' ventanaEvento = vEvento.Evento() ventanaEvento.connect("delete-event", Gtk.main_quit) ventanaEvento.show_all() Gtk.main()
def update_accelerator_label(self): if self.current_node.shortcut: key, mods = Gtk.accelerator_parse(self.current_node.shortcut) label = Gtk.accelerator_get_label(key, mods) self['accelerator'].set_text(label) else: self['accelerator'].set_text('')
def main(): win = ScrolledInfoBarDemoWindow() win.set_size_request(600, 300) win.set_position(Gtk.WindowPosition.MOUSE) win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main()
def test_next_nosong_536(self): self.pl.go_to(1) self.pl.repeat = True self.pl.order = ORDERS[1](self.pl) self.pl.set([]) Gtk.main_iteration_do(False) self.pl.next()
def recordLine(self): '''Listen to temperature data from the serial port, save to a log file (csv) and return as a list: return log = [datetime_stamp, temperature] ''' try: n = 0 while n < 5: # Record temp from the defined log number row = self.ser.readline() logger = row.split(' ')[0] temp = row.split(' ')[1] if int(logger) == self.log_no: print('row ', str(self.log_no), row) date_num = date2num(datetime.now()) self.log = [str(datetime.now()), float(temp)] #self.temp_read = self.log self.liststore.append(self.log) self.plotpoints() # Send email alert if temp > 5: sendEmailAlert(self.log_no, temp) row = None temp = None n += 1 while Gtk.events_pending(): Gtk.main_iteration() # runs the GTK main loop as needed except: print('Could not read serial device') self.temp_read = None return True
def destroy(self, window): try: self.conn.destroy() except AttributeError: pass Gtk.main_quit()
def main(): for opt in sys.argv[1:]: if opt in ('-h', '--help'): usage() sys.exit() elif opt in ('-d', '--dev'): config.ENABLE_INSPECTOR = True else: print "hotot: unrecognized option '%s'" % opt usage() sys.exit(1) try: import i18n except: from gettext import gettext as _ try: import prctl prctl.set_name('hotot') except: pass GObject.threads_init() config.loads(); agent.init_notify() app = Hotot() agent.app = app Gdk.threads_enter() Gtk.main() Gdk.threads_leave()
def start(self, bridge): """Start the UI event loop.""" bridge.attach(80, 24, True) drawing_area = Gtk.DrawingArea() drawing_area.connect('draw', self._gtk_draw) window = Gtk.Window() window.add(drawing_area) window.set_events(window.get_events() | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.SCROLL_MASK) window.connect('configure-event', self._gtk_configure) window.connect('delete-event', self._gtk_quit) window.connect('key-press-event', self._gtk_key) window.connect('key-release-event', self._gtk_key_release) window.connect('button-press-event', self._gtk_button_press) window.connect('button-release-event', self._gtk_button_release) window.connect('motion-notify-event', self._gtk_motion_notify) window.connect('scroll-event', self._gtk_scroll) window.connect('focus-in-event', self._gtk_focus_in) window.connect('focus-out-event', self._gtk_focus_out) window.show_all() im_context = Gtk.IMMulticontext() im_context.set_client_window(drawing_area.get_window()) im_context.set_use_preedit(False) # TODO: preedit at cursor position im_context.connect('commit', self._gtk_input) self._pango_context = drawing_area.create_pango_context() self._drawing_area = drawing_area self._window = window self._im_context = im_context self._bridge = bridge Gtk.main()
def on_usbcreator_destroy(self, widget): # Unmount devices for device in self.devices: if self.get_device_mount(device) != "": self.unmount_device(device) # Close the app Gtk.main_quit()