def __init__(self):
Gtk.Window.__init__(self)
self.get_settings().set_property(
"gtk-application-prefer-dark-theme", True)
self.connect('destroy', lambda x: Gtk.main_quit())
# Layout
self.box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
self.add(self.box)
self.abar = Gtk.ActionBar()
self.box.pack_end(self.abar, False, False, 0)
self.build_contents()
# Finalize the window itself
self.set_titlebar(self.headerbar())
self.set_title("Foreign Package Installer")
self.set_icon_name("system-software-install")
self.set_size_request(600, 450)
self.set_position(Gtk.WindowPosition.CENTER)
self.show_all()
python类main_quit()的实例源码
def _quit(self, *args):
if len(self.filesObject) > 0:
unsaved = False
unsavedFile = ''
for i,f in enumerate(self.filesObject):
if not f['curText'] == f['originalText']:
unsaved = True
unsavedFile = os.path.basename(f['path'])
break
if unsaved:
res = self.confirm('{} is not saved, are you sure you want to exit without saving?'.format(os.path.basename(f['path'])))
if res:
self.linter.do_deactivate()
Gtk.main_quit()
else:
return True
else:
self.linter.do_deactivate()
Gtk.main_quit()
else:
self.linter.do_deactivate()
Gtk.main_quit()
def __init__(self):
Gtk.Window.__init__(self, title="BTC Widget")
self._ticker_labels = {}
self._tickers_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self._create_ticker_labels()
self._graph = btcwidget.graph.Graph(config['dark_theme'])
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
vbox.pack_start(self._tickers_vbox, False, False, 5)
vbox.pack_start(self._graph, True, True, 0)
self.set_icon_from_file(self._ICON_PATH)
self.connect('delete-event', Gtk.main_quit)
self.add(vbox)
self.show_all()
self._indicator = Indicator(self)
# self.open_options()
def _create_menu(self):
menu = Gtk.Menu()
self._menu_item = Gtk.MenuItem("Bitcoin")
self._menu_item.connect('activate', self._on_show_item_activate)
menu.append(self._menu_item)
options_menu_item = Gtk.MenuItem("Options...")
options_menu_item.connect('activate', self._on_options_item_activate)
menu.append(options_menu_item)
alarm_menu_item = Gtk.MenuItem("Alarms...")
alarm_menu_item.connect('activate', self._on_alarm_item_activate)
menu.append(alarm_menu_item)
quit_menu_item = Gtk.MenuItem("Quit")
quit_menu_item.connect('activate', Gtk.main_quit)
menu.append(quit_menu_item)
menu.show_all()
return menu
def __init__(self, datadir):
Gtk.Window.__init__(self)
self.icons = stock.EditorIconFactory(self, datadir)
self.connect('destroy', lambda w: Gtk.main_quit())
self.g_help_window = None
# toplevel_vbox:
# -menubar
# -toolbar
# -notebook
# -statusbar
self.toplevel_vbox = Gtk.VBox()
self.add(self.toplevel_vbox)
self.create_menu_and_toolbar()
self.g_notebook = Gtk.Notebook()
self.toplevel_vbox.pack_start(self.g_notebook, True, True, 0)
self.vbox = Gtk.VBox()
self.toplevel_vbox.pack_start(self.vbox, True, True, 0)
self.create_mainwin_ui()
self.show_all()
def quit_program(self, *w):
can_quit = True
for dlg in gu.EditorDialogBase.instance_dict.values():
if dlg.close_window():
dlg.destroy()
else:
can_quit = False
break
if can_quit:
solfege.app.quit_program()
Gtk.main_quit()
else:
return True
def main():
win = Gtk.Window()
win.connect('destroy', Gtk.main_quit)
win.set_default_size(Width, Height)
global drawingarea
drawingarea = Gtk.DrawingArea()
drawingarea.connect('draw', draw)
drawing_event_box = Gtk.EventBox()
drawing_event_box.add(drawingarea)
drawing_event_box.connect('button-press-event', mouse_pressed)
drawing_event_box.connect('motion-notify-event', mouse_dragged)
check_useIk = Gtk.CheckButton("Lock Forearm & Hand")
check_useIk.set_active(True)
check_useIk.connect("toggled", check_toggled)
box = Gtk.VBox()
box.pack_start(check_useIk, False, True, 0)
box.pack_start(drawing_event_box, True, True, 0)
win.add(box)
win.show_all()
Gtk.main()
def quit(self, widget, event=None, data=None):
'''Main quit.
@param widget: who sent the signal.
@param event: the event that happened
@param data: optional data to receive.
'''
msg = ("Do you really want to quit?")
dlg = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, msg)
dlg.set_default_response(Gtk.ResponseType.YES)
opt = dlg.run()
dlg.destroy()
if opt != Gtk.ResponseType.YES:
return True
Gtk.main_quit()
if self.dasm_process:
self.dasm_process.terminate()
return True
def __init__(self):
window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
window.set_title("Audio-Player")
window.set_default_size(300, -1)
window.connect("destroy", Gtk.main_quit, "WM destroy")
vbox = Gtk.VBox()
window.add(vbox)
self.entry = Gtk.Entry()
vbox.pack_start(self.entry, False, True, 0)
self.button = Gtk.Button("Start")
self.button.connect("clicked", self.start_stop)
vbox.add(self.button)
window.show_all()
self.player = Gst.ElementFactory.make("playbin", "player")
fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
self.player.set_property("video-sink", fakesink)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.connect("message", self.on_message)
def __init__(self):
Gtk.Window.__init__(self,title="Ghetto OMR")
self.set_resizable(True)
self.connect("configure-event",self.new_dim)
self.connect("delete-event",Gtk.main_quit)
self.win_width = 200
self.win_height = 200
something = Gtk.Label("SOMETHING")
self.maximize()
self.count =0
self.main = MainGrid(self)
self.add(self.main)
#
# self.main.destroy()
# self.main = Gtk.Label("SOMETHING")
# self.add(self.main)
def make_menu(self, event_button, event_time):
menu = gtk.Menu()
# show about dialog
about = gtk.MenuItem("About")
about.show()
menu.append(about)
about.connect('activate', self.show_about_dialog)
# add quit item
quit = gtk.MenuItem("Quit")
quit.show()
menu.append(quit)
quit.connect('activate', gtk.main_quit)
menu.popup(None, None, None, None, event_button, event_time)
GUI.py 文件源码
项目:Simple-User-Input-Sculpture-Generation
作者: ClaireKincaid
项目源码
文件源码
阅读 32
收藏 0
点赞 0
评论 0
def __init__(self):
Gtk.Window.__init__(self, title = "Choose a method of Sculpture Generation")
self.set_border_width(10)
self.set_default_size(400, 50)
#initiates Gtk box window
self.box = Gtk.Box(spacing = 6)
self.add(self.box)
#Initializes Vector Animation Button, places in box
self.VectorButton = Gtk.Button(label = "Vector Animation")
self.VectorButton.connect("clicked", self.on_VectorButton_clicked)
self.VectorButton.connect("clicked", Gtk.main_quit)
self.box.pack_start(self.VectorButton, True, True, 0)
#Initializes Perlin Noise Button, places in box
self.PerlinButton = Gtk.Button(label = "Perlin Noise")
self.PerlinButton.connect("clicked", self.on_PerlinButton_clicked)
self.PerlinButton.connect("clicked", Gtk.main_quit)
self.box.pack_start(self.PerlinButton, True, True, 0)
#when VectorButton clicked, toggles to new GUI
def __init__(self, tracker, url, tab_id):
self.alive = True
self.tracker = tracker
self.uuid = tab_id
self.plug = Gtk.Plug()
self.plug.connect("destroy", Gtk.main_quit)
self.webview = WebKit.WebView()
settings = self.webview.get_settings()
settings.set_property("enable-developer-extras", True)
#settings.set_property("enable-webgl", True)
self.webview.connect("load-started", self.load_start_event)
self.webview.connect("notify::title", self.push_title_change)
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.add(self.webview)
self.plug.set_default_size(800, 600)
self.plug.add(scrolled_window)
self.plug.show_all()
self.send("attach_event", plug_id = str(self.plug.get_id()))
self.navigate_event(url)
def watch_process(self, io, condition, process_name):
if condition is GLib.IO_HUP:
os.system('rm ' + current_dir + '/game/cache')
os.system('mkdir -p ' + current_dir + '/game/cache')
self.config_save()
Gtk.main_quit()
return False
print io.readline().strip('\n')
self.progressbar.pulse()
return True
def cb_button_save(self, button):
config_file = current_dir + '/settings.ini'
config_parser = ConfigParser.ConfigParser()
config_parser.read(config_file)
config_parser.set('Settings', 'exe', self.exe)
config_parser.set('Settings', 'width', self.width)
config_parser.set('Settings', 'height', self.height)
new_config_file = open(config_file, 'w')
config_parser.write(new_config_file)
new_config_file.close()
self.modify_start_file()
self.modify_registry()
Gtk.main_quit()
def cb_button_save(self, button):
config_file = current_dir + '/settings.ini'
config_parser = ConfigParser.ConfigParser()
config_parser.read(config_file)
if not os.path.exists(game_dir + '/Konung2.exe.original'):
os.system('mv ' + game_dir + '/Konung2.exe ' + game_dir + '/Konung2.exe.original')
selected_resolution = self.combobox_resolution.get_active_text()
os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/* ' + game_dir)
config_parser.set('Settings', 'resolution', self.resolution)
new_config_file = open(config_file, 'w')
config_parser.write(new_config_file)
new_config_file.close()
Gtk.main_quit()
def cb_button_save(self, button):
if not os.path.exists(game_dir + '/Nosferatu.exe.original'):
os.system('mv ' + game_dir + '/Nosferatu.exe ' + game_dir + '/Nosferatu.exe.original')
selected_resolution = self.combobox_resolution.get_active_text()
os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/Nosferatu.exe ' + game_dir)
config_file = current_dir + '/settings.ini'
config_parser = ConfigParser.ConfigParser()
config_parser.read(config_file)
config_parser.set('Settings', 'resolution', self.resolution)
new_config_file = open(config_file, 'w')
config_parser.write(new_config_file)
new_config_file.close()
Gtk.main_quit()
def cb_button_save(self, button):
if (self.custom_width == '') or (self.custom_height == ''):
message_dialog = Gtk.MessageDialog(
self.main_window,
0,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
_("Error")
)
message_dialog.format_secondary_text(_("You have to set width and height."))
content_area = message_dialog.get_content_area()
content_area.set_property('margin-left', 10)
content_area.set_property('margin-right', 10)
content_area.set_property('margin-top', 10)
content_area.set_property('margin-bottom', 10)
message_dialog.run()
message_dialog.destroy()
return
self.config_save()
Gtk.main_quit()
def cb_button_save(self, button):
if not os.path.exists(game_dir + '/Game/game.exe.original'):
os.system('mv ' + game_dir + '/Game/game.exe ' + game_dir + '/Game/game.exe.original')
selected_resolution = self.combobox_resolution.get_active_text()
os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/game.exe ' +
game_dir + '/Game')
config_file = current_dir + '/settings.ini'
config_parser = ConfigParser.ConfigParser()
config_parser.read(config_file)
config_parser.set('Settings', 'resolution', self.resolution)
new_config_file = open(config_file, 'w')
config_parser.write(new_config_file)
new_config_file.close()
Gtk.main_quit()
def cb_button_save(self, button):
if (self.custom_width == '') or (self.custom_height == ''):
message_dialog = Gtk.MessageDialog(
self.main_window,
0,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
_("Error")
)
message_dialog.format_secondary_text(_("You have to set width and height."))
content_area = message_dialog.get_content_area()
content_area.set_property('margin-left', 10)
content_area.set_property('margin-right', 10)
content_area.set_property('margin-top', 10)
content_area.set_property('margin-bottom', 10)
message_dialog.run()
message_dialog.destroy()
return
self.config_save()
Gtk.main_quit()
def cb_button_save(self, button):
config_file = current_dir + '/settings.ini'
config_parser = ConfigParser.ConfigParser()
config_parser.read(config_file)
if is_english_version:
self.modify_start_file()
config_parser.set('Settings', 'exe', self.exe)
else:
if not os.path.exists(game_dir + '/konung.exe.original'):
os.system('mv ' + game_dir + '/konung.exe ' + game_dir + '/konung.exe.original')
selected_resolution = self.combobox_resolution.get_active_text()
os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/* ' + game_dir)
config_parser.set('Settings', 'resolution', self.resolution)
new_config_file = open(config_file, 'w')
config_parser.write(new_config_file)
new_config_file.close()
Gtk.main_quit()
def cb_button_save(self, button):
if (self.custom_width == '') or (self.custom_height == ''):
message_dialog = Gtk.MessageDialog(
self.main_window,
0,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
_("Error")
)
message_dialog.format_secondary_text(_("You have to set width and height."))
content_area = message_dialog.get_content_area()
content_area.set_property('margin-left', 10)
content_area.set_property('margin-right', 10)
content_area.set_property('margin-top', 10)
content_area.set_property('margin-bottom', 10)
message_dialog.run()
message_dialog.destroy()
return
self.config_save()
Gtk.main_quit()
def on_delete_window(*args):
Gtk.main_quit(*args)
def quit_app(self, window, event):
self.config_save()
Gtk.main_quit()
def quit_app(self, window, event):
self.config_save()
Gtk.main_quit()
def quit_app(self, window, event):
Gtk.main_quit()
def cb_button_save(self, button):
self.dosbox_config_save()
Gtk.main_quit()
def quit_app(self, window, event):
self.config_save()
Gtk.main_quit()
def watch_process(self, io, condition, process_name):
if condition is GLib.IO_HUP:
self.progressbar.pulse()
self.n_files_to_copy -= 1
if self.n_files_to_copy == 0:
message_dialog = Gtk.MessageDialog(
self.main_window,
0,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
_("Done!"),
width_request = 360
)
content_area = message_dialog.get_content_area()
content_area.set_property('margin-left', 10)
content_area.set_property('margin-right', 10)
content_area.set_property('margin-top', 10)
content_area.set_property('margin-bottom', 10)
action_area = message_dialog.get_action_area()
action_area.set_property('spacing', 10)
self.main_window.hide()
message_dialog.run()
message_dialog.destroy()
Gtk.main_quit()
return False
while Gtk.events_pending():
Gtk.main_iteration_do(False)
return True
def quit_app(self, window, event):
self.config_save()
Gtk.main_quit()