def show_window(self):
self.window.show_all()
Gtk.main()
python类main()的实例源码
def show_window(self):
self.window.show_all()
Gtk.main()
def run(self):
self.builder.get_object("stage").show_all()
self.builder.get_object("name").set_text(self.ds.name)
gtk.main()
def run_pi(self):
# suppresses error: Couldn't connect to accessibility bus:
# Failed to connect to socket:
shell_this("export NO_AT_BRIDGE=1")
# listener loop for icon switch signals
ui_thread = Thread(target=self.update_icon)
ui_thread.daemon = True
ui_thread.start()
# starting Gtk main:
Gtk.main()
def __init__(self, scrlck_mode=False):
self.scrlck_mode = scrlck_mode
self.id_q = Queue()
self.on_q = Queue()
self.pi_q = Queue()
# init processes
gi_proc = Process(target=self.get_ids)
gi_proc.daemon = True
cs_proc = Process(target=self.change_state)
# no daemon, or main program will terminate before Keys can be unlocked
cs_proc.daemon = False
zmq_lis = ZmqListener(
self.on_q) # somehow works ony with threads not processes
zmq_lis_thr = Thread(target=zmq_lis.start_listener)
zmq_lis_thr.setDaemon(True)
pi = PanelIndicator(self.pi_q, self.on_q)
# starting processes and catching exceptions:
try:
gi_proc.start()
cs_proc.start()
zmq_lis_thr.start()
pi.run_pi() # main loop of root process
except (KeyboardInterrupt, SystemExit):
print('Caught exit event.')
finally:
# send exit signal, will reactivate YubiKey slots
print('Sending EXIT_SIGNAL')
self.on_q.put(EXIT_SIGNAL)
def main(self):
gtk.main()
#Gets called when the (x) on the window is clicked to close the window. Note that stopping the program from Eclipse will NOT trigger this function
def run(self):
# can't use Gtk.main() because of a bug that prevents proper SIGINT
# handling. use Glib.MainLoop() directly instead.
self.mainloop = GLib.MainLoop() # main loop
# signal.signal(signal.SIGINT, signal.SIG_DFL)
self.logger.debug(_("Starting GLib main loop..."))
self.mainloop.run()
self.logger.debug(_("GLib main loop ended."))
# quit the gui
def __init__(self):
super(WelcomeWindow, self).__init__()
self.hb = Gtk.HeaderBar()
self.hb.set_show_close_button(True)
self.hb.set_title("Py IDE")
self.set_titlebar(self.hb)
self.currentPage = None
self.hbButtons = []
self.language = ''
self.showHome()
##################################################################
self.set_size_request(800, 400)
self.set_resizable(False)
self.loadSettings()
self.connect('destroy', Gtk.main_quit)
self.show_all()
Gtk.main()
def main():
if dbus.SessionBus().request_name(
'es.atareao.PomodoroIndicator') !=\
dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
print("application already running")
exit(0)
GObject.threads_init()
Gst.init(None)
Gst.init_check(None)
Notify.init('pomodoro-indicator')
Pomodoro_Indicator()
Gtk.main()
def run():
Game()
GObject.threads_init()
Gtk.main()
return 0
def start(self):
from gi.repository import Gtk
Gtk.main()
def mail_notify(self, inbox_count):
"""
If inbox_count is unchanged from last update - exit the function.
If new inbox_count is smaller - user read the message
somewhere else (browser, phone app, etc).
"""
notification_config = self.config.get('notifications')
local_inbox_count = self.local_data.get('inbox_count', 0)
if inbox_count == local_inbox_count:
return
elif inbox_count < local_inbox_count:
self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
return
self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ATTENTION)
if not notification_config:
return
if not self.services['notification']:
self.services['notification'] = Notify.init(self.APPINDICATOR_ID)
if notification_config == 1:
message_data = self.request.get_last_message()
header = "reddit mail from <b>{author}</b>".format(author=message_data['author'])
body = message_data['body']
else:
header = "You have a new reddit mail"
body = ''
Notify.Notification.new(
header,
body,
self.ICONS['main']
).show()
def main_loop():
Gtk.main()
def __init__(self):
from playlist_creator import preferences_file_location, systems_list
self.settings_file_location = preferences_file_location
with open(self.settings_file_location) as data_file:
self.preferences_data = json.load(data_file)
builder = Gtk.Builder()
builder.add_from_file("glade/app.glade")
builder.connect_signals(self)
self.notebook = builder.get_object("notebook")
self.renderer_text = Gtk.CellRendererText()
self.playlists_directory_chooser = builder.get_object("playlists_directory_chooser")
self.cores_directory_chooser = builder.get_object("cores_directory_chooser")
self.infos_directory_chooser = builder.get_object("infos_directory_chooser")
self.playlists_location = self.preferences_data[0]['playlists_location']
self.cores_location = self.preferences_data[0]['cores_location']
self.infos_location = self.preferences_data[0]['infos_location']
self.playlists_directory_chooser.set_current_folder(self.playlists_location)
self.cores_directory_chooser.set_current_folder(self.cores_location)
self.infos_directory_chooser.set_current_folder(self.infos_location)
self.system_names = Gtk.ListStore(str)
for system_name in systems_list:
self.system_names.append([system_name])
# get all cores and populate list
self.__populate_cores_list__()
if len(self.preferences_data) > 1:
for system_from_prefs in self.preferences_data[1]:
self.create_new_tab(system_from_prefs['system_name'], system_from_prefs['roms_dir'],
system_from_prefs['core_path'], system_from_prefs['core_name'])
window = builder.get_object("window")
window.show_all()
Gtk.main()
def start(self, bridge):
"""Start the UI event loop."""
bridge.attach(80, 24, rgb=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 main(self):
Gtk.main()
def main():
SIGS = [getattr(signal, s, None) for s in "SIGINT SIGTERM SIGHUP".split()]
for sig in filter(None, SIGS):
signal.signal(sig, idle_handler)
GLib.idle_add(install_glib_handler, sig, priority=GLib.PRIORITY_HIGH)
IEE = ImunesExperimentExporter()
IEE.main()
def __init__(self, *args):
super(main, self).__init__(*args)
self.data = []
self.graph = None
self.charts = None
self.win = Gtk.Window()
self.set_border_width(4)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_title("PySpc : Statistical Process Control Charts for Humans")
self.set_default_size(480, 600)
self.connect("delete-event", Gtk.main_quit)
self.buildui()
def get_new_values(self, widget):
"""
When ComboBox changed, main window will update all labels informations
"""
nb1, nb2 = self.combo.get_active(), self.combo2.get_active()
self.img_name1, self.img_name2 = self.coin_list[nb1], self.coin_list[nb2]
self.get_items(widget = "window")
def main(self):
"""
Main function
"""
window = self.builder.get_object("window1")
window.connect("delete-event", self.safe_quit, "kill ui")
window.show_all()