def test(scale=0.25): from PyQt5.Qt import QLabel, QApplication, QPixmap, QMainWindow, QWidget, QScrollArea, QGridLayout app = QApplication([]) mi = Metadata('xxx', ['Kovid Goyal', 'John & Doe', 'Author']) mi.series = 'A series of styles' m = QMainWindow() sa = QScrollArea(m) w = QWidget(m) sa.setWidget(w) l = QGridLayout(w) w.setLayout(l), l.setSpacing(30) labels = [] for r, color in enumerate(sorted(default_color_themes)): for c, style in enumerate(sorted(all_styles())): mi.series_index = c + 1 mi.title = 'An algorithmic cover [%s]' % color prefs = override_prefs(cprefs, override_color_theme=color, override_style=style) scale_cover(prefs, scale) img = generate_cover(mi, prefs=prefs, as_qimage=True) la = QLabel() la.setPixmap(QPixmap.fromImage(img)) l.addWidget(la, r, c) labels.append(la) m.setCentralWidget(sa) w.resize(w.sizeHint()) m.show() app.exec_()
def launch_editor(path_to_edit, path_is_raw=False, syntax='html', callback=None): from calibre.gui2.tweak_book import dictionaries from calibre.gui2.tweak_book.main import option_parser from calibre.gui2.tweak_book.ui import Main from calibre.gui2.tweak_book.editor.syntax.html import refresh_spell_check_status dictionaries.initialize() refresh_spell_check_status() opts = option_parser().parse_args([]) app = QApplication([]) # Create the actions that are placed into the editors toolbars main = Main(opts) # noqa if path_is_raw: raw = path_to_edit else: with open(path_to_edit, 'rb') as f: raw = f.read().decode('utf-8') ext = path_to_edit.rpartition('.')[-1].lower() if ext in ('html', 'htm', 'xhtml', 'xhtm'): syntax = 'html' elif ext in ('css',): syntax = 'css' t = Editor(syntax) t.data = raw if callback is not None: callback(t) t.show() app.exec_()
def show_window_pyside(): # Import PySide classes from PyQt5.Qt import QApplication, QLabel # Create a Qt application app = QApplication([]) # Create a Label and show it label = QLabel("Hello World Pyside") label.show() app.exec_()
def launch_editor(path_to_edit, path_is_raw=False): app = QApplication([]) if path_is_raw: raw = path_to_edit else: with open(path_to_edit, 'rb') as f: raw = f.read() t = Editor('raster_image') t.data = raw t.show() app.exec_()
def main(): os.closerange(3, 256) app = QApplication([]) s = CalibreSplashScreen() s.show_message.connect(s.showMessage, type=Qt.QueuedConnection) s.shutdown.connect(app.quit, type=Qt.QueuedConnection) s.show() t = Thread(target=run_loop, args=(s,)) t.daemon = True t.start() app.exec_()
def test(): setup_for_cli_run() app = QApplication([]) bus = dbus.SessionBus() dbus_name = BusName('com.calibre-ebook.TestDBusMenu', bus=bus, do_not_queue=True) m = QMenu() ac = m.addAction(QIcon(I('window-close.png')), 'Quit', app.quit) ac.setShortcut(QKeySequence('Ctrl+Q')) menu = DBusMenu('/Menu', bus=bus) menu.publish_new_menu(m) app.exec_() del dbus_name
class HAEClient: def __init__(self): from codec import Codec from window import Window from system import System from datajar import DataJar from filesystem import FileSystem try: manifest = json.load(codecs.open('manifest.json', 'r', 'utf-8')) except: manifest = {} for key in assets.manifest: if key in manifest: assets.manifest[key] = manifest[key] self.app = QApplication(sys.argv) self.app.setApplicationName(assets.manifest['name']) self.app.setApplicationVersion(assets.manifest['version']) assets.sys = System() assets.codec = Codec() assets.fs = FileSystem() assets.dataJar = DataJar() translator = QTranslator() if translator.load("zh_CN.qm"): self.app.installTranslator(translator) self.window = Window(None, assets.manifest['path'] + 'index.html') sys.exit(self.app.exec_())
def main(): app = QApplication(sys.argv) ui = MainWindow() ui.setupUi() ui.show() sys.exit(app.exec_())
def test(): from PyQt5.Qt import QApplication, QMainWindow app = QApplication([]) w = QMainWindow() cf = CoverFlow() cf.resize(int(available_width()/1.5), available_height()-60) w.resize(cf.size()+QSize(30, 20)) model = DummyImageList() cf.setImages(model) cf.setCurrentSlide(39000) w.setCentralWidget(cf) w.show() cf.setFocus(Qt.OtherFocusReason) sys.exit(app.exec_())
def start(self): app = QApplication(sys.argv) app.setApplicationName('QuickText') self.window_init() if self.settings.value("myWidget/geometry") and self.settings.value("myWidget/windowState"): self.main_window.restoreGeometry(self.settings.value("myWidget/geometry")) self.main_window.restoreState(self.settings.value("myWidget/windowState")) self.main_window.show() try: ret = app.exec_() finally: self.end(ret)
def main(): app = QApplication(sys.argv) font = app.font() if sys.platform.startswith("win"): font.setFamily("Microsoft YaHei") else: font.setFamily("Ubuntu") app.setFont(font) main_window = MainWindow() main_window.setWindowTitle("Image Downloader") main_window.show() sys.exit(app.exec_())
def exceptHook(hook_type, value, traceback): from cura.CrashHandler import CrashHandler from cura.CuraApplication import CuraApplication has_started = False if CuraApplication.Created: has_started = CuraApplication.getInstance().started # # When the exception hook is triggered, the QApplication may not have been initialized yet. In this case, we don't # have an QApplication to handle the event loop, which is required by the Crash Dialog. # The flag "CuraApplication.Created" is set to True when CuraApplication finishes its constructor call. # # Before the "started" flag is set to True, the Qt event loop has not started yet. The event loop is a blocking # call to the QApplication.exec_(). In this case, we need to: # 1. Remove all scheduled events so no more unnecessary events will be processed, such as loading the main dialog, # loading the machine, etc. # 2. Start the Qt event loop with exec_() and show the Crash Dialog. # # If the application has finished its initialization and was running fine, and then something causes a crash, # we run the old routine to show the Crash Dialog. # from PyQt5.Qt import QApplication if CuraApplication.Created: _crash_handler = CrashHandler(hook_type, value, traceback, has_started) if CuraApplication.splash is not None: CuraApplication.splash.close() if not has_started: CuraApplication.getInstance().removePostedEvents(None) _crash_handler.early_crash_dialog.show() sys.exit(CuraApplication.getInstance().exec_()) else: _crash_handler.show() else: application = QApplication(sys.argv) application.removePostedEvents(None) _crash_handler = CrashHandler(hook_type, value, traceback, has_started) # This means the QtApplication could be created and so the splash screen. Then Cura closes it if CuraApplication.splash is not None: CuraApplication.splash.close() _crash_handler.early_crash_dialog.show() sys.exit(application.exec_())
def exceptHook(hook_type, value, traceback): from cura.CrashHandler import CrashHandler from cura.CuraApplication import CuraApplication has_started = False if CuraApplication.Created: has_started = CuraApplication.getInstance().started # # When the exception hook is triggered, the QApplication may not have been initialized yet. In this case, we don't # have an QApplication to handle the event loop, which is required by the Crash Dialog. # The flag "CuraApplication.Created" is set to True when CuraApplication finishes its constructor call. # # Before the "started" flag is set to True, the Qt event loop has not started yet. The event loop is a blocking # call to the QApplication.exec_(). In this case, we need to: # 1. Remove all scheduled events so no more unnecessary events will be processed, such as loading the main dialog, # loading the machine, etc. # 2. Start the Qt event loop with exec_() and show the Crash Dialog. # # If the application has finished its initialization and was running fine, and then something causes a crash, # we run the old routine to show the Crash Dialog. # from PyQt5.Qt import QApplication if CuraApplication.Created: _crash_handler = CrashHandler(hook_type, value, traceback, has_started) if CuraApplication.splash is not None: CuraApplication.splash.close() if not has_started: CuraApplication.getInstance().removePostedEvents(None) _crash_handler.early_crash_dialog.show() sys.exit(CuraApplication.getInstance().exec_()) else: _crash_handler.show() else: application = QApplication(sys.argv) application.removePostedEvents(None) _crash_handler = CrashHandler(hook_type, value, traceback, has_started) # This means the QtApplication could be created and so the splash screen. Then Cura closes it if CuraApplication.splash is not None: CuraApplication.splash.close() _crash_handler.early_crash_dialog.show() sys.exit(application.exec_())
def __init__(self, app_dir): app_dir = os.path.realpath(app_dir) manifest_path = os.path.join(app_dir, "manifest.json") try: manifest = json.load(codecs.open(manifest_path, 'r', 'utf-8')) except: manifest = {} for key in manifest: assets.manifest[key] = manifest[key] app = QApplication(sys.argv) app.setApplicationName(assets.manifest['name']) app.setApplicationVersion(assets.manifest['version']) assets.sys = System() assets.codec = Codec() assets.fs = FileSystem() assets.dataJar = DataJar() translator = QTranslator() translateLocaleName = "qt_" + QLocale.system().name() translator.load(translateLocaleName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(translator) if assets.manifest.get("plugins"): plugindir = os.path.join(app_dir, assets.manifest["plugins"]) plugin_manager = PluginsManager(plugindir) plugin_manager.load(assets) assets.manifest['icon'] = os.path.join(app_dir, assets.manifest["icon"]) assets.manifest['app_dir'] = app_dir if "--debug" in sys.argv: assets.manifest['debug'] = True index_path = os.path.join(app_dir, assets.manifest['path'] + 'index.html') self.window = Window(None, index_path) sys.exit(app.exec_())
class HAEClient: def __init__(self, app_dir): from codec import Codec from window import Window from system import System from datajar import DataJar from filesystem import FileSystem manifest_json = os.path.join(app_dir, "manifest.json") try: manifest = json.load(codecs.open(manifest_json, 'r', 'utf-8')) except: manifest = {} for key in assets.manifest: if key in manifest: assets.manifest[key] = manifest[key] self.app = QApplication(sys.argv) self.app.setApplicationName(assets.manifest['name']) self.app.setApplicationVersion(assets.manifest['version']) assets.sys = System() assets.codec = Codec() assets.fs = FileSystem() assets.dataJar = DataJar() translator = QTranslator() if translator.load(os.path.join(current_dir, "zh_CN.qm")): self.app.installTranslator(translator) paths = [app_dir] paths += assets.manifest['path'].split("/") paths.append("index.html") html_index = os.path.join(*paths) self.window = Window(None, html_index) sys.exit(self.app.exec_())
def main(): global app global threads Log.__init__(None) Log.i("Performing DB Init") upgrade = Upgrade() upgrade.upgrade() Log.i('Starting GUI') app = QApplication(sys.argv) Log.i('Process ID %s' % app.applicationPid()) app.setStyle('Fusion') app.focusWidget() window = MainWindow() app.setActiveWindow(window) window.show() threads = [] sys.excepthook = handle_exception sys.exit(app.exec_())
def main(): exit_on_ctrl_c() if '--automation_server' in sys.argv: pqaut.start_automation_server() if 'FREEZETIME' in os.environ: freeze_time(os.environ['FREEZETIME'], tz_offset=0).start() app = QApplication(sys.argv) qmlRegisterType(status_screen.StatusScreen, 'Screens', 1, 0, 'StatusScreen') qmlRegisterType(now_playing.NowPlaying, 'Widgets', 1, 0, 'NowPlaying') qmlRegisterType(marquee.Marquee, 'Widgets', 1, 0, 'Marquee') qmlRegisterType(model.project.Project, 'Model', 1, 0, 'Project') qmlRegisterType(model.projects_model.ProjectsModel, 'Model', 1, 0, 'ProjectsModel') window = main_window.MainWindow() window.showFullScreen() mqtt = mqtt_service.MqttService() mqtt.start() sys.exit(app.exec_())
from PyQt5.Qt import QApplication from src.controller.lib.ssqt import SSQt from src.controller.finder.finder import FinderController from src.controller.cadastro.pessoa import PessoaController class FinderPessoa(FinderController): def __init__(self, parent=None, env=None, feedClass=None, tv_find_list=None, cb_campo_list=None, force_show=None): campos = ['Nome', 'Código'] super(FinderPessoa, self).__init__(parent=parent, env=env, feedClass=PessoaController, tv_find_list=tv_find_list, cb_campo_list=cb_campo_list, force_show=force_show) self.view.setWindowTitle('Localizar Cliente') if __name__ == "__main__": appcl = QApplication(sys.argv) w = FinderPessoa(force_show=True) sys.exit(appcl.exec_())
class Application(object): ''' classdocs ''' def __init__(self): ''' Constructor ''' # logging.config.fileConfig("logging.conf") self.log = logging.getLogger("Application") def setupModels(self): self.mongoResultModel = MongoResultModel() pass def setupSlot(self): self.ui_MainWindow.tableview.setModel(self.mongoResultModel) self.ui_MainWindow.connectBtn.clicked.connect(self.appctl.connectServer) self.ui_MainWindow.querybtn.clicked.connect(self.appctl.query) self.ui_MainWindow.query.returnPressed.connect(self.appctl.query) self.ui_MainWindow.query.textChanged.connect(self.appctl.queryChange) self.ui_MainWindow.tableview.clicked.connect(self.appctl.clickTable) self.add_query_action = QAction("add to query",self.ui_MainWindow.tableview) self.add_query_action.triggered.connect(self.appctl.addToQuery) self.ui_MainWindow.tableview.setContextMenuPolicy(Qt.ActionsContextMenu) self.ui_MainWindow.tableview.addAction(self.add_query_action) self.tableHeader = self.ui_MainWindow.tableview.horizontalHeader() self.tableHeader.setSortIndicatorShown(True) self.tableHeader.sortIndicatorChanged.connect(self.appctl.columnSort) self.ui_MainWindow.treeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.ui_MainWindow.treeWidget.customContextMenuRequested.connect(self.appctl.showTreeMenu) self.ui_MainWindow.prevBtn.clicked.connect(self.appctl.prevPagination) self.ui_MainWindow.nextBtn.clicked.connect(self.appctl.nextPagination) def setupCtl(self): self.appctl = AppController(self) def run(self): self.log.info("app is start") self.qtapp = QApplication(sys.argv) self.setupUi() self.setupModels() self.setupCtl() self.setupSlot() sys.exit(self.qtapp.exec_()) def setupUi(self): self.mainWindow = QMainWindow() self.ui_MainWindow = Ui_MainWindow() self.ui_MainWindow.setupUi(self.mainWindow) self.mainWindow.show() pass
from ui.fsmainwindow import FSMainWindow from util.fslogger import FSLogger def print_help(): print("help: help") if __name__ == '__main__': logger = FSLogger.get_instance() logger.setLevel(logging.DEBUG) try: opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) # parse command line arguments for opt, arg in opts: if opt == '-h' or opt == '--help': print_help() sys.exit() else: print_help() sys.exit() except getopt.GetoptError: print_help() logger.info("Start application") APP = QApplication(sys.argv) ui = FSMainWindow() ui.show() sys.exit(APP.exec_())
def main(): app = QApplication(sys.argv) form = MainWindow() form.show() sys.exit(app.exec_())
print(k[keys[i]]) def readBasicData(self): with open(self.basicInfopath, 'r') as f: return json.load(f) def saveRecord(self, map): for j, i in enumerate(self.records): if i['recordName'] == map['recordName']: self.records[j] = map else: self.records.append(map) with open(self.recordsPath, 'w') as f: json.dump(self.records, f) def readRecord(self): with open(self.recordsPath, 'r') as f: self.records = json.load(f) # return json.dump(f) resource = Resource() # print(resource.makeMap('jjj')) if __name__ == '__main__': print(resource.mapScaleList) window = QWidget() window.show() sys.exit(Qapp.exec_())
def start(self, username=None, password=None): """ Start Alignak-app """ settings.init_config() settings.init_css() init_localization() # Logger global logger # pylint: disable=global-statement logger = create_logger() logger.name = 'alignak_app.app' if settings.get_config('Log', 'debug', boolean=True): logger.setLevel(DEBUG) else: logger.setLevel(INFO) logger.info('\n') logger.info('----- Alignak-App START -----') logger.info('- Running Version : "%s"', __version__) logger.info('- Alignak-App Env :') logger.info('[ALIGNAKAPP_APP_DIR] = %s', os.environ['ALIGNAKAPP_APP_DIR']) logger.info('[ALIGNAKAPP_USR_DIR] = %s', os.environ['ALIGNAKAPP_USR_DIR']) logger.info('[ALIGNAKAPP_LOG_DIR] = %s', os.environ['ALIGNAKAPP_LOG_DIR']) logger.info('- Config File : %s', settings.settings['settings']) logger.info('- Debug Activate : %s', settings.get_config('Log', 'debug', boolean=True)) logger.info('- Alignak Backend : %s', settings.get_config('Alignak', 'backend')) app = QApplication(sys.argv) app.setQuitOnLastWindowClosed(False) # Connection to Backend proxies = None if settings.get_config('Alignak', 'username') and not username and not password: username = settings.get_config('Alignak', 'username') password = settings.get_config('Alignak', 'password') if settings.get_config('Alignak', 'proxy'): try: # Model is: {'protocol': 'http://proxy:port'} proxies = { settings.get_config('Alignak', 'proxy').split(':')[0]: settings.get_config('Alignak', 'proxy') } except ValueError: self.show_login_window() # If Proxy user, display login window to let user enter password if settings.get_config('Alignak', 'proxy_user') and \ not settings.get_config('Alignak', 'proxy_password'): self.show_login_window() # Try login else display login window logger.info('- Proxy settings : %s', proxies) if not app_backend.login(username, password, proxies=proxies): self.show_login_window() # Create Progress Bar app_progress = AppProgressQWidget() app_progress.initialize() center_widget(app_progress) logger.info("Preparing DataManager...") while not data_manager.ready: thread_manager.launch_threads() app_progress.show() for _ in range(0, 100): t = time.time() while time.time() < t + 0.01: status = data_manager.is_ready() app_progress.progress_bar.set_text('%s' % status) app.processEvents() app_progress.close() init_event_widget() requests_interval = int( settings.get_config('Alignak-app', 'requests_interval')) * 1000 self.threadmanager_timer.setInterval(requests_interval) self.threadmanager_timer.start() self.threadmanager_timer.timeout.connect(self.check_threads) self.tray_icon = AppTrayIcon(QIcon(settings.get_image('icon'))) self.tray_icon.build_menu() self.tray_icon.show() sys.exit(app.exec_())
class Application(object): ''' classdocs ''' def __init__(self): ''' Constructor ''' # logging.config.fileConfig("logging.conf") self.log = logging.getLogger("Application") def setupModels(self): self.mongoResultModel = MongoResultModel() pass def setupSlot(self): self.ui_MainWindow.tableview.setModel(self.mongoResultModel) self.ui_MainWindow.connectBtn.clicked.connect( self.appctl.connectServer) self.ui_MainWindow.querybtn.clicked.connect(self.appctl.query) self.ui_MainWindow.query.returnPressed.connect(self.appctl.query) self.ui_MainWindow.query.textChanged.connect(self.appctl.queryChange) self.ui_MainWindow.tableview.clicked.connect(self.appctl.clickTable) self.add_query_action = QAction("add to query", self.ui_MainWindow.tableview) self.add_query_action.triggered.connect(self.appctl.addToQuery) self.ui_MainWindow.tableview.setContextMenuPolicy( Qt.ActionsContextMenu) self.ui_MainWindow.tableview.addAction(self.add_query_action) self.tableHeader = self.ui_MainWindow.tableview.horizontalHeader() self.tableHeader.setSortIndicatorShown(True) self.tableHeader.sortIndicatorChanged.connect(self.appctl.columnSort) self.ui_MainWindow.treeWidget.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) self.ui_MainWindow.treeWidget.customContextMenuRequested.connect( self.appctl.showTreeMenu) self.ui_MainWindow.prevBtn.clicked.connect(self.appctl.prevPagination) self.ui_MainWindow.nextBtn.clicked.connect(self.appctl.nextPagination) def setupCtl(self): self.appctl = AppController(self) def run(self): self.log.info("app is start") self.qtapp = QApplication(sys.argv) self.setupUi() self.setupModels() self.setupCtl() self.setupSlot() sys.exit(self.qtapp.exec_()) def setupUi(self): self.mainWindow = QMainWindow() self.ui_MainWindow = Ui_MainWindow() self.ui_MainWindow.setupUi(self.mainWindow) self.mainWindow.show() pass
def main(): app = QApplication(sys.argv) main = First() main.show() sys.exit(app.exec_())
''' Created on 13 mars 2017 @author: olinox ''' import sys from PyQt5.Qt import QApplication, QMessageBox # import ipdb from GridViewer import GridViewer if __name__ == '__main__': app = QApplication(sys.argv) iface = GridViewer() iface.show() SYS_HOOK = sys.excepthook def error_handler(typ, value, trace): QApplication.restoreOverrideCursor() QMessageBox.critical(iface, typ.__name__, "{}".format(value)) SYS_HOOK(typ, value, trace) sys.excepthook = error_handler r = app.exec_() sys.exit(r)
import sys from PyQt5.Qt import QWidget, QApplication, QPushButton, QGridLayout class Sensor(QWidget): def __init__(self, slot): super().__init__() btn = QPushButton("Send Signal") btn.setMinimumSize(200, 100) btn.pressed.connect(slot) layout = QGridLayout() layout.addWidget(btn) layout.setSpacing(20) self.setLayout(layout) self.show() pass if __name__ == '__main__': q = QApplication(sys.argv) s = Sensor(lambda: print("Pressed")) sys.exit(q.exec_())
def main(acc): app1 = QApplication(sys.argv) MW = MainW(acc) sys.exit(app1.exec_())
l2 = QLabel("Operative clause formatting:", w) l2.resize(300, 20) l2.move(10, 290) op_bold = QCheckBox("Bold", w) op_bold.move(220, 286) op_italic = QCheckBox("Italic", w) op_italic.move(280, 286) op_underlined = QCheckBox("Underlined", w) op_underlined.move(340, 286) pre = QPlainTextEdit(w) pre.setPlaceholderText("Enter preambulatory clauses") pre.move(10, 330) pre.resize(1440, 156) op = QPlainTextEdit(w) op.setPlaceholderText("Enter operative clauses") op.move(10, 496) op.resize(1440, 395) submit = QPushButton("Export", w) submit.move(10, 900) submit.clicked.connect(save) w.show() sys.exit(appctxt.exec_())
import os import sys from PyQt5.Qt import QApplication from PyQt5 import QtGui from core.ui import Window from core import Settings if __name__ == "__main__": appconf = {} conf = Settings.getInstance() QApp = QApplication(sys.argv) QApp.setObjectName("Oceana") mainWindow = Window() if not QApp.objectName() in conf: conf[QApp.objectName()] = {} appconf = conf[QApp.objectName()] appconf["x"] = mainWindow.pos().x() appconf["y"] = mainWindow.pos().y() appconf["width"] = mainWindow.width() appconf["height"] = mainWindow.height() appconf["lookandfeel"] = "native" appconf = conf[QApp.objectName()] mainWindow.setMinimumSize(appconf.as_int("width"), appconf.as_int("height")) mainWindow.show() conf.write() sys.exit(QApp.exec_())
self.portLine.setText('{}'.format(experiment.properties['Monitor']['channel'])) self.timeResolutionLine.setText(experiment.properties['Monitor']['time_resolution']) self.refreshTimeLine.setText(experiment.properties['Monitor']['refresh_time']) self.totalTimeLine.setText(experiment.properties['Monitor']['total_time']) def apply_new_values(self): """Formats the values in the form and emits a custom signal *propertiesChanged* including a dictionary of the values that are provided (changed or not). """ new_values = {'port_monitor': int(self.portLine.text()), 'time_resolution': Q_(self.timeResolutionLine.text()), 'refresh_time': Q_(self.refreshTimeLine.text()), 'total_time': Q_(self.totalTimeLine.text()),} self.propertiesChanged.emit(new_values) if __name__ == "__main__": import sys from PyQt5.Qt import QApplication ap = QApplication(sys.argv) from PythonForTheLab.Model.experiment.IV_measurement import Experiment e = Experiment() session = {'port_monitor': 1, 'time_resolution': Q_('1ms'), 'refresh_time': Q_('20ms'), 'total_time': Q_('15s')} e.properties = session m = ConfigWindow(e) m.show() ap.exit(ap.exec_())
cf.resize(int(available_width()/1.5), available_height()-60) w.resize(cf.size()+QSize(30, 20)) model = DummyImageList() cf.setImages(model) cf.setCurrentSlide(39000) w.setCentralWidget(cf) w.show() cf.setFocus(Qt.OtherFocusReason) sys.exit(app.exec_()) def main(args=sys.argv): return 0 if __name__ == '__main__': from PyQt5.Qt import QApplication, QMainWindow app = QApplication([]) w = QMainWindow() cf = CoverFlow() cf.resize(int(available_width()/1.5), available_height()-60) w.resize(cf.size()+QSize(30, 20)) path = sys.argv[1] model = FileSystemImages(sys.argv[1]) cf.currentChanged[int].connect(model.currentChanged) cf.setImages(model) w.setCentralWidget(cf) w.show() cf.setFocus(Qt.OtherFocusReason) sys.exit(app.exec_())
@property def text(self): return unicode(self.edit.text()) @property def xpath(self): return self.text def check(self): from calibre.ebooks.oeb.base import XPNSMAP from lxml.etree import XPath try: if self.text.strip(): XPath(self.text, namespaces=XPNSMAP) except: import traceback traceback.print_exc() return False return True if __name__ == '__main__': from PyQt5.Qt import QApplication app = QApplication([]) w = XPathEdit() w.setObjectName('test') w.show() app.exec_() print w.xpath
"""Main entry point""" import os from PyQt5.Qt import QApplication import qdarkstyle from gui.prime import Prime APP = QApplication([]) APP.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) P = Prime() os._exit(APP.exec_()) # pylint: disable=W0212
def main(): app = QApplication(sys.argv) window = YouTubeWindow() window.setWindowIcon(QtGui.QIcon(scriptDir + os.path.sep + 'logo.png')) window.show() app.exec_()
def main(): app = QApplication(sys.argv) print('Loading Game...') window = MainWindow(app) window.show() sys.exit(app.exec_())
def run_loop(self): self.block_signal_handlers() try: return QApplication.exec_() finally: self.restore_signal_handlers()
self.count() self.showList() def count(self): initial = int(self.begginingValue.text()) end = int(self.endValue.text()) step = int(self.stepValue.text()) step *= -1 if initial > end else 1 end += -1 if initial > end else 1 self.numbers = range(initial, end, step) def showList(self): self.resultList.clear() for number in self.numbers: if (self.getFilterCallback()(number)): self.resultList.addItem(str(number)) def getFilterCallback(self): return self.filterOptions[self.filterCombo.currentIndex()] if __name__ == "__main__": qt = QApplication(sys.argv) app = App() app.show() qt.exec_()
if self.toolbar_prefs_name is not None: gprefs.set(self.toolbar_prefs_name, visible) @property def toolbars_visible(self): return self.toolbar1.isVisible() or self.toolbar2.isVisible( ) or self.toolbar3.isVisible() @toolbars_visible.setter def toolbars_visible(self, val): getattr(self, ('show' if val else 'hide') + '_toolbars')() def set_readonly(self, what): self.editor.set_readonly(what) def hide_tabs(self): self.tabs.tabBar().setVisible(False) # }}} if __name__ == '__main__': app = QApplication([]) w = Editor() w.resize(800, 600) w.show() w.html = '''<span style="background-color: rgb(0, 255, 255); ">He hadn't set out to have an <em>affair</em>, <span style="font-style:italic; background-color:red">much</span> less a long-term, devoted one.</span>''' app.exec_() # print w.html
class BrowserProcess(Process): def __init__(self, url, display_time, refresh=False, autoscroll=True): super(Process, self).__init__() self.url = url self.display_time = display_time self.refresh = refresh self.autoscroll = autoscroll self.browser = None self.queue = Queue() self.response_queue = Queue() def command_thread(self): while True: time.sleep(0.1) if not self.queue.empty(): command = self.queue.get() if command == 'show': if not pikake.config['debug']: self.browser.setFocus() self.browser.activateWindow() self.browser.mainFrame.setScrollBarValue(Qt.Vertical, 0) elif command == 'get_attrs': attrs = self.browser.get_attrs() self.response_queue.put(attrs) elif command == 'reload': if self.browser.refresh: self.browser.refresh_signal.emit() elif command == 'pause_scrolling': self.browser.pause_scrolling() elif command == 'resume_scrolling': if self.browser.autoscroll: self.browser.resume_scrolling() def scrolling_thread(self): down = True mainFrame = self.browser.mainFrame while self.browser.must_run: while not self.browser.must_wait and self.browser.must_run: time.sleep(0.03) pos = mainFrame.scrollBarValue(Qt.Vertical) min_ = mainFrame.scrollBarMinimum(Qt.Vertical) max_ = mainFrame.scrollBarMaximum(Qt.Vertical) if pos == max_: down = False elif pos == min_: down = True self.browser.scroll_signal.emit(down) def run(self): self.browser_app = QApplication(sys.argv) self.browser = Browser(self.url, self.display_time, self.refresh, self.autoscroll) self.browser.show() # Let time to apply fullscreen properly time.sleep(random.random()) if not pikake.config['debug']: self.browser.showFullScreen() t = Thread(target=self.command_thread) t.start() self.scroll_thread = Thread(target=self.scrolling_thread) self.scroll_thread.start() self.browser_app.exec_()
def main(args): app = QApplication(sys.argv) form = MicroDAQviewer_live(args) form.show() app.aboutToQuit.connect(form.disconnect) app.exec_()
def keyPressEvent(self, key_event): code = key_event.key() char = key_event.text() print(f"{code}:{char}") if code == 32: #space char = '<span style="font-size: 22px;"> </span>' elif code == 75 and self.exercise.current_char == '\n': # enter char = '<span>' elif self.exercise.current_char != char: char = f'<span style="color: #ff0000; font-size: 22px;">{char}</span>' else: self.exercise.add_passes() char = f'<span style="color: #0000ff; font-size: 22px;">{char}</span>' self.exercise.next_char() self.typed(char) print(self.exercise.live_score) def typed(self, char): self.typing_area.insertHtml(char) if __name__ == '__main__': qapp = QApplication(sys.argv) app = Canvas( Exercise( "exercise 1", 'lfjal jflas kjfa ljoiewr a fdsalk ja<br>Hivi kwa nini hunipendi')) app.setGeometry(200, 300, 500, 600) app.show() sys.exit(qapp.exec_())
#coding:utf-8 from PyQt5.Qt import QWidget, QApplication, QFileDialog, QTime from PyQt5.QtWidgets import QMessageBox from Project import Ui_form import pymysql import xlrd import sys class landingpanel(QWidget, Ui_form): # 定义变量 tablename = 'tablename' rdfile = 'rdfile' conn = '' def __init__(self): super().__init__() self.setupUi(self) # 绑定函数 self.pushButton_connect.clicked.connect(self.mysqlconnect) self.pushButton.clicked.connect(self.open) self.pushButton_2.clicked.connect(self.to_mysql) self.listWidget.clicked.connect(self.set_tobtn) self.pushButton_disconnected.clicked.connect(self.mysqldisconnect) # 按钮初始化 self.pushButton.setEnabled(False) #打开按钮 self.pushButton_2.setEnabled(False) #导入按钮 self.pushButton_disconnected.setEnabled(False) #断开按钮 def mysqlconnect(self): # 连接数据库 dbhost = self.lineEdit_name.text() dbport = int(self.lineEdit_port.text())
def main(): app = QApplication(sys.argv) window = PrettyWidget() window.show() sys.exit(app.exec_())