def main(): client = HCPHoNClient() # Temporary client config # Move to self implementation using QSettings later. client._configure(protocol=19) app = QApplication(sys.argv) app.setApplicationName("HoNChatPy") #app.setQuitOnLastWindowClosed(True) # May need to change for system tray behaviour login_window = HCPLoginWindow(client) login_window.setObjectName('login_window') core_window = HCPCoreWindow(client) core_window.setObjectName('hcp_window') while True: while not client.is_logged_in: login_window.show() app.exec_() while client.is_logged_in: core_window.show() client.connect() app.exec_()
class Browser(QObject): # pylint: disable=too-many-public-methods __execute_script_called = Signal(str) def __init__(self): super().__init__() self.app = QApplication([]) self.webview = QWebView() self.webview.setAttribute(Qt.WA_DeleteOnClose) self.webview.destroyed.connect(self.app.quit) self.__execute_script_called.connect(self.__execute_script) def __execute_script(self, javascript_code: str): assert current_thread_is_main() self.webview.page().mainFrame().evaluateJavaScript(javascript_code) def execute_script(self, javascript_code: str): if current_thread_is_main(): self.__execute_script(javascript_code) else: self.__execute_script_called.emit(javascript_code) def run(self, url): assert current_thread_is_main() self.webview.showFullScreen() self.webview.load(url) self.app.exec_()
def main(): if len(sys.argv) < 3: sys.exit('please specifiy website url and image path') website, image_path = sys.argv[1], sys.argv[2] app = QApplication(sys.argv) renderer = ImageRenderer(website, image_path) app.exec_()
def webkit_download(url): app = QApplication([]) webview = QWebView() webview.loadFinished.connect(app.quit) webview.load(url) app.exec_() # delay here until download finished return webview.page().mainFrame().toHtml()
def main(): app = QApplication(sys.argv) editor = pyqode.core.QGenericCodeEdit() editor.show() # show the api pyqode is currently using editor.setPlainText("pyQode using %s" % os.environ["QT_API"]) app.exec_()
def main(): app = QApplication(sys.argv) app.setApplicationName("Audio Device Test") audio = AudioTest() audio.show() app.exec_()
def main(): app = QApplication(sys.argv) mw = ToolkitMainWindow() mw.show() app.exec_() sys.exit()
def main(): try: app = QApplication(sys.argv) #app.setStyle('cleanlooks') app.setStyleSheet(qdarkstyle.load_stylesheet()) db = Database('sample.db') icon = QIcon('app.ico') app.setWindowIcon(icon) # set the default font for the app app.setFont(MEDIUM_FONT) app.setStyle(BUTTON_STYLE) main_view = MainView() main_view.showMaximized() main_view.show() app.exec_() # clean up and exit code for model in main_view.models: model.submitAll() # commit all pending changes to all models db.close() app.quit() sys.exit(0) #os._exit(0) except SystemExit: print("Closing Window...") except Exception as e: print(str(e))
def run_emulator( sysargv, use_pifacedigital, init_board, emulated_pfd): app = QApplication(sysargv) emu_window = PiFaceDigitalEmulatorWindow() if use_pifacedigital: emu_window.pifacedigital = pifacedigitalio.PiFaceDigital( hardware_addr=emulated_pfd.hardware_addr, bus=emulated_pfd.bus, chip_select=emulated_pfd.chip_select, init_board=init_board) emu_window.current_pfd = emulated_pfd.hardware_addr emu_window.update_jumpers() start_q_watcher(app, emu_window, emulated_pfd.proc_comms_q_to_em, emulated_pfd.proc_comms_q_from_em) # only watch inputs if there is actually a piface digital if emu_window.pifacedigital is not None: start_input_watcher(app, emu_window) emu_window.show() app.exec_()
def startMonitor(): camera = Camera() actionDict = ActionDict(camera) config = Config( actionDict, getButtons().keys(), getClickTypes()) camera.setConfig(config) config.checkConfigFile() app = QApplication([]) camera.initCamera() keys = QmKeys() buttonTimers = dict() for b in getButtons().values(): buttonTimers[b] = ClickTimer(b, config) keys.keyEvent.connect(lambda k, s: (k in buttonTimers and buttonTimers[k].keyEvent(s))) config.dbusButton.setHandler( lambda button: dbusBtnClicked(config, button)) config.dbusButton.connectButtonDbus() config.proximityButton.setHandler( lambda state: prxBtnClicked(config, state)) config.proximityButton.connectProximityButton() app.exec_()
def launch(msfrpc, **kwargs): app = QApplication(sys.argv) MsfShellWindow(msfrpc, **kwargs).show() if sys.platform == 'darwin': from subprocess import Popen Popen(['osascript', '-e', 'tell application "Python" to activate']) app.exec_()
def run_emulator( sysargv, cad, proc_comms_q_to_em, proc_comms_q_from_em, emulator_sync): app = QApplication(sysargv) emu_window = PiFaceCADEmulatorWindow() emu_window.cad = cad # now we have to set up some state so that the emulator and the cad are in #sync emu_window.display_on() emu_window.cursor_on() emu_window.backlight_off() emu_window.blink_on() start_interface_message_handler( app, emu_window, proc_comms_q_to_em, proc_comms_q_from_em) # only watch switches if there is actually a piface cad attached if emu_window.cad is not None: start_switch_watcher(app, emu_window) start_blinker(app, emu_window) # causing problems emu_window.show() app.exec_()
def run_emulator( sysargv, use_LNdigital, init_board, emulated_LN): app = QApplication(sysargv) emu_window = LNdigitalEmulatorWindow() if use_LNdigital: emu_window.LNdigital = LNdigitalIO.LNdigitals( hardware_addr=emulated_LN.hardware_addr, bus=emulated_LN.bus, chip_select=emulated_LN.chip_select, init_board=init_board) emu_window.current_LN = emulated_LN.hardware_addr start_q_watcher(app, emu_window, emulated_LN.proc_comms_q_to_em, emulated_LN.proc_comms_q_from_em) # only watch inputs if there is actually a LN digital if emu_window.LNdigital is not None: start_input_watcher(app, emu_window) emu_window.show() app.exec_()
def browse(url, name='', icon=''): from PySide.QtGui import QApplication, QIcon from PySide.QtCore import QUrl from PySide.QtWebKit import QWebView for try_ in range(10): try: assert urllib2.urlopen(url).code == 200 except (AssertionError, urllib2.URLError): time.sleep(0.25) else: print "Started Qt Web View after %i ticks." % try_ break else: sys.exit("Error initializing Qt Web View.") qtapp = QApplication(name) web = QWebView() web.load(QUrl(url)) if icon: print "Setting Icon to", icon web.setWindowIcon(QIcon(icon)) else: print "WARNING: No icon found in settings.py" web.setWindowTitle(name) web.show() qtapp.exec_()
class MainWindow(QMainWindow): """ Creates the main window for dataNexus. Also handles any functions for the main window. """ def __init__(self): """ Initializes the application and logging for the MainWindow class. """ self.app = QApplication(sys.argv) def create_main_window(self, version): """ Creates the main application window and returns it. :param version: The application's version number, found in the project root-level __init__.py :return: """ window = QMainWindow() window.setMinimumSize(800, 600) window.setWindowTitle("dataNexus v" + version) # Create the menu for main window. menu = window.menuBar() sub_menus = Menu(menu, window) sub_menus.create_file_menu() sub_menus.create_edit_menu() sub_menus.create_about_menu() window.show() self.app.exec_()
def main(): app = QApplication(sys.argv) # this is used for the window title app.setApplicationName('PoC audio player') mainwindow = PlaybackWindow() mainwindow.show() app.exec_()
def main(): app = QApplication(sys.argv) # connect to the current user's session bus bus = dbus.SessionBus(mainloop=DBusGMainLoop()) try: # try to connect to our service. If this fails with a dbus # exception, the application is already running. mainwindow = bus.get_object('lunar.Qt4DBusTest', '/lunar/Qt4DBusTest/MainWindow') except dbus.DBusException: # the application is not running, so the service is registered and # the window created name = dbus.service.BusName('lunar.Qt4DBusTest', bus) mainwindow = DBusTrayMainWindow() # register the service object for the main window mainwindowobject = DBusTrayMainWindowObject(mainwindow, bus) # show the window and get the message loop running mainwindow.show() app.exec_() else: # the try clause completed, the application must therefore be # running. Now the mainwindow is shown and activated. mainwindow.show() mainwindow.activateWindow()
def main(argv): app = QApplication(argv) window = MainWindow() window.show() window.raise_() window.clearFocus() app.exec_()
class QmlGui(Gui): USES = ['geonames', 'qmllocationprovider'] def __init__(self, core, dataroot, parent=None): self.app = QApplication(sys.argv) self.core = core self.view = QDeclarativeView() self.view.statusChanged.connect(self._status_changed) glw = QGLWidget() self.view.setViewport(glw) self.controller = Controller(self.view, self.core) self.settings = SettingsWrapper(self.core) rc = self.view.rootContext() rc.setContextProperty('controller', self.controller) rc.setContextProperty('settings', self.settings) rc.setContextProperty('gps', GPSDataWrapper(self.core)) self.view.setSource(os.path.join('qml','main.qml')) def get_gps(self, callback): self.controller.callback_gps = callback def show(self): self.view.showFullScreen() self.app.exec_() self.core.on_destroy() def _status_changed(self, error): logger.error(self.view.errors())
def create_app(view_model_cls, args = sys.argv): ''' Create an application with shell using the `view_model` ''' app = QApplication(args) vm = view_model_cls() v = view_locator(vm) bind(vm, v) v.show() app.exec_()
def doit(): try: app = QApplication([]) except RuntimeError: app = QCoreApplication.instance() main_window = main_window_factory() main_window.show() app.exec_()
def test(): """A simple app to test the video stream""" import sys app = QApplication(sys.argv) video = VideoWidget() video.show() app.exec_()
def main(argv=None): if argv is None: argv = sys.argv app = QApplication(argv) window = MainWindow() window.show() app.exec_()
def __init__(self): rospy.init_node('key_control_app',anonymous=True) app = QApplication(sys.argv) app_widget = KeyControlAppWidget("KeyControlApp",app) rospy.logwarn("KeyControlApp: Started") app.exec_() rospy.logwarn('KeyControlApp: Finished')
def main(): app = QApplication(sys.argv) window = Window() window.show() #html = open(sys.argv[1]).read() #window.view.setHtml(html) window.view.load("html"+os.path.sep+"index.html") app.exec_()
def __init__(self): rospy.init_node('python_example_app',anonymous=True) app = QApplication(sys.argv) app_widget = PythonAppWidget("PythonExampleApp",app) # Running rospy.logwarn("PythonExampleApp: Started") app.exec_() # Done rospy.logwarn('PythonExampleApp: Finished')
def main(args): app = QApplication(args) app.setApplicationName(__APPNAME__) app.setApplicationVersion(__VERSION__) app.setOrganizationName(__ORG__) app.setOrganizationDomain(__ORGDOMAIN__) mainwindow = MaeBird() mainwindow.show() app.exec_() del mainwindow
def main(): manager = PluginManager() manager.setPluginPaths(["plugins"]) manager.loadPlugins() app = QApplication(sys.argv) dialog = PluginDialog(manager) dialog.show() app.exec_()
def main(): QApplication.setColorSpec(QApplication.ManyColor) app = QApplication(sys.argv) app.setOrganizationName("NJN Ltd.") app.setOrganizationDomain("e-nool.blogspot.com") app.setApplicationName("Nigandu English to Tamil Dictionary") app.setWindowIcon(QIcon(":/icons/njnlogo.png")) form = mainwin() form.show() app.exec_()
def main(): app = QApplication(argv) # n = Notepad() # n.show() w = NotepadWindow() w.show() app.exec_()
def run_app(): app = create_app() create_db(app) appg = QApplication(sys.argv) if os.name != 'nt': # !!! it did not work creates no back-end available error !!! # !!! strange bug , do not remove !!! if listp(): pass window = NewWindow(app) # switching the language with template folder path @app.route('/lang_switch/<int:lang>') def lang_switch(lang): if lang == 1: session['lang'] = 'AR' else: session['lang'] = 'EN' if current_user.is_authenticated: return redirect(str(request.referrer)) return redirect(url_for('core.root')) # Adding error handlers on main app instance @app.errorhandler(404) @app.errorhandler(500) @app.errorhandler(413) def page_not_found(error): if error == 413: flash(get_lang(55), "danger") if current_user.is_authenticated: return redirect(url_for('cust_app.multimedia', nn=1)) return redirect(url_for('core.root')) flash(get_lang(56), "danger") return redirect(url_for('core.root')) # Injecting default varibles to all templates @app.context_processor def inject_vars(): # adding language support var ar = False if session.get('lang') == 'AR': ar = True # adding browser detection var firefox = False if session.get('firefox') == 1: firefox = True # modifing side bar spacing for specific paths path = request.path adml = [ '/users', '/user_a', '/admin_u', '/user_u', '/csvd', '/settings' ] adme = False if path in adml or path[:7] in adml or path[:5] in adml: adme = True return dict(is_connected=check_ping, path=path, adme=adme, brp=Markup("<br>"), ar=ar, firefox=firefox, version=version) QCoreApplication.processEvents() appg.exec_()
message = "Alert! " try: if len(sys.argv) < 2: raise ValueError("Not enough arguments") hours, minutes = sys.argv[1].split(":") #python SimpleApp.py 09:32 <optional message> due = QTime(int(hours), int(minutes)) if not due.isValid(): raise ValueError("Input time is not Valid") if len(sys.argv) > 2: message += " ".join(sys.argv[2:]) except ValueError as e: print e.args print "Usage: python SimpleApp.py HH:MM [message]" sys.exit(0) while QTime.currentTime() < due: time.sleep(5) label = QLabel("<font color=red size=36 >" + message + "</font>") label.setWindowFlags(Qt.SplashScreen) label.show() QTimer.singleShot(10000, quitApplication(app)) app.exec_() # Run the application
def main(): app = QApplication(sys.argv) w = MainWindow() w.show() QMessageBox.information(None, "Info", "Just drag and drop the items.") sys.exit(app.exec_())
selected_filter = selected_filter[1:] if filename: if not filename.endswith(selected_filter): filename += selected_filter self.lineEdit.setText(filename) def accept(self): """Overrride QDialog accept. """ path = self.lineEdit.text() date = self.dateTimeEdit.dateTime().toPython() try: info = Database(since=date).info() info.generate_page(path) url_open(path, isfile=True) self.close() except NoMatchError: QErrorMessage(self).showMessage(u'无匹配条目\n{}') class NoMatchError(Exception): """Indecate no match item on cgtw. """ def __str__(self): return u'no match item founded. ' if __name__ == '__main__': APP = QApplication(sys.argv) FRAME = Dialog() FRAME.show() sys.exit(APP.exec_())
def main(): application = QApplication(sys.argv) app = MainWindow(application) app.show() app.raise_() sys.exit(application.exec_())
tree_widget = QTreeWidgetItem() tree_widget.setText(0, k) total_size = 0 for child in v['children']: total_size += child.total_size tree_widget.setText(1, self._get_size(v[constant.sort_size_name])) self.key_tree.addTopLevelItem(tree_widget) self._last_info = info def _refresh_value_tree(self, directory_info): info = sorted(directory_info, key=lambda x: x.total_size, reverse=True) # Clear for _ in range(self.value_tree.topLevelItemCount()): self.value_tree.takeTopLevelItem(0) # Add for item in info: tree_widget = QTreeWidgetItem() tree_widget.setText(0, item.part_path) tree_widget.setText(1, self._get_size(item.total_size)) self.value_tree.addTopLevelItem(tree_widget) if __name__ == '__main__': directory_detect_app = QApplication(sys.argv) directory_detect_window = DirectoryDetectWindow() directory_detect_window.show() directory_detect_app.exec_() sys.exit()
class qtPodder(QObject): def __init__(self, args, gpodder_core, dbus_bus_name): QObject.__init__(self) self.dbus_bus_name = dbus_bus_name # TODO: Expose the same D-Bus API as the Gtk UI D-Bus object (/gui) # TODO: Create a gpodder.dbusproxy.DBusPodcastsProxy object (/podcasts) self.app = QApplication(args) signal.signal(signal.SIGINT, signal.SIG_DFL) self.quit.connect(self.on_quit) self.core = gpodder_core self.config = self.core.config self.db = self.core.db self.model = self.core.model self.config_proxy = ConfigProxy(self.config) # Initialize the gpodder.net client self.mygpo_client = my.MygPoClient(self.config) gpodder.user_extensions.on_ui_initialized( self.model, self.extensions_podcast_update_cb, self.extensions_episode_download_cb) self.view = DeclarativeView() self.view.closing.connect(self.on_quit) self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.controller = Controller(self) self.media_buttons_handler = helper.MediaButtonsHandler() self.tracker_miner_config = helper.TrackerMinerConfig() self.podcast_model = gPodderPodcastListModel() self.episode_model = gPodderEpisodeListModel(self.config) self.last_episode = None # A dictionary of episodes that are currently active # in some way (i.e. playing back or downloading) self.active_episode_wrappers = {} engine = self.view.engine() # Add the cover art image provider self.cover_provider = images.LocalCachedImageProvider() engine.addImageProvider('cover', self.cover_provider) root_context = self.view.rootContext() root_context.setContextProperty('controller', self.controller) root_context.setContextProperty('configProxy', self.config_proxy) root_context.setContextProperty('mediaButtonsHandler', self.media_buttons_handler) root_context.setContextProperty('trackerMinerConfig', self.tracker_miner_config) # Load the QML UI (this could take a while...) self.view.setSource(QUrl.fromLocalFile(QML('main_default.qml'))) # Proxy to the "main" QML object for direct access to Qt Properties self.main = helper.QObjectProxy( self.view.rootObject().property('main')) self.main.podcastModel = self.podcast_model self.main.episodeModel = self.episode_model self.view.setWindowTitle('gPodder') if gpodder.ui.harmattan: self.view.showFullScreen() else: # On the Desktop, scale to fit my small laptop screen.. desktop = self.app.desktop() if desktop.height() < 1000: FACTOR = .8 self.view.scale(FACTOR, FACTOR) size = self.view.size() size *= FACTOR self.view.resize(size) self.view.show() self.do_start_progress.connect(self.on_start_progress) self.do_end_progress.connect(self.on_end_progress) self.do_show_message.connect(self.on_show_message) podcasts = self.load_podcasts() self.resumable_episodes = None self.do_offer_download_resume.connect(self.on_offer_download_resume) util.run_in_background(self.find_partial_downloads(podcasts)) def find_partial_downloads(self, podcasts): def start_progress_callback(count): self.start_progress(_('Loading incomplete downloads')) def progress_callback(title, progress): self.start_progress( '%s (%d%%)' % (_('Loading incomplete downloads'), progress * 100)) def finish_progress_callback(resumable_episodes): self.end_progress() self.resumable_episodes = resumable_episodes self.do_offer_download_resume.emit() common.find_partial_downloads(podcasts, start_progress_callback, progress_callback, finish_progress_callback) do_offer_download_resume = Signal() def on_offer_download_resume(self): if self.resumable_episodes: def download_episodes(): for episode in self.resumable_episodes: qepisode = self.wrap_simple_episode(episode) self.controller.downloadEpisode(qepisode) def delete_episodes(): logger.debug('Deleting incomplete downloads.') common.clean_up_downloads(delete_partial=True) message = _( 'Incomplete downloads from a previous session were found.') title = _('Resume') self.controller.confirm_action(message, title, download_episodes, delete_episodes) def add_active_episode(self, episode): self.active_episode_wrappers[episode.id] = episode episode.episode_wrapper_refcount += 1 def remove_active_episode(self, episode): episode.episode_wrapper_refcount -= 1 if episode.episode_wrapper_refcount == 0: del self.active_episode_wrappers[episode.id] def load_last_episode(self): last_episode = None last_podcast = None for podcast in self.podcast_model.get_podcasts(): for episode in podcast.get_all_episodes(): if not episode.last_playback: continue if last_episode is None or \ episode.last_playback > last_episode.last_playback: last_episode = episode last_podcast = podcast if last_episode is not None: self.last_episode = self.wrap_episode(last_podcast, last_episode) # FIXME: Send last episode to player #self.select_episode(self.last_episode) def on_episode_deleted(self, episode): # Remove episode from play queue (if it's in there) self.main.removeQueuedEpisode(episode) # If the episode that has been deleted is currently # being played back (or paused), stop playback now. if self.main.currentEpisode == episode: self.main.togglePlayback(None) def enqueue_episode(self, episode): self.main.enqueueEpisode(episode) def run(self): return self.app.exec_() quit = Signal() def on_quit(self): # Make sure the audio playback is stopped immediately self.main.togglePlayback(None) self.save_pending_data() self.view.hide() self.core.shutdown() self.app.quit() do_show_message = Signal(unicode) @Slot(unicode) def on_show_message(self, message): self.main.showMessage(message) def show_message(self, message): self.do_show_message.emit(message) def show_input_dialog(self, message, value='', accept=_('OK'), reject=_('Cancel'), is_text=True): self.main.showInputDialog(message, value, accept, reject, is_text) def open_context_menu(self, items): self.main.openContextMenu(items) do_start_progress = Signal(str) @Slot(str) def on_start_progress(self, text): self.main.startProgress(text) def start_progress(self, text=_('Please wait...')): self.do_start_progress.emit(text) do_end_progress = Signal() @Slot() def on_end_progress(self): self.main.endProgress() def end_progress(self): self.do_end_progress.emit() def resort_podcast_list(self): self.podcast_model.sort() def insert_podcast(self, podcast): self.podcast_model.insert_object(podcast) self.mygpo_client.on_subscribe([podcast.url]) self.mygpo_client.flush() def remove_podcast(self, podcast): # Remove queued episodes for this specific podcast self.main.removeQueuedEpisodesForPodcast(podcast) if self.main.currentEpisode is not None: # If the currently-playing episode is in the podcast # that is to be deleted, stop playback immediately. if self.main.currentEpisode.qpodcast == podcast: self.main.togglePlayback(None) self.podcast_model.remove_object(podcast) self.mygpo_client.on_unsubscribe([podcast.url]) self.mygpo_client.flush() def load_podcasts(self): podcasts = map(model.QPodcast, self.model.get_podcasts()) self.podcast_model.set_podcasts(self.db, podcasts) return podcasts def wrap_episode(self, podcast, episode): try: return self.active_episode_wrappers[episode.id] except KeyError: return model.QEpisode(self, podcast, episode) def wrap_simple_episode(self, episode): for podcast in self.podcast_model.get_podcasts(): if podcast.id == episode.podcast_id: return self.wrap_episode(podcast, episode) return None def select_podcast(self, podcast): if isinstance(podcast, model.QPodcast): # Normal QPodcast instance wrap = functools.partial(self.wrap_episode, podcast) objects = podcast.get_all_episodes() self.episode_model.set_is_subset_view(False) else: # EpisodeSubsetView wrap = lambda args: self.wrap_episode(*args) objects = podcast.get_all_episodes_with_podcast() self.episode_model.set_is_subset_view(True) self.episode_model.set_objects(map(wrap, objects)) self.main.state = 'episodes' def save_pending_data(self): current_ep = self.main.currentEpisode if isinstance(current_ep, model.QEpisode): current_ep.save() def podcast_to_qpodcast(self, podcast): podcasts = filter(lambda p: p._podcast == podcast, self.podcast_model.get_podcasts()) assert len(podcasts) <= 1 if podcasts: return podcasts[0] return None def extensions_podcast_update_cb(self, podcast): logger.debug('extensions_podcast_update_cb(%s)', podcast) try: qpodcast = self.podcast_to_qpodcast(podcast) if qpodcast is not None and not qpodcast.pause_subscription: qpodcast.qupdate( finished_callback=self.controller.update_subset_stats) except Exception, e: logger.exception('extensions_podcast_update_cb(%s): %s', podcast, e)
def __init__(self): app = QApplication(sys.argv) app.setApplicationName('OpenDev Player') player = VideoPlayer() player.show() app.exec_()
if __name__ == '__main__': parser = argparse.ArgumentParser(description='BraidsTag server.') args = parser.parse_args() gameState = ServerGameState() main = ListeningThread(gameState) main.start() # Create Qt application app = QApplication(sys.argv) mainWindow = MainWindow(gameState) mainWindow.show() # Enter Qt main loop retval = app.exec_() for i in gameState.players.values(): print i main.stop() gameState.terminate() #print >> sys.stderr, "\n*** STACKTRACE - START ***\n" #code = [] #for threadId, stack in sys._current_frames().items(): # code.append("\n# ThreadID: %s" % threadId) # for filename, lineno, name, line in traceback.extract_stack(stack): # code.append('File: "%s", line %d, in %s' % (filename, # lineno, name)) # if line:
def main(): app = QApplication(sys.argv) ex_start = Start() ex_start.show() sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) window = MainWindow() window.show() app.exec_()
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '--qt_from', default='pyqt', choices=['pyqt', 'pyqt5', 'pyside', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument( '--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_pyside() elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_pyqt() elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_pyqt5() elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_from_environment() elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.mw_dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.mw_dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.mw_dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs from ui.mw_dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' # create the application app = QApplication(sys.argv) # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__ + " - Example - Using " + args.qt_from) # create docks for buttons dw_buttons = QDockWidget() ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - fields dw_inputs = QDockWidget() ui_inputs = ui_inputs() ui_inputs.setupUi(dw_inputs) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs) # create docks for inputs - no fields dw_inputs_no_field = QDockWidget() ui_inputs_no_field = ui_inputs_no_fields() ui_inputs_no_field.setupUi(dw_inputs_no_field) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_field) # tabify docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs) window.tabifyDockWidget(dw_inputs, dw_inputs_no_field) # connect some actions, signals and functions # auto quit after 2s when testing on travis-ci if "--test" in sys.argv: QTimer.singleShot(2000, app.exit) # run window.showMaximized() app.exec_()
def main(): app = QApplication([]) widget = ExampleWidget() widget.show() app.exec_()
#!/usr/bin/env python2.7 import logging import sys from PySide.QtGui import QApplication from Meso1819.Meso1819Gui import Meso1819Gui log = logging.getLogger('Meso1819') log.setLevel(logging.DEBUG) qt_app = QApplication(sys.argv) inst = Meso1819Gui() qt_app.exec_()
def main(): app = QApplication(sys.argv) mainwindow = SpiralWindow() mainwindow.show() app.exec_()
database.store(athlete) else: athlete = False print "No athlete created. Pushup-app quitting" elif len(athletes) == 1: athlete = athletes[0] elif len(athletes) > 1: profileSelection = ProfileSelector(athletes) profileSelection.runSelectionDialog() athlete = profileSelection.getSelectedAthlete() return athlete # # Application starts here ! # qtApplication = QApplication(sys.argv) athlete = getAthleteProfile() if athlete is not False: mainController = MainWindow(athlete) mainController.showMainWindow() sys.exit(qtApplication.exec_()) else: sys.exit(qtApplication.quit())
self.myStatusBar = QStatusBar() self.progressBar.setValue(10) self.myStatusBar.addWidget(self.statusLabel, 1) self.myStatusBar.addWidget(self.progressBar, 2) self.setStatusBar(self.myStatusBar) def ShowProgress(self): """ Function to Show Progress """ while self.progressBar.value() < self.progressBar.maximum(): self.progressBar.setValue(self.progressBar.value() + 1) self.statusLabel.setText('Ready') if __name__ == '__main__': # Exception Handeling try: myApp = QApplication(sys.argv) mainWindow = MainWindow() mainWindow.CreateStatusBar() mainWindow.show() mainWindow.ShowProgress() myApp.exec_() sys.exit(0) except NameError: print("Name Error", sys.exc_info()[1]) except SystemExit: print("Closing Window...") except Exception: print(sys.exc_info()[1])
def get_main_window_app(qt_from='pyqt', no_dark=True): """Return main window application.""" # set log for debug logging.basicConfig(level=logging.DEBUG) style = '' if qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # getting style style = qrainbowstyle.load_stylesheet_pyside() elif qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # getting style style = qrainbowstyle.load_stylesheet_pyqt() elif qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # getting style style = qrainbowstyle.load_stylesheet_pyqt5() elif qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # getting style style = qrainbowstyle.load_stylesheet_from_environment() elif qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt import QtGui, QtCore # getting style style = qrainbowstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if no_dark: style = '' # create the application app = QApplication(sys.argv) app.setOrganizationName('QRainbowStyle') app.setApplicationName('QRainbowStyle Test') # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() window.setWindowTitle("QRainbowStyle v." + qrainbowstyle.__version__ + " - TEST - Using " + qt_from) # auto quit after 2s when testing on travis-ci if "--test" in sys.argv: QTimer.singleShot(2000, app.exit) # run window.showMaximized() app.exec_() return window
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--qt_from', default='pyqt', choices=['pyqt', 'pyqt5', 'pyside', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument('--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyside() elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt() elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt5() elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment() elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') if args.qt_from == 'pyside': pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) else: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__ + " - Example - Using " + args.qt_from) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # auto quit after 2s when testing on travis-ci if "--test" in sys.argv: QTimer.singleShot(2000, app.exit) # run read_settings(window) window.showMaximized() app.exec_() write_settings(window)
if y != 1: item = self.table.item(x, y) item.setTextAlignment(Qt.AlignCenter) else: pass self.btn_set_middle.setStyleSheet('background-color:lightblue') self.settext(u'将文字居中显示,设置文字颜色') def cellchange(self, row, col): item = self.table.item(row, col) txt = item.text() self.settext(u'第%s行,第%s列 , 数据改变为:%s' % (row, col, txt)) def noframe(self): self.table.setAlternatingRowColors(True) self.table.setFrameStyle(QFrame.NoFrame) self.table.setStyleSheet('color:green;' 'gridline-color:white;' 'border:0px solid gray') self.settext(u'取消表的框线,\n 取消表格内框') def settext(self, txt): font = QFont(u'微软雅黑', 10) self.txt.setFont(font) self.txt.setText(txt) if __name__ == '__main__': app = QApplication(sys.argv) ui = ui() sys.exit(app.exec_())
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '--qt_from', default='qtpy', choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument( '--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") parser.add_argument('--reset', action='store_true', help="Reset GUI settings (position, size).") parser.add_argument('--screenshots', action='store_true', help="Generate screenshots.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) # to avoid problems when testing without screen if args.test: os.environ['QT_QPA_PLATFORM'] = 'offscreen' if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyside elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyqt elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyqt5 elif args.qt_from == 'pyside2': # using PyQt5 wrapper from PySide2.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PySide2.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside2_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside2_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside2_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside2_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside2_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside2_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside2_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside2_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside2_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyside2 elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_from_environment elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = lambda: qdarkstyle.load_stylesheet_from_environment( is_pyqtgraph=True) if args.no_dark: style = '' def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window, reset=False): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') if args.qt_from == 'pyside' or args.qt_from == 'pyside2': pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) else: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') if not reset: window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet style = style_method() app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # tabify right docks window.tabifyDockWidget(dw_containers_no_tabs, dw_containers_tabs) window.tabifyDockWidget(dw_containers_tabs, dw_widgets) window.tabifyDockWidget(dw_widgets, dw_views) # issues #9120, #9121 on Spyder qstatusbar = QStatusBar() qstatusbar.addWidget( QLabel('Issue Spyder #9120, #9121 - background not matching.')) qstatusbar.addWidget(QPushButton('OK')) window.setStatusBar(qstatusbar) # auto quit after 2s when testing on travis-ci if args.test: QTimer.singleShot(2000, app.exit) # run read_settings(window, args.reset) window.showMaximized() # Save screenshots for differents displays and quit if args.screenshots: window.showFullScreen() QTimer.singleShot( 1000, lambda: create_screenshots(app, window, not args.no_dark)) app.exec_() write_settings(window)
def main(): app = QApplication(argv) game = Fifteen(4, 4) gui = GameGui(game) app.exec_()
def redirect_to_permission_page(): QDesktopServices.openUrl(get_permission_url()) quickstart(auth_server) def shoot(): if (not isTokenCollected()): redirect_to_permission_page() #taking the screenshot filename = date.strftime('%Y-%m-%d_%H-%M-%S.jpg') p = QPixmap.grabWindow(QApplication.desktop().winId()) p.save(filename, 'jpg') upload_file_to_drive(filename) def upload_file_to_drive(fname): service = get_drive_service() insert_file(service, fname, 'SHTR SHOT', None, 'image/jpg', fname) widget.layout().addWidget(QPushButton('Setup Google Drive', clicked=shoot)) dispatcher.connect(receive_verification_code) widget.show() #enter Qt App main loop app.exec_() sys.exit()
def main(): app = QApplication(sys.argv) opc = opcda.start() main_window = MainWindow(opc) main_window.show() app.exec_()
def main(): app = QApplication(sys.argv) # app.setStyle('plastique') win = BaseMplCanvas() win.show() sys.exit(app.exec_())
def demo_3REPORT(): from Appointment import AppointmentClass from Patient import PatientClass db_appointment = ControllerDatabase('appointmentObject.pkl') db_patients = ControllerDatabase('patientObject.pkl') pre_pre_report = [[ "OPD", "0001", "PIC", "Atichat Lappanopakon", 20, "0971249197", "10001" ], ["Pre_OD", "Plan", "Underlying", "Treatment", "Note"]] p1 = PatientClass.Patient(pre_pre_report) pre_pre_report = [[ "IPD", "0002", "PIC", "David Jason", 10, "0871249197", "10002" ], ["Pre_OD", "Plan", "Underlying", "Treatment", "Note"]] p2 = PatientClass.Patient(pre_pre_report) pre_pre_report = [[ "OPD", "0003", "PIC", "Sara MJ", 40, "0271249197", "10003" ], ["Pre_OD", "Plan", "Underlying", "Treatment", "Note"]] p3 = PatientClass.Patient(pre_pre_report) db_patients.updateObject([p1, p2, p3]) doctor = Doctor('D001', 'doc1', '1234', 'Dr.A', 'Charnchyyy', '00000', 'Sri tanya') s1 = AppointmentClass.Appointment( '10001', ["Elective case", "28/5/2017", "Morning"], doctor, p1) s2 = AppointmentClass.Appointment( '10002', ["Emergency case", "28/5/2017", "Afternoon"], doctor, p2) s3 = AppointmentClass.Appointment('10003', ["Ergency case", "28/5/2017", "None"], doctor, p3) db_appointment.updateObject([s1, s2, s3]) preReport1 = PreReportPatientClass.PreReportByNurse( 'atenolol 5 mg tab O at 6.00', '-', '-', '-', '-', 'Yes', '001', 'In', 'I', '2', '5', '130/80', '86', '20', '36', 'E', 'Yes', 'Yes', 'Yes', ['Med1', 'sym1', 'Med2', 'sym2', 'Med3', 'sym3']) preReport2 = PreReportPatientClass.PreReportByNurse( 'atenolol 5 mg tab O at 6.00', '-', '-', '-', '-', 'Yes', '001', 'In', 'I', '2', '5', '130/80', '86', '20', '36', 'E', 'Yes', 'Yes', 'No', ['-', '-', '-', '-', '-', '-']) intraReport = IntraReportPatientClass.IntraReportPatient( '1234', '01/06/2017', '0001', '101', 'A', 'ICUS', 'ICUS', ['Janet van Dyne', 'Wanda Maximoff'], 'post diagnose', 'operation', 'Major', 'Anes', 'Clinton Francis Barton', 'note', 'Pre anesthesia visit at ward', 'Official', 'I', '1', '1', '1', '-', '-', 'Oral Endotrachel Tracheal', '8:30', '9:00', '30', '-', [ 'Janet van Dyne', 'Wanda Maximoff', 'Natasha Alianovna Romanoff', 'Carol Danvers', 'Jennifer Walters' ]) intraReport2 = IntraReportPatientClass.IntraReportPatient( '1111', '02/06/2017', '0002', '102', 'A', 'ICUS', 'ICUS', ['Janet van Dyne', 'Wanda Maximoff'], 'post diagnose', 'operation', 'Major', 'Anes', 'Clinton Francis Barton', 'note', 'Pre anesthesia visit at ward', 'Official', 'I', '1', '1', '1', '-', '-', 'Oral Endotrachel Tracheal', '8:30', '9:00', '30', '-', [ 'Janet van Dyne', 'Wanda Maximoff', 'Natasha Alianovna Romanoff', 'Carol Danvers', 'Jennifer Walters' ]) post_report1 = [ 'Anes. Personal hazard', 'Awareness', 'Cardiac arrest', 'Note', 'Jacques Duquesne', 'Procedure', '6/5/2017' ] post_report2 = [ 'CVA', 'Awareness', 'Diffcult intubation', 'Note', 'Jacques Duquesne', 'Procedure', '7/5/2017' ] post_report = PostReportPatientClass.PostReportPatient() post_report.setAnesthetic_complications_operationroom(post_report1) post_report.setAnesthetic_complications_admitroom(post_report1) post_report.setAnesthetic_complications_admitroom_2hrs(post_report1) post_report.setAnesthetic_complications_admitroom_24hrs(post_report2) post_report.setAnesthetic_complications_procedure(post_report2) post_report.setAnesthetic_complications_admitroom_48hrs(post_report2) post_report.setAnesthetic_complications_admitroom_7day(post_report2) p1.addPreReportNurse(preReport1) p1.addIntraReport(intraReport) p1.addPostReport(post_report) print(type(preReport1)) print(type(intraReport)) print(type(post_report)) import sys app = QApplication(sys.argv) # from Employee.Doctor.GuiClass import Dialog_3ReportPatientClass as R # win = R.ReportPatient() # pre_data, pre_databox = p1.getPreInfo() # intra_data, intra_databox = p1.getIntraInfo() # post_data = p1.getPostInfo() # win.setDataFromDataBasePre(pre_data, pre_databox) # win.setDataFromDataBaseIntra(intra_data, intra_databox) # win.setDataFromDataBasePost(post_data) """THIS HERE""" from Patient import Widget_HistoryReport as h win = h.HistoryReport(preReport1, intraReport, post_report) win.show() win.exec_() sys.exit(app.exec_())
class qtPodder(QObject): def __init__(self, args, gpodder_core, dbus_bus_name): QObject.__init__(self) self.dbus_bus_name = dbus_bus_name # TODO: Expose the same D-Bus API as the Gtk UI D-Bus object (/gui) # TODO: Create a gpodder.dbusproxy.DBusPodcastsProxy object (/podcasts) self.app = QApplication(args) signal.signal(signal.SIGINT, signal.SIG_DFL) self.quit.connect(self.on_quit) self.core = gpodder_core self.config = self.core.config self.db = self.core.db self.model = self.core.model self.config_proxy = ConfigProxy(self.config) # Initialize the gpodder.net client self.mygpo_client = my.MygPoClient(self.config) gpodder.user_extensions.on_ui_initialized( self.model, self.extensions_podcast_update_cb, self.extensions_episode_download_cb) self.view = DeclarativeView() self.view.closing.connect(self.on_quit) self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.controller = Controller(self) self.media_buttons_handler = helper.MediaButtonsHandler() self.tracker_miner_config = helper.TrackerMinerConfig() self.podcast_model = gPodderPodcastListModel() self.episode_model = gPodderEpisodeListModel(self.config, self) self.last_episode = None # A dictionary of episodes that are currently active # in some way (i.e. playing back or downloading) self.active_episode_wrappers = {} engine = self.view.engine() # Add the cover art image provider self.cover_provider = images.LocalCachedImageProvider() engine.addImageProvider('cover', self.cover_provider) root_context = self.view.rootContext() root_context.setContextProperty('controller', self.controller) root_context.setContextProperty('configProxy', self.config_proxy) root_context.setContextProperty('mediaButtonsHandler', self.media_buttons_handler) root_context.setContextProperty('trackerMinerConfig', self.tracker_miner_config) root_context.setContextProperty('podcastModel', self.podcast_model) root_context.setContextProperty('episodeModel', self.episode_model) root_context.setContextProperty('isSailfish', gpodder.ui.sailfish) for folder in gpodder.ui_folders: if gpodder.ui.sailfish: path = os.path.join(folder, 'sailfish') else: path = os.path.join(folder, 'harmattan') if os.path.exists(path): logger.info('Adding QML Import Path: %s', path) engine.addImportPath(path) # Load the QML UI (this could take a while...) self.view.setSource(QUrl.fromLocalFile(QML('main_default.qml'))) self.view.setWindowTitle('gPodder') if gpodder.ui.harmattan or gpodder.ui.sailfish: self.view.showFullScreen() else: # On the Desktop, scale to fit my small laptop screen.. desktop = self.app.desktop() if desktop.height() < 1000: FACTOR = .8 self.view.scale(FACTOR, FACTOR) size = self.view.size() size *= FACTOR self.view.resize(size) self.view.show() podcasts = self.load_podcasts() self.resumable_episodes = None self.do_offer_download_resume.connect(self.on_offer_download_resume) util.run_in_background(self.find_partial_downloads(podcasts)) def find_partial_downloads(self, podcasts): def start_progress_callback(count): self.controller.startProgress.emit( _('Loading incomplete downloads')) def progress_callback(title, progress): self.controller.startProgress.emit( '%s (%d%%)' % (_('Loading incomplete downloads'), progress * 100)) def finish_progress_callback(resumable_episodes): self.controller.endProgress.emit() self.resumable_episodes = resumable_episodes self.do_offer_download_resume.emit() common.find_partial_downloads(podcasts, start_progress_callback, progress_callback, finish_progress_callback) do_offer_download_resume = Signal() def on_offer_download_resume(self): if self.resumable_episodes: def download_episodes(): for episode in self.resumable_episodes: qepisode = self.wrap_simple_episode(episode) self.controller.downloadEpisode(qepisode) def delete_episodes(): logger.debug('Deleting incomplete downloads.') common.clean_up_downloads(delete_partial=True) message = _( 'Incomplete downloads from a previous session were found.') title = _('Resume') self.controller.confirm_action(message, title, download_episodes, delete_episodes) def add_active_episode(self, episode): self.active_episode_wrappers[episode.id] = episode episode.episode_wrapper_refcount += 1 def remove_active_episode(self, episode): episode.episode_wrapper_refcount -= 1 if episode.episode_wrapper_refcount == 0: del self.active_episode_wrappers[episode.id] def load_last_episode(self): last_episode = None last_podcast = None for podcast in self.podcast_model.get_podcasts(): for episode in podcast.get_all_episodes(): if not episode.last_playback: continue if last_episode is None or \ episode.last_playback > last_episode.last_playback: last_episode = episode last_podcast = podcast if last_episode is not None: self.last_episode = self.wrap_episode(last_podcast, last_episode) # FIXME: Send last episode to player #self.select_episode(self.last_episode) def run(self): return self.app.exec_() quit = Signal() def on_quit(self): self.controller.on_quit() self.view.hide() self.core.shutdown() self.app.quit() def resort_podcast_list(self): self.podcast_model.sort() def insert_podcast(self, podcast): self.podcast_model.insert_object(podcast) self.mygpo_client.on_subscribe([podcast.url]) self.mygpo_client.flush() def load_podcasts(self): podcasts = map(model.QPodcast, self.model.get_podcasts()) self.podcast_model.set_podcasts(self.db, podcasts) return podcasts def wrap_episode(self, podcast, episode): try: return self.active_episode_wrappers[episode.id] except KeyError: return model.QEpisode(self, podcast, episode) def wrap_simple_episode(self, episode): for podcast in self.podcast_model.get_podcasts(): if podcast.id == episode.podcast_id: return self.wrap_episode(podcast, episode) return None def select_podcast(self, podcast): if isinstance(podcast, model.QPodcast): # Normal QPodcast instance wrap = functools.partial(self.wrap_episode, podcast) objects = podcast.get_all_episodes() self.episode_model.set_is_subset_view(False) else: # EpisodeSubsetView wrap = lambda args: self.wrap_episode(*args) objects = podcast.get_all_episodes_with_podcast() self.episode_model.set_is_subset_view(True) self.episode_model.set_objects(map(wrap, objects)) def podcast_to_qpodcast(self, podcast): podcasts = filter(lambda p: p._podcast == podcast, self.podcast_model.get_podcasts()) assert len(podcasts) <= 1 if podcasts: return podcasts[0] return None def extensions_podcast_update_cb(self, podcast): logger.debug('extensions_podcast_update_cb(%s)', podcast) try: qpodcast = self.podcast_to_qpodcast(podcast) if qpodcast is not None and not qpodcast.pause_subscription: qpodcast.qupdate( finished_callback=self.controller.update_subset_stats) except Exception, e: logger.exception('extensions_podcast_update_cb(%s): %s', podcast, e)
def main(): app = QApplication(sys.argv) view = HarmattanView() view.showFullScreen() sys.exit(app.exec_())
return False # TODO gérer le else, au moins logger quelque chose return True if __name__ == "__main__": u"""Main de test""" import sys from PySide.QtGui import QApplication from PySide.QtCore import QLibraryInfo, QLocale, QTranslator from PySide.QtSql import QSqlDatabase app = QApplication(sys.argv) locale = QLocale.system().name() translator = QTranslator() translator.load("qt_" + locale, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(translator) # Configuration de la base de données db = QSqlDatabase.addDatabase("QSQLITE") db.setDatabaseName('private/gem.db') db.open() ui = IntervenantUI() ui.show() ret = app.exec_() sys.exit(ret)
def run(): app = QApplication(sys.argv) app.exec_()