class App(QApplication): """ App class - derived from QApplication INPUTS: None, does not take cmd args. OUTPUTS: Creates an instance of the MainWindow and shows it. Notes: A single instance of the App class is created by the main function when the program begins execution. """ def __init__(self): """Initialize the application Input: None Output: Sets application name and creates the main window. """ # Initialize the parent widget super().__init__([]) # Set the application name self.setApplicationName("Facial Recognition App") # Create the main window self.mainWindow = MainWindow() # Show the main window # Note: show() is non-blocking, exec() is blocking self.mainWindow.show()
def __init__(self): self.app = QSingleApplication("BlobBackup", sys.argv) self.app.setQuitOnLastWindowClosed(False) self.app.setStyle("Fusion") self.window = MainWindow(self) self.scheduler = Scheduler(self.app) self.show_minimize_message = not Settings.get_param("minimize") self.app.start_backup.connect(self.window.go_backup) if self.app.isRunning(): QMessageBox.warning( None, "BlobBackup already running", "An instance of BlobBackup is already running. Check your status bar." ) sys.exit() menu = QMenu() window_action = menu.addAction("BlobBackup") window_action.triggered.connect(self.show_window) quit_action = menu.addAction("Exit") quit_action.triggered.connect(self.quit_action) self.tray = QSystemTrayIcon() self.tray.setIcon(QIcon(get_resource_path("images/logo.ico"))) self.tray.setContextMenu(menu) self.tray.show() self.tray.setToolTip("BlobBackup") self.tray.activated.connect(self.tray_activated) self.show_window()
def run(): app = QApplication(sys.argv) window = MainWindow() window.show() app.exec_()
def main(): """ The main function, runs when the script is called from the command line """ # Handler for the event loop application = QApplication([]) # Makes an instance of the MainWindow class mainWindow = MainWindow() # Calls MainWindow method .show() mainWindow.show() # A process for handling the web method, it is an infinite loop so needs to be handled # in a seperate process webProcess = QProcess() # 127.0.0.1:5000 the current host webProcess.start("python3 WebRun.py") # .exec begins the while loop for the event loop, does not exit until receives # user input application.exec() webProcess.terminate() webProcess.waitForFinished() exit()
def main(): app = QtWidgets.QApplication(sys.argv) view = MainWindow() model = Repository() presenter = Presenter(view, model) view.show() sys.exit(app.exec_())
class CDATGUIApp(QtGui.QApplication): def __init__(self): super(CDATGUIApp, self).__init__(sys.argv) self.setApplicationName("CDAT GUI") self.setApplicationVersion(info.version) self.setWindowIcon(icon(info.icon)) self.win = None self.splash = LoadingSplash() self.splash.show() self.splash.raise_() self.splash.activateWindow() self.preloadModules() def preloadModules(self): self.splash.showMessage("Loading VCS") import vcs x = vcs.init() x.close() x = None self.splash.showMessage("Loading CDMS2") import cdms2 self.ready() def ready(self): self.win = MainWindow() self.splash.finish(self.win) self.win.show()
def main(): """This starts up the oricreate application. """ global oricreate # Make sure '.' is in sys.path if '' not in sys.path: sys.path.insert(0, '') # Start the app. from traits.etsconfig.api import ETSConfig # Check that we have a traits backend installed from traitsui.toolkit import toolkit toolkit() # This forces the selection of a toolkit. if ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits ________________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Oricreate with easy_install, try easy_install <pkg_name>. easy_install Oricreate[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''' ) from main_window import MainWindow oricreate = MainWindow() oricreate.configure_traits()
class App(QApplication): def __init__(self, sys_argv): super(App, self).__init__(sys_argv) self.model = Model() self.logic = Logic(self.model) self.mainWindow = MainWindow(self.model, self.logic) self.mainWindow.show()
class Application(BaseApplication): def __init__(self) -> None: super().__init__() self.init_app_info() # self.setQuitOnLastWindowClosed(False) # icon = QIcon(qta.icon('fa.circle','fa5s.video', options=[{'color':'gray'}, {'scale_factor':0.5, 'color':'white'}])) # self.setWindowIcon(icon) self.device_manager = DeviceManager(self) # create window self.window = MainWindow() self.window.show() def closeEvent(self, event): self.device_manager.close() return super().closeEvent(event) def init_app_info(self): self.setOrganizationName("DaelonCo") self.setOrganizationDomain("DaelonCo") self.setApplicationName("CodexTester") self.setApplicationVersion("v0.1")
def on_error( self , msg ) : """Show an error message box.""" msg = "<html> {}".format( msg ) \ + " <p>Check <a href='https://github.com/pacman-ghost/aslcards/#faq'>here</a> if you're having trouble analyzing your files." \ + " </html>" msg = msg.replace( "\n" , "<br>\n" ) MainWindow.show_error_msg( msg )
def main(): app = QtWidgets.QApplication(sys.argv) settings = Settings() main_window = MainWindow(settings) main_window.show() sys.exit(app.exec_())
def main(): urls = [] debug = False if len(sys.argv) > 1: ## If they want help if sys.argv[1] == "-h" or sys.argv[1] == "--help": print_help() return (0) elif sys.argv[1] == "-V" or sys.argv[1] == "--version": print_version() return (0) ## If they're reading URLs from stdin elif sys.argv[1] == '-' or sys.argv[1] == "--stdin": rawUrls = sys.stdin.readlines() for r in rawUrls: urls.append(r.replace(' ', '\n', -1).strip()) ## If they're trying to use debug mode elif sys.argv[1] == "-d" or sys.argv[1] == "--debug": debug = True ## If they're importing URLs elif os.path.exists(sys.argv[1]): try: fin = open(sys.argv[1], "r") rawUrls = fin.readlines() fin.close() for r in rawUrls: urls.append(r.strip()) except (OSError, PermissionError, FileNotFoundError): print("ERROR: Cannot read from '%s'! Aborting." % sys.argv[1]) sys.exit(1) ## Running a bunch of URLs as args else: for arg in sys.argv[1:]: urls.append(arg) app = QApplication(sys.argv) sysInstall = (os.path.expanduser('~') in sys.argv[0]) app.setWindowIcon(Icons().get_icon("application-icon", sysInstall)) win = MainWindow(debug) if debug: print("(Debug mode)") if len(urls) > 0: win.load_urls(urls) sys.exit(app.exec_())
def main(): # Load translator. translator = qt4.QTranslator() translator.load('i18n/ru_RU') # Create Qt application. app = qt4.QApplication(sys.argv) # Close application when all windows closed. app.lastWindowClosed.connect(app.quit) # Handle exceptions in Qt threads. sys.excepthook = excepthook # Register a signal handler to catch ctrl+C # TODO: Don't work signal.signal(signal.SIGINT, handle_int_signal) # Apply translator. app.installTranslator(translator) # Create main window. main_window = MainWindow() main_window.show() # Main loop. sys.exit(app.exec_())
def init_controller(self): self._view = MainWindow() self._view.setMouseTracking(True) self.load() self._view.next_button.clicked.connect(self.next_button_pressed) if len(self.pictures) > 0: self._view.set_picture(self.pictures[self.index])
def main(argv=None): logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('Main:Start Application') app = QApplication(sys.argv) mainWindow = MainWindow() mainWindow.show() sys.exit(app.exec_())
def main(): pyqt = os.path.dirname(PyQt5.__file__) os.environ['QT_PLUGIN_PATH'] = os.path.join(pyqt, "Qt/plugins") app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() app.exec_()
def main(): app = QApplication([]) model = Model() main = MainWindow(model) main.show() app.exec_()
def main(): app = QApplication(sys.argv) app.setWindowIcon(QIcon(':/icon/sina.ico')) main_window = MainWindow() main_window.show() sys.exit(app.exec_())
class App: def __init__(self): self.app = QApplication([]) self.window = MainWindow() def run(self): self.window.show() self.app.exec_()
def __init__(self): QWidget.__init__(self) IDEGeneric.__init__(self) self.setWindowTitle('NINJA-IDE {Ninja Is Not Just Another IDE}') self.setWindowIcon(QIcon(resources.images['icon'])) self.setWindowState(Qt.WindowMaximized) self.setMinimumSize(700, 500) #Opactity self.opacity = 1 #ToolBar self._toolbar = QToolBar() self._toolbar.setToolTip('Press and Drag to Move') styles.set_style(self._toolbar, 'toolbar-default') self.addToolBar(Qt.LeftToolBarArea, self._toolbar) self._toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) #StatusBar self._status = StatusBar() self._status.hide() self.setStatusBar(self._status) #Main Widgets self.main = MainWindow(self) self.setCentralWidget(self.main) #Menu menubar = self.menuBar() styles.apply(menubar, 'menu') file_ = menubar.addMenu('&File') edit = menubar.addMenu('&Edit') view = menubar.addMenu('&View') project = menubar.addMenu('&Project') self.pluginsMenu = menubar.addMenu('P&lugins') about = menubar.addMenu('&About') #The order of the icons in the toolbar is defined by this calls self._menuFile = MenuFile(file_, self._toolbar, self.main) self._menuView = MenuView(view, self, self.main) self._menuEdit = MenuEdit(edit, self._toolbar, self.main, self._status) self._menuProject = MenuProject(project, self._toolbar, self.main) self._menuPlugins = MenuPlugins(self.pluginsMenu, self) self._menuAbout = MenuAbout(about, self.main) self.main.container.load_toolbar(self._toolbar) self.main._central.actual_tab().obtain_editor().setFocus() filenames, projects_path = core.cliparser.parse() for filename in filenames: self.main.open_document(filename) for project_path in projects_path: self.main.open_project_folder(project_path) self.connect(self.main, SIGNAL("fileSaved(QString)"), self.show_status_message)
def main(): app = QApplication([]) vkRequestProcessor = VkRequestProcessor() model = Model(vkRequestProcessor) main = MainWindow(model) main.show() app.exec_()
def check_login_func(self): if self.USER_PWD.get(self.user_line.text()) == self.pwd_line.text(): QMessageBox.information(self, '通知', '成功登录!') self.close() self.MainWindow = MainWindow(self.user_line.text()) self.MainWindow.show() else: QMessageBox.critical(self, '通知', '用户名或密码错误!') self.pwd_line.clear()
def main(): #Setup QtApp app = QtGui.QApplication(sys.argv[0]) ui_mainwindow = Ui_MainWindow() main_window = MainWindow(app, ui_mainwindow, viz_config) main_window.show() sys.exit(app.exec_())
def __init__(self, parent): """Creates the main window""" tk.Frame.__init__(self, parent) self._root_win = tk.Toplevel() self._main_window = MainWindow(self._root_win, self) self._vlc_instance = vlc.Instance() self._player = self._vlc_instance.media_player_new() self.list_songs_callback() self.queue_titles = []
def OnInit(self): self.frame = MainWindow(parent=None, title='GeoSniff') self.frame.Maximize() self.frame.Show() self.SetTopWindow(self.frame) self.database = Database() self.points = collections.OrderedDict() pub.subscribe(self.__onClearData, 'ClearData') return True
def __init__(self): super().__init__() self._view = MainWindow() self._expenseForm = None self.db = MyDatabase('expenses.db') self._models = Models(self.db) self._view.initializeView(self._models) self.connectSignals()
def run(): # Create the Qt Application app = BaseApplication() # create window window = MainWindow() window.show() # Run the main Qt loop app.exec_()
def __init__(self): self.app = QApplication(sys.argv) self.stages = stages self.current_stage = 0 self.history = [] self.image_file = None self.window = MainWindow(self.stages) self.window.show() self.set_handlers()
def __init__(self): self.client_list = [] self.trashed_clients = [] self.favorite_list = [] self.name = '' self.path = '' self.notes = '' self.is_running = False self.server_status = ray.ServerStatus.OFF self.is_renameable = True self._signaler = Signaler() server = GUIServerThread.instance() server.start() self._daemon_manager = DaemonManager(self) if CommandLineArgs.daemon_url: self._daemon_manager.setOscAddress(CommandLineArgs.daemon_url) elif CommandLineArgs.daemon_port: self._daemon_manager.setOscAddress(CommandLineArgs.daemon_port) elif not CommandLineArgs.out_daemon: self._daemon_manager.setNewOscAddress() # build nsm_child if NSM_URL in env self._nsm_child = None if CommandLineArgs.under_nsm: if CommandLineArgs.out_daemon: self._nsm_child = NSMChildOutside(self) self._daemon_manager.setExternal() else: self._nsm_child = NSMChild(self) # build and show Main UI self._main_win = MainWindow(self) self._daemon_manager.finishInit() server.finishInit(self) self._main_win.show() # display donations dialog under conditions if not RS.settings.value('hide_donations', False, type=bool): coreff_counter = RS.settings.value('coreff_counter', 0, type=int) coreff_counter += 1 RS.settings.setValue('coreff_counter', coreff_counter) if coreff_counter % 44 == 29: self._main_win.donate(True) # The only way I found to not show Messages Dock by default. if not RS.settings.value('MainWindow/ShowMessages', False, type=bool): self._main_win.hideMessagesDock()
class KvitterApp: def __init__(self): self.username_str = "username" self.password_str = "password" self.api = twitter.Api(username=self.username_str, password=self.password_str, input_encoding=None) self.main_window = MainWindow() def run(self): self.main_window.show(self.api, self.username_str) pass
def main(argv): # Create a Qt application app = QApplication(argv) app.setStyle('macintosh') window = MainWindow() window.show() # Enter Qt application main loop app.exec_() sys.exit()
def main(): app, client = create_nucentral_application( name="example", resource="example.rcc", locale=":/locale/example", ) from main_window import MainWindow window = MainWindow(client) window.show() return app.exec_()
def init_screen(self): try: del self.main_window except AttributeError: pass self.main_window = MainWindow(self, self.app, self.config, self.img_toolkit) self.main_window.setWindowIcon(self.chz_ico) self.main_window.show() self.main_window.activateWindow() self.main_window.raise_()
def do_activate(self): # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = MainWindow(application=self, title="Monitoring") self.window.present() self.thread_data.start() self.thread_values.start() self.thread_graph.start()
def __init__(self): QtCore.QCoreApplication.setApplicationName("PSSOptimisation") QtCore.QCoreApplication.setApplicationVersion(str(VERSION)) QtCore.QCoreApplication.setOrganizationName("Hubert Grzeskowiak") self.settings = QtCore.QSettings() self.main_window = MainWindow(True) self.grades_model = GradesModel(self.main_window) self.proxy_model = GradesModelProxy() self.proxy_model.setSourceModel(self.grades_model) self.initUI()
def begin_game(self, game: GoFish): # Create the main window if self._main_window is None: print("here") self._main_window = MainWindow(self._exit_function, self._ask_function, self._save_function, self._open_function, self._new_game, self._hand_to_json_function) print(game) self._main_window.configure_ui(game) # show the new window and hide the old self._main_window.show() self._setup_window.hide()
def __init__(self): self.current_game = None self.main_window = MainWindow() main_sweeper = MainSweeper(self) main_russia = MainRussiaBox(self) main_sudoku = MainSudoku(self) self.games = [['sweeper', main_sweeper], ['RussiaBox', main_russia], ['sudoku', main_sudoku]] self.set_game(2) color = (200, 200, 200) self.exit_button = Button(text="exit", background_color=color) self.sweep_button = ChoiceGameButton(mainwindow=self, width=80, text=self.games[0][0], value=0) self.russiabox_button = ChoiceGameButton(mainwindow=self, width=100, x=82, text=self.games[1][0], value=1) self.sudoku_button = ChoiceGameButton(mainwindow=self, width=100, x=182, text=self.games[2][0], value=2) self.main_window.register_mouse_down(self.russiabox_button) self.main_window.register_mouse_down(self.sweep_button) self.main_window.register_mouse_down(self.sudoku_button) self.main_window.add_top(self.exit_button) self.exit_button.set_right() self.main_window.add_top(self.sweep_button) self.main_window.add_top(self.russiabox_button) self.main_window.add_top(self.sudoku_button) # genereate gif self.gif_button = Button(x=20, y=20, width=50, height=20, background_color=color, text='GIF') self.gif_button.main_window = self self.gif_button.response_mouse_down = MethodType( gif_button_mouse_down, self.gif_button) self.main_window.register_mouse_down(self.gif_button) # self.add(self.gif_button) self.main_window.get_right().add(self.gif_button) self.main_window.register_sys_exit(self) self.main_window.show_window()
def openMainWindow(self, userID): if self.login != None: self.login.close() self.user = Landlord(userID, self.DBconnection) # create landlord in mw self.mw = MainWindow(self.user, self.DBconnection) #slots self.mw.signOut.triggered.connect(self.logOut) #logout when "sign out" is clicked in mw's menu bar self.mw.openInBrowser.triggered.connect(self.openSite) self.mw.mainWidget.propertiesWidget.closeOut.clicked.connect(self.mw.close) self.mw.mainWidget.propertiesWidget.goToSite.clicked.connect(self.openSite) self.mw.show()
def __init__(self): # build UI from glade file builder = Gtk.Builder() #builder.add_from_file(to_abs_path(PoResources.UI_TRAY)) builder.add_from_file(to_abs_path(PoResources.UI_TRAY)) builder.connect_signals(self) style.setStyle() # get some common used object self.builder = builder self.menu = builder.get_object('tray_menu') self.lb_clock = builder.get_object('mni_clock') self.lb_counter = builder.get_object('mni_archive_count') APPIND_SUPPORT = 1 try: from gi.repository import AppIndicator3 except: APPIND_SUPPORT = 0 if APPIND_SUPPORT == 1: self.ind = AppIndicator3.Indicator.new_with_path("domor-indicator", 'app_icon_64', AppIndicator3.IndicatorCategory.APPLICATION_STATUS, to_abs_path('img')) self.ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE) self.ind.set_menu(self.menu) else: self.myStatusIcon = Gtk.StatusIcon() self.myStatusIcon.set_from_file( to_abs_path(PoResources.ICON_APP_64)) self.myStatusIcon.connect( 'popup-menu', self.right_click_event_statusicon) # 6 load config self.settings = settings = Settings() settings.load_config() # 7 init class state self.btn_state = State.STOP self.state = State.IDLE self.time = settings.short_work_time self.work_time = 0 self.count = 0 # create main screen self.main_window = MainWindow(self.on_mni_start_activate) self.main_window.update(self.state, self.btn_state) # create rest screen self.break_screen = BreakScreen(self.on_skip_break) self.reset() # register timer callback GObject.timeout_add_seconds(1, self.count_down)
def main(): app = QtGui.QApplication(sys.argv) # deliver_widget = DeliverWindow() # sale_widget = SaleWindow() mw = MainWindow() # mw.windows.append(deliver_widget) # mw.windows.append(sale_widget) mapper = QSignalMapper() QObject.connect(mw.ui.deliver_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.sale_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_drugs_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_delivers_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_sales_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_patients_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_distributors_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_medorg_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_doctors_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_manufacters_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_ills_action, SIGNAL("activated()"), mapper,SLOT("map()")) QObject.connect(mw.ui.all_recipes_action, SIGNAL("activated()"), mapper,SLOT("map()")) mapper.setMapping(mw.ui.deliver_action, 0) mapper.setMapping(mw.ui.sale_action, 1) mapper.setMapping(mw.ui.all_drugs_action, 2) mapper.setMapping(mw.ui.all_delivers_action, 3) mapper.setMapping(mw.ui.all_sales_action, 4) mapper.setMapping(mw.ui.all_patients_action, 5) mapper.setMapping(mw.ui.all_distributors_action, 6) mapper.setMapping(mw.ui.all_medorg_action, 7) mapper.setMapping(mw.ui.all_doctors_action, 8) mapper.setMapping(mw.ui.all_manufacters_action, 9) mapper.setMapping(mw.ui.all_ills_action, 10) mapper.setMapping(mw.ui.all_recipes_action, 11) QObject.connect(mapper,SIGNAL("mapped(int)"), mw,SLOT("show_child_window(int)")) mw.showMaximized() os.popen('soffice -invisible "-accept=socket,host=localhost,port=2002;urp;"') sys.exit(app.exec_())
def __init__( self ): self.window = MainWindow( self ) path_input = os.path.dirname(__file__) + "\\relatorios_rpt" path_output = os.path.dirname(__file__) + "\\saida_excel" if os.path.isdir(path_input): self.window.set_input_folder(path_input) if os.path.isdir(path_output): self.window.set_output_folder(path_output)
class IDE(QMainWindow): def __init__(self): QWidget.__init__(self) self.setWindowTitle('pyIDEal') self.setWindowState(Qt.WindowMaximized) #Main Widgets self.main = MainWindow(self) self.setCentralWidget(self.main) #Menu menubar = self.menuBar() file = menubar.addMenu('&File') edit = menubar.addMenu('&Edit') self._toolbar = self.addToolBar("toolbar") self._toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) self._menuFile = MenuFile(file, self._toolbar, self.main) self._menuEdit = MenuEdit(edit, self._toolbar, self.main) self.main.obtain_editor().setFocus()
def do_activate(self): GObject.threads_init() gettext.install('easy-ebook-viewer', '/usr/share/easy-ebook-viewer/locale') # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = MainWindow(file_path=self.file_path) self.window.connect("delete-event", self.on_quit) self.window.set_wmclass("easy-ebook-viewer", "easy-ebook-viewer") self.window.show_all() if not self.window.book_loaded: self.window.header_bar_component.hide_jumping_navigation() Gtk.main()
class Application(Gtk.Application): def __init__(self, *args, **kwargs): super().__init__(*args, application_id="easy-ebook-viewer", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE, **kwargs) self.window = None self.file_path = None GLib.set_application_name('Easy eBook Viewer') GLib.set_prgname('easy-ebook-viewer') GLib.setenv('PULSE_PROP_application.icon_name', 'easy-ebook-viewer', True) def do_startup(self): Gtk.Application.do_startup(self) action = Gio.SimpleAction.new("about", None) action.connect("activate", self.on_about) self.add_action(action) action = Gio.SimpleAction.new("quit", None) action.connect("activate", self.on_quit) self.add_action(action) def do_activate(self): GObject.threads_init() gettext.install('easy-ebook-viewer', '/usr/share/easy-ebook-viewer/locale') # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = MainWindow(file_path=self.file_path) self.window.connect("delete-event", self.on_quit) self.window.set_wmclass("easy-ebook-viewer", "easy-ebook-viewer") self.window.show_all() if not self.window.book_loaded: self.window.header_bar_component.hide_jumping_navigation() Gtk.main() def do_command_line(self, command_line): # If book came from arguments ie. was oppened using "Open with..." method etc. if len(sys.argv) > 1: # Check if that file really exists if os.path.exists(sys.argv[1]): self.file_path = sys.argv[1] self.activate() return 0 def on_about(self, action, param): dialog = about_dialog.AboutDialog() dialog.show_all() def on_quit(self, action, param): Gdk.threads_leave() Gtk.main_quit() self.quit()
def __init__(self): appdata = str(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) MusicGuruBase.__init__(self, appdata) ApplicationBase.__init__(self) if not op.exists(appdata): os.makedirs(appdata) logging.basicConfig(filename=op.join(appdata, 'debug.log'), level=logging.WARNING) self.prefs = Preferences() self.prefs.load() self.selectedBoardItems = [] self.selectedLocation = None self.mainWindow = MainWindow(app=self) self.locationsPanel = LocationsPanel(app=self) self.detailsPanel = DetailsPanel(app=self) self.ignoreBox = IgnoreBox(app=self) self.progress = Progress(self.mainWindow) self.aboutBox = AboutBox(self.mainWindow, self) self.connect(self.progress, SIGNAL('finished(QString)'), self.jobFinished) self.connect(self, SIGNAL('applicationFinishedLaunching()'), self.applicationFinishedLaunching)
class MainPresenter: def __init__( self ): self.window = MainWindow( self ) path_input = os.path.dirname(__file__) + "\\relatorios_rpt" path_output = os.path.dirname(__file__) + "\\saida_excel" if os.path.isdir(path_input): self.window.set_input_folder(path_input) if os.path.isdir(path_output): self.window.set_output_folder(path_output) def ok_clicked( self ): reports_folder = self.window.get_input_folder() output_folder = self.window.get_output_folder() for file in os.listdir(reports_folder): if file.endswith(".RPT"): ReportProcessor().process_report( output_folder, reports_folder, file ) self.window.show_message( "Processo concluído." )
def main(argv): # load plugins if os.path.exists(PLUGIN_FILE): imp.load_source('hmtk.plugin', PLUGIN_FILE) # create Qt application # Claim to be QGIS2 so that used plugins that tries to access # QSettings will get the QGIS2 settings QtGui.QApplication.setApplicationName('QGIS2') QtGui.QApplication.setOrganizationDomain('qgis.org') if QtCore.QSettings().value('locale/userLocale') is None: QtGui.QApplication.setOrganizationDomain('QGIS') app = QtGui.QApplication(argv, True) # setup QGIS QgsApplication.setPrefixPath(os.environ['QGIS_PREFIX_PATH'], True) QgsApplication.initQgis() # Install a custom exception hook that prints exception into a # MessageBox sys.excepthook = excepthook # create main window wnd = MainWindow() # classname wnd.show() if sys.platform == "darwin": wnd.raise_() if len(argv) > 1: wnd.change_model(CatalogueModel.from_csv_file(argv[1])) if len(argv) > 2: wnd.load_fault_source(argv[2]) else: wnd.load_catalogue() # Connect signal for app finish def on_quit(): QgsApplication.exitQgis() app.quit() app.lastWindowClosed.connect(on_quit) # Start the app up ret = app.exec_() sys.exit(ret)
def main(): app = QtGui.QApplication(sys.argv) widget = MainWindow() widget.show() widget.raise_() sys.exit(app.exec_())
#!/usr/bin/env python from PyQt4.QtCore import * from PyQt4.QtGui import * from main_window import MainWindow import sys from config import * import logging if __name__ == '__main__': logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('Main:Start Application') app = QApplication(sys.argv) mainWindow = MainWindow() mainWindow.show() sys.exit(app.exec_())
# coding: utf8 import sys import matplotlib matplotlib.use("Qt5Agg", force=True) from PyQt5.QtWidgets import QApplication from main_window import MainWindow import matplotlib.pyplot as plt app = QApplication(sys.argv) app.setApplicationName('CSM_3') # -----------------------------------------------------# form = MainWindow() form.setWindowTitle('Лабораторная работа №3') form.show() # -----------------------------------------------------# sys.exit(app.exec_())
def main(): window = MainWindow() window.main()
class PSSOptimisation(object): def __init__(self): QtCore.QCoreApplication.setApplicationName("PSSOptimisation") QtCore.QCoreApplication.setApplicationVersion(str(VERSION)) QtCore.QCoreApplication.setOrganizationName("Hubert Grzeskowiak") self.settings = QtCore.QSettings() self.main_window = MainWindow(True) self.grades_model = GradesModel(self.main_window) self.proxy_model = GradesModelProxy() self.proxy_model.setSourceModel(self.grades_model) self.initUI() # tray = QtGui.QSystemTrayIcon(self.main_window) # tray.setIcon(QtGui.QIcon("icons/Accessories-calculator.svg")) # tray.connect(tray, # SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), # self.trayClicked) # tray.show() # self.tray = tray # def trayClicked(self, reason): # print reason # if reason == QtGui.QSystemTrayIcon.DoubleClick: # self.main_window.setVisible(not self.main_window.isVisible()) def initUI(self): self.connectUI() self.main_window.show() def __columnsChanged(self): """This should be called whenever the columns filter is changed. It's a workaround for a bug in the headerview not updating the columns properly on filter change. """ header = self.main_window.grades_table.horizontalHeader() header.resizeSections(QtGui.QHeaderView.ResizeToContents) header.resizeSection(0, header.sectionSize(0)-1) header.resizeSection(0, header.sectionSize(0)+1) def connectUI(self): self.main_window.grades_table.setModel(self.proxy_model) delegate = CheckBoxDelegate() self.main_window.grades_table.setItemDelegate(delegate) self.main_window.connect(self.main_window.action_download, SIGNAL("triggered()"), self.openLoginDialog) self.main_window.connect(self.main_window.action_donate, SIGNAL("triggered()"), self.openDonationDialog) self.main_window.connect(self.main_window.action_open, SIGNAL("triggered()"), self.openFileDialog) self.main_window.connect(self.grades_model, SIGNAL("dataChanged()"), self.updateStats) self.main_window.connect(self.grades_model, SIGNAL("dataChanged()"), self.main_window.grades_table.resizeColumnsToContents) self.main_window.connect(self.grades_model, SIGNAL("modelReset()"), self.updateStats) self.main_window.connect(self.grades_model, SIGNAL("modelReset()"), self.main_window.grades_table.resizeColumnsToContents) # workaround for buggy headerview self.main_window.connect(self.proxy_model, SIGNAL("columnsVisibilityChanged()"), self.__columnsChanged) # create actions for toggling table columns header = self.main_window.grades_table.horizontalHeader() self.header_actions = QtGui.QActionGroup(header) self.header_actions.setExclusive(False) for nr, (name, visible) in enumerate(zip( self.grades_model.header_data, self.proxy_model.col_visibility)): action = self.header_actions.addAction(name) action.setCheckable(True) action.setChecked(visible) action.connect(action, SIGNAL("triggered()"), lambda nr=nr: self.proxy_model.toggleColumn(nr)) # add that menu as context menu for the header header.addActions(self.header_actions.actions()) header.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu) # and put it into the main window's menus self.main_window.menu_table_columns.clear() for action in self.header_actions.actions(): self.main_window.menu_table_columns.addAction(action) # automatically download new grades (depends on settings) if self.settings.value("updateOnStart", False).toBool(): QtCore.QTimer.singleShot(200, self.tryAutoDownloadFromPSSO) def openLoginDialog(self): self.login_dialog = LoginDialog(self.main_window) self.login_dialog.exec_() if self.login_dialog.result(): username = str(self.login_dialog.username_line.text()) password = str(self.login_dialog.password_line.text()) if username and password: remember = self.login_dialog.remember_checkbox.isChecked() self.handleLoginData(username, password, remember) def handleLoginData(self, username, password, remember=False): """Try to load the grades by using the provided login credentials. On failure, an error popup is displayed. On success a loading progress bar and after that a table is shown. If "remember" is True, then the login data is saved. """ self.main_window.setDisabled(True) QtGui.QApplication.processEvents() QtGui.QApplication.processEvents() progress = 0 try: iterator = self.grades_model.getFromPSSOIterator(username, password) for step in iterator: self.main_window.showProgress(progress, step) # getFromPSSOIterator defines 8 steps, but 1st is at 0 progress += 100.0/7 QtGui.QApplication.processEvents() except (ConnectionError, ServiceUnavailableError, ParsingError) as e: QtGui.QMessageBox.critical(self.main_window, e.title, e.message) return except LoginError as e: self.clearLoginData(username) QtGui.QMessageBox.critical(self.main_window, e.title, e.message) return finally: self.main_window.setEnabled(True) self.main_window.showProgress(-1) self.main_window.showTable() self.main_window.setEnabled(True) if remember: self.saveLoginData(username, password) def saveLoginData(self, username, password): assert username and password self.settings.setValue("username", username) keyring.set_password("PSSO", username, password) def getLoginData(self): """Try to retrieve previously saved username and password. Returns a tuple of two empty strings on failure. """ username = str(self.settings.value("username").toString() or "") try: password = keyring.get_password("PSSO", username) or "" except IOError: return "", "" return username, password def clearLoginData(self, username=None): """Remove username and password settings. If a username is given, its password will be removed. If there is a saved username, it will also get removed alongside with the corresponding password. """ username2 = str(self.settings.value("username").toString() or "") try: keyring.delete_password("PSSO", username) except: pass try: keyring.delete_password("PSSO", username2) except: pass self.settings.remove("username") def tryAutoDownloadFromPSSO(self): u, p = self.getLoginData() if u and p: self.handleLoginData(u, p) def openFileDialog(self): ofd = OpenFileDialog(self.main_window) accepted = ofd.exec_() if accepted and ofd.html_file: try: html = codecs.open(ofd.html_file, encoding='utf-8') except IOError: QtGui.QMessageBox.warning(self.main_window, "File not found", "Sorry, but there seems to be no file called {}.".format( ofd.html_file)) return self.grades_model.getFromHTML(html) self.main_window.showTable() def openDonationDialog(self): dp = DonationDialog(self.main_window) dp.exec_() def updateStats(self): self.main_window.num_of_grades.setText(str( self.grades_model.getNumOfGrades())) self.main_window.num_of_credits.setText(str( self.grades_model.getNumOfCredits())) self.main_window.average_grade.setText(str( self.grades_model.getAverageGrade()))
lan = 'jp' qt_translation = "qt_"+lan+".qm" jerry_translation = "jerry_"+lan+".qm" #load qt localization qt_translator = QTranslator(app) qt_translator.load(qt_translation,"i18n/qm") app.installTranslator(qt_translator) #load jerry localization translator = QTranslator(app) translator.load(jerry_translation,"i18n/qm/") app.installTranslator(translator) main = MainWindow() def about_to_quit(): main.model.dump() #main.engine_controller.stop_engine() #main.engine_controller.thread.exit() # set app icon app_icon = QIcon() app_icon.addFile('res/icons_taskbar/icon16.png', QSize(16,16)) app_icon.addFile('res/icons_taskbar/icon24.png', QSize(24,24)) app_icon.addFile('res/icons_taskbar/icon32.png', QSize(32,32)) app_icon.addFile('res/icons/taskbar/icon48.png', QSize(48,48)) app_icon.addFile('res/icons_taskbar/icon256.png',QSize(256,256)) app.setWindowIcon(app_icon)
def main(): app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())
#!/usr/bin/python from PyQt4.QtCore import * from PyQt4.QtGui import * import sys app = QApplication(sys.argv) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('UTF-8')) from main_window import MainWindow mainWindow = MainWindow() mainWindow.setGeometry(QRect(100, 100, 400, 400)) mainWindow.show() app.exec_()
class IDE(QMainWindow, IDEGeneric): max_opacity = 1 min_opacity = 0.3 def __init__(self): QWidget.__init__(self) IDEGeneric.__init__(self) self.setWindowTitle('NINJA-IDE {Ninja Is Not Just Another IDE}') self.setWindowIcon(QIcon(resources.images['icon'])) self.setWindowState(Qt.WindowMaximized) self.setMinimumSize(700, 500) #Opactity self.opacity = 1 #ToolBar self._toolbar = QToolBar() self._toolbar.setToolTip('Press and Drag to Move') styles.set_style(self._toolbar, 'toolbar-default') self.addToolBar(Qt.LeftToolBarArea, self._toolbar) self._toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) #StatusBar self._status = StatusBar() self._status.hide() self.setStatusBar(self._status) #Main Widgets self.main = MainWindow(self) self.setCentralWidget(self.main) #Menu menubar = self.menuBar() styles.apply(menubar, 'menu') file_ = menubar.addMenu('&File') edit = menubar.addMenu('&Edit') view = menubar.addMenu('&View') project = menubar.addMenu('&Project') self.pluginsMenu = menubar.addMenu('P&lugins') about = menubar.addMenu('&About') #The order of the icons in the toolbar is defined by this calls self._menuFile = MenuFile(file_, self._toolbar, self.main) self._menuView = MenuView(view, self, self.main) self._menuEdit = MenuEdit(edit, self._toolbar, self.main, self._status) self._menuProject = MenuProject(project, self._toolbar, self.main) self._menuPlugins = MenuPlugins(self.pluginsMenu, self) self._menuAbout = MenuAbout(about, self.main) self.main.container.load_toolbar(self._toolbar) self.main._central.actual_tab().obtain_editor().setFocus() filenames, projects_path = core.cliparser.parse() for filename in filenames: self.main.open_document(filename) for project_path in projects_path: self.main.open_project_folder(project_path) self.connect(self.main, SIGNAL("fileSaved(QString)"), self.show_status_message) def show_status_message(self, message): self._status.showMessage(message, 2000) def add_toolbar_item(self, plugin, name, icon): self._toolbar.addSeparator() action = self._toolbar.addAction(QIcon(icon), name) self.connect(action, SIGNAL("triggered()"), lambda: plugin.toolbarAction()) def closeEvent(self, event): settings = QSettings('NINJA-IDE','Kunai') if settings.value('Preferences/General/load_files', 2).toInt()[0]==2: settings.setValue('Open_Files/projects',self.main.get_open_projects()) settings.setValue('Open_Files/tab1', self.main._central._tabs.get_open_files()) settings.setValue('Open_Files/tab2', self.main._central._tabs2.get_open_files()) else: settings.setValue('Open_Files/projects',[]) if self.main._central.check_for_unsaved(): val = QMessageBox.question(self, 'Some changes were not saved', 'Do you want to exit anyway?', QMessageBox.Yes, QMessageBox.No) if val == QMessageBox.No: event.ignore() else: self.main._properties._treeProjects.close_open_projects() else: self.main._properties._treeProjects.close_open_projects() def wheelEvent(self, event): if event.modifiers() == Qt.AltModifier: if event.delta() == 120 and self.opacity < self.max_opacity: self.opacity += 0.1 elif event.delta() == -120 and self.opacity > self.min_opacity: self.opacity -= 0.1 self.setWindowOpacity(self.opacity) event.ignore() else: super(IDE, self).wheelEvent(event)