def initUI(self): self.setObjectName(u"closeBtn") sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setMinimumSize(QSize(40, 0)) self.setMaximumSize(QSize(40, 16777215)) self.setStyleSheet(u"QPushButton {" "border: none;" "background-color: transparent;" "}" "QPushButton:hover {" "background-color: rgb(52, 59, 72);" "}" "QPushButton:pressed {" "background-color: rgb(85, 170, 255);" "}" "QToolTip {" "color:white;" "background-color: black;" "border: black solid 1px;" "}") icon = QIcon() icon.addFile(resource_path("icons/cil-x.png"), QSize(), QIcon.Normal, QIcon.Off) self.setIcon(icon) self.setToolTip("Close") self.setContentsMargins(0, 0, 0, 0)
def main(): """Run Halo Wars Casting Tool.""" from hwctool.view.main import MainWindow from PyQt5.QtCore import QSize from PyQt5.QtGui import QIcon translator = None os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" currentExitCode = MainWindow.EXIT_CODE_REBOOT while currentExitCode == MainWindow.EXIT_CODE_REBOOT: try: hwctool.settings.loadSettings() app = QApplication(sys.argv) app.setAttribute(Qt.AA_EnableHighDpiScaling) app.setStyle(QStyleFactory.create('Fusion')) translator = choose_language(app, translator) icon = QIcon() icon.addFile(hwctool.settings.getResFile('hwct.ico'), QSize(32, 32)) app.setWindowIcon(icon) showChangelog, updater = initial_download() if updater: hwctool.settings.loadSettings() main_window(app, showChangelog) currentExitCode = app.exec_() app = None except Exception as e: logger.exception("message") break sys.exit(currentExitCode)
def initUI(self): #icon app_icon = QIcon() app_icon.addFile("key.png", QSize(256, 256)) self.setWindowIcon(app_icon) #text preview self.Gen = self.parent.getGen() self.preview = QTextEdit() self.preview.setReadOnly(True) #gui elements pntBtn = QPushButton("Print", self) pntBtn.clicked.connect(self.printMKS) previewBtn = QPushButton("Preview", self) previewBtn.clicked.connect(self.previewMKS) #showBittings = QCheckBox("Master Bittings") #showTitlePage = QCheckBox("Title Page") showContact = QCheckBox("Contact Information") showContact.setEnabled(False) vert = QVBoxLayout() self.setLayout(vert) #vert.addWidget(showBittings) #vert.addWidget(showTitlePage) vert.addWidget(showContact) vert.addWidget(self.preview) vert.addWidget(pntBtn) vert.addWidget(previewBtn) self.setGeometry(300, 300, 290, 150) self.setWindowTitle('Print') self.formatPrint() self.show()
def setup_systray(self) -> None: icons = {} for state in { "conflict", "disabled", "error", "idle", "notification", "paused", "syncing", "update", }: name = "{}{}.svg".format(state, "_light" if WINDOWS else "") icon = QIcon() icon.addFile(find_icon(name)) if MAC: icon.addFile(find_icon("active.svg"), mode=QIcon.Selected) icons[state] = icon setattr(self, "icons", icons) self.tray_icon = DriveSystrayIcon(self) if not self.tray_icon.isSystemTrayAvailable(): log.critical("There is no system tray available!") else: self.tray_icon.setToolTip(self.manager.app_name) self.set_icon_state("disabled") self.tray_icon.show()
def run(): directory = os.path.dirname(os.path.abspath(__file__)) appIcon = QIcon() appIcon.addFile(os.path.join(directory, "python.png"), QSize(64, 64)) app.setWindowIcon(appIcon) from . import registerQmlTypes registerQmlTypes() engine = QQmlApplicationEngine() context = QQmlContext(engine) mainQml = QUrl.fromLocalFile(os.path.join(directory, "Main.qml")) component = QQmlComponent(engine) component.loadUrl(mainQml) if component.isError(): for error in component.errors(): print("Error: ", error.toString()) dialog = component.create(context) return app.exec_()
def load_toggle_icon(on: str, off: str) -> QIcon: """ Add the contents of Scalable Vector Graphics (SVG) files provided for associated icon states, see https://doc.qt.io/qt-5/qicon.html#State-enum. Parameters ---------- on: str file name to the on-state image off: str file name to the on-state image Returns ------- QIcon The icon that displays the contents of the SVG files. """ icon = QIcon() icon.addFile(path(on), state=QIcon.On) icon.addFile(path(off), state=QIcon.Off) return icon
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" icon_path = ':/plugins/gwr/icon.png' self.add_action( icon_path, text=self.tr(u'gwr'), callback=self.run, parent=self.iface.mainWindow()) formIcon = QIcon() formIcon.addFile(self.tr(":/plugins/gwr/icons/earth.png")) self.dlg.setWindowIcon(formIcon) openFileIcon = QIcon() openFileIcon.addFile(self.tr(":/plugins/gwr/icons/download.svg")) self.dlg.pushButton_OpenFile.setIcon(openFileIcon) self.dlg.pushButton_OpenFile.setIconSize(QSize(23, 23)) refreshIcon = QIcon() refreshIcon.addFile(self.tr(":/plugins/gwr/icons/action_refresh.png")) self.dlg.pushButton_Refresh.setIcon(refreshIcon) self.dlg.pushButton_Refresh.setIconSize(QSize(23, 23)) actionIcon = QIcon() actionIcon.addFile(self.tr(":/plugins/gwr/icons/mActionSetProjection.svg")) self.dlg.pushButton_Run.setIcon(actionIcon) cancelIcon = QIcon() cancelIcon.addFile(self.tr(":/plugins/gwr/icons/cancel.svg")) self.dlg.pushButton_Exit.setIcon(cancelIcon) self.dlg.comboBox_VectorLayers.currentIndexChanged.connect(self.selectLayerChanged) self.dlg.pushButton_OpenFile.clicked.connect(self.openFile) self.dlg.pushButton_Run.clicked.connect(self.runGwr) self.dlg.pushButton_Refresh.clicked.connect(self.refreshLayersList) self.dlg.listWidget_Independents.setSelectionMode(QAbstractItemView.ExtendedSelection) self.refreshLayersList()
def main(): """Run StarCraft Casting Tool.""" from scctool.view.main import MainWindow from PyQt5.QtCore import QSize from PyQt5.QtGui import QIcon translator = None currentExitCode = MainWindow.EXIT_CODE_REBOOT while currentExitCode == MainWindow.EXIT_CODE_REBOOT: try: scctool.settings.loadSettings() app = QApplication(sys.argv) app.setStyle(QStyleFactory.create('Fusion')) translator = choose_language(app, translator) icon = QIcon() icon.addFile(scctool.settings.getResFile('scct.ico'), QSize(32, 32)) app.setWindowIcon(icon) showChangelog, updater = initial_download() if updater: scctool.settings.loadSettings() main_window(app, showChangelog) currentExitCode = app.exec_() app = None except Exception as e: logger.exception("message") break sys.exit(currentExitCode)
def customDialog(self): """Custom donate dialog""" size = QSize(256, 256) self.ui.labelWechat.setFixedWidth(size.width()) self.ui.labelAlipay.setFixedWidth(size.width()) # self.ui.btnIconWechat.setStyleSheet('QPushButton:focus {border: none;outline: none;}') # self.ui.btnIconAlipay.setStyleSheet('QPushButton:focus {border: none;outline: none;}') iconWx = QIcon() iconWx.addFile(ResourcePath("assets/images/susan-wechat-256.jpg")) self.ui.btnIconWechat.setIcon(iconWx) self.ui.btnIconWechat.setIconSize(size) self.ui.btnIconWechat.setFixedSize(size) iconAli = QIcon() iconAli.addFile(ResourcePath("assets/images/susan-alipay-256.jpg")) self.ui.btnIconAlipay.setIcon(iconAli) self.ui.btnIconAlipay.setIconSize(size) self.ui.btnIconAlipay.setFixedSize(size) self.ui.btnClose.setIcon(self.style().standardIcon( QStyle.SP_DialogApplyButton))
def get_app_icon(icon_name, widget): dark = bool(widget.palette().brush( 2, QPalette.WindowText).color().lightness() > 128) icon = QIcon.fromTheme(icon_name) if icon.isNull(): for ext in ('svg', 'svgz', 'png'): filename = ":app_icons/%s.%s" % (icon_name, ext) darkname = ":app_icons/dark/%s.%s" % (icon_name, ext) if dark and QFile.exists(darkname): filename = darkname if QFile.exists(filename): del icon icon = QIcon() icon.addFile(filename) break if icon.isNull(): for path in ('/usr/local', '/usr', '%s/.local' % os.getenv('HOME')): for ext in ('png', 'svg', 'svgz', 'xpm'): filename = "%s/share/pixmaps/%s.%s" % (path, icon_name, ext) if QFile.exists(filename): del icon icon = QIcon() icon.addFile(filename) break return icon
def add_new_tab(self, session_name, show_close_btn=True): """ Add a new tab in the tab widget :param session_name: name to be displayed :param show_close_btn: if true we add the close button :return: """ new_tab = QSSHSessionWidget(self) uuid = new_tab.uuid self.tabs.addTab(new_tab, session_name) if show_close_btn: kill_btn = QPushButton() kill_btn.setIcon(self.style().standardIcon( QStyle.SP_DialogCloseButton)) kill_btn.clicked.connect(lambda: self.on_close(uuid)) kill_btn.setToolTip('Close session') self.tabs.tabBar().setTabButton(self.tabs.count() - 1, QTabBar.RightSide, kill_btn) else: kill_btn = QPushButton() ico = QIcon() ico.addFile(resource_path('gui/icons/plus.png')) kill_btn.setIcon(ico) kill_btn.clicked.connect(self.on_new) kill_btn.setToolTip('New session') self.tabs.tabBar().setTabButton(self.tabs.count() - 1, QTabBar.RightSide, kill_btn) new_tab.logged_in.connect(self.on_login) new_tab.sessions_changed.connect(self.on_sessions_changed) logger.debug("Added new tab " + str(uuid))
def _initialize_app(self) -> None: self.app = QApplication(sys.argv) self.app.setApplicationName("Voorspelling") icons = QIcon() for data in ui_icons.values(): icons.addFile(data["Path"], QSize(data["Size"], data["Size"])) self.app.setWindowIcon(icons)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1000, 700) MainWindow.setStyleSheet( qdarkgraystyle.load_stylesheet() + 'QPlainTextEdit {selection-background-color: white}') icon = QIcon() icon.addFile('../Images/python.png', QSize(256, 256)) MainWindow.setWindowIcon(icon) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout_2.setObjectName("gridLayout_2") self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) self.tabWidget.setObjectName("tabWidget") self.tab = GeneralWidget() self.tabWidget.addTab(self.tab, "") self.gridLayout_2.addWidget(self.tabWidget, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.actionnewAction = QtWidgets.QAction(MainWindow) self.actionnewAction.setObjectName("actionnewAction") self.tabWidget.setTabsClosable(True) self.retranslateUi(MainWindow) self.tabWidget.setCurrentIndex(0) self.tabWidget.tabBarDoubleClicked['int'].connect(self.addTab) self.tabWidget.tabCloseRequested['int'].connect(self.tab_close) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def getAppIcon(icon_name, widget, addSearchPaths=[]): dark = bool(widget.palette().brush( 2, QPalette.WindowText).color().lightness() > 128) icon = QIcon.fromTheme(icon_name) if icon.isNull(): for ext in ('svg', 'svgz', 'png'): filename = ":app_icons/%s.%s" % (icon_name, ext) darkname = ":app_icons/dark/%s.%s" % (icon_name, ext) if dark and QFile.exists(darkname): filename = darkname if QFile.exists(filename): del icon icon = QIcon() icon.addFile(filename) break else: for path in addSearchPaths: for ext in ('svg', 'svgz', 'png'): filename = "%s/%s.%s" % (path, icon_name, ext) darkname = "%s/dark/%s.%s" % (path, icon_name, ext) if dark and QFile.exists(darkname): filename = darkname if QFile.exists(filename): del icon icon = QIcon() icon.addFile(filename) break return icon
def load_icons_set(self, use_light_icons: bool = False) -> None: """Load a given icons set (either the default one "dark", or the light one).""" if self.use_light_icons is use_light_icons: return suffix = ("", "_light")[use_light_icons] mask = str(find_icon("active.svg")) # Icon mask for macOS for state in { "conflict", "disabled", "error", "idle", "notification", "paused", "syncing", "update", }: icon = QIcon() icon.addFile(str(find_icon(f"{state}{suffix}.svg"))) if MAC: icon.addFile(mask, mode=QIcon.Selected) self.icons[state] = icon self.use_light_icons = use_light_icons self.manager.set_config("light_icons", use_light_icons) # Reload the current showed icon if self.icon_state: self.set_icon_state(self.icon_state, force=True)
def customDialog(self): """Custom about dialog""" size = QSize(128, 128) icon = QIcon() icon.addFile(ResourcePath("assets/images/logo128.png")) self.ui.btnLogo.setIcon(icon) self.ui.btnLogo.setIconSize(size) self.ui.btnLogo.setFixedSize(size) name = "{}: {}".format(self.config.get("name"), self.config.get("version", "1.0")) self.ui.labelVersion.setText(name) email = self.config.get("email") self.ui.labelMailAddress.setText( f' <a href="mailto:{email}">{email}</a>') url = self.config.get("website") self.ui.labelHomeUrl.setText(f' <a href="{url}">{url}</a>') url = self.config.get("issue") self.ui.labelIssueUrl.setText(f' <a href="{url}">{url}</a>') self.ui.btnClose.setIcon(self.style().standardIcon( QStyle.SP_DialogApplyButton))
def search_dipendente(self): if self.vista_lista_dipendente.barra_ricerca.text() == "": self.vista_lista_dipendente.error.setText( "La barra di ricerca e' vuota") else: self.vista_lista_dipendente.error.setText("") self.vista_lista_dipendente.list_dipendenti.setSortingEnabled( False) cont = 0 for dipendente in self.controllerdip.modeldip.listdipendent: searcheditem = self.vista_lista_dipendente.list_dipendenti.item( cont) searcheditem.setBackground(QColor(255, 255, 255, 255)) cont += 1 items = self.vista_lista_dipendente.list_dipendenti.findItems( self.vista_lista_dipendente.barra_ricerca.text(), Qt.MatchContains) if items == []: self.vista_lista_dipendente.error.setText( "Non e' stato torvato nessun dipendente") else: for item in items: dip = self.vista_lista_dipendente.list_dipendenti.takeItem( self.vista_lista_dipendente.list_dipendenti.row(item)) self.vista_lista_dipendente.list_dipendenti.insertItem( 0, dip.text()) searchitem = self.vista_lista_dipendente.list_dipendenti.item( 0) searchitem.setBackground(QColor(0, 242, 255, 255)) icon = QIcon() icon.addFile("images/Dipendente-Icon.png", QSize(), QIcon.Normal, QIcon.Off) item = self.vista_lista_dipendente.list_dipendenti.item(0) item.setIcon(icon)
def __init__(self, setToLoad=None): super(SolutionBrowser, self).__init__() # parse config self.parse_config() # overwrite default set if provided if setToLoad: self.default_set = setToLoad # set size mainwindow self.setWindowTitle('Solution Browser') self.resize(self.hsize, self.vsize) if self.isStartMaximized: self.setWindowState(Qt.WindowMaximized) font = QFont() font.setPointSize(10) self.setFont(font) # icon app_icon = QIcon() app_icon.addFile(os.path.join('icons', 'icon256.png'), QSize(256, 256)) app_icon.addFile(os.path.join('icons', 'icon128.png'), QSize(128, 128)) self.setWindowIcon(app_icon) # statusbar self.statusbar = self.statusBar() self.statusbar_style_alert = "QStatusBar{font-size:10pt;background:rgba(250, 128, 114, 1);color:black;font-weight:bold;}" self.statusbar_style_normal = "QStatusBar{font-size:10pt;color:black;font-weight:bold;}" self.statusbar.setStyleSheet(self.statusbar_style_normal) self.statusbar.showMessage('Starting SolutionBrowser') # load layout top and bottom frames self.layouts = SolutionBrowserLayout(self) self.setCentralWidget(self.layouts) self.createActions() self.createMenus() # create par dialog self.parDialogOpen = False self.parDialog = ParDialog(self) # get frames for easy reference. self.ImageViewerFrame = self.layouts.ImageViewerFrame self.ParameterFrame = self.layouts.ParameterFrame self.ParameterFrame.setFont(font) # start image viewer self.setup_image_viewer() # load default image self.open_image('default.jpg') # start parameter selection tool self.setup_parameter_selector() # ahk to communicate with matlab if AHK: self.ahk = AHK(executable_path=self.ahk_executable_path)
def add_taskbar_icon(app): from PyQt5.QtGui import QIcon app_icon = QIcon() from PyQt5.QtCore import QSize icon_path = os.path.join(os.path.abspath(""), "src", "ui", "images", "main_icon.png") app_icon.addFile(icon_path, QSize(1600, 1600)) app.setWindowIcon(app_icon)
def __init__(self): super(MainWindow, self).__init__() status_bar = QStatusBar(self) self.setStatusBar(status_bar) self.setDockNestingEnabled(True) self.setWindowTitle(self._projectNameTemplate.format(self._noProjectText)) self.debugger = QtNetworkDebugManager() self.debugger.on_closed_session.subscribe(self._onClosedDebugSession) self.debugger.on_created_session.subscribe(self._onCreatedDebugSession) # Add tab widget self.tab_widget = TabViewWidget() self.setCentralWidget(self.tab_widget) self.tab_widget.onTabChanged.connect(self._onTabChanged) self.tab_widget.checkTabClosable = self._checkTabClosable # Show current hives self._project_hives_active_widget = TreeWidget() self._project_hives_active_widget.onDoubleClick.connect(self._openProjectHive) self._project_hives_inactive_widget = QLabel("No project active") self._project_hives_inactive_widget.setAlignment(Qt.AlignCenter) self._project_hives_window = self.createSubwindow("Project", "right", widget=self._project_hives_inactive_widget) self.hive_finder = HiveFinder() self._current_hive_list = None self._projectDirectory = None self._project_context = None self.updateLoadedHives() self._setupMenus() self._clipboard = None # Set application icon icon = QIcon() file_path = os.path.join(os.path.dirname(__file__), "../hive.png") icon.addFile(file_path) self.setWindowIcon(icon) # Add Help page web_view = QEditorWebView() web_view.onDragMove.connect(self._filterWebDrop) web_view.onDropped.connect(self._onDropped) url = QUrl("http://agoose77.github.io/hive2/") web_view.setUrl(url) # Load home page self._web_view = web_view self.tab_widget.addTab(web_view, "About", closeable=False)
def add_icon(self): cont = 0 for dipendente in self.controllerdip.modeldip.listdipendent: icon = QIcon() icon.addFile("images/Dipendente-Icon.png", QSize(), QIcon.Normal, QIcon.Off) item = self.vista_lista_dipendente.list_dipendenti.item(cont) item.setIcon(icon) cont += 1
def __init__(self): super().__init__() self.setCheckable(True) ico = QIcon() ico.addFile('../Icons/future_off.png', mode=QIcon.Selected, state=QIcon.Off) ico.addFile('../Icons/future_on.png', mode=QIcon.Selected, state=QIcon.On) self.setIcon(ico) self.setIconSize(QSize(60, 60)) self.setFixedSize(60, 60)
class my_window(QWidget): def __init__(self, parent): super().__init__(parent) def initUI(self, w_factor, h_factor): self.size_window(w_factor, h_factor) self.centre_window() self.define_colors() self.color_window() self.add_widgets() def determine_geometry(self): self.geo = QDesktopWidget().availableGeometry() def add_icon(self, string): self.icon = QIcon() self.icon.addFile(string) self.setWindowIcon(self.icon) def define_colors(self): self.window_color = "#DEDEDE" self.rocket_red = "#C20024" self.grey = "#4D4D4D" def color_window(self): pal = QPalette() my_window_color = QColor() my_window_color.setNamedColor(self.window_color) pal.setColor(QPalette.Window, my_window_color) self.setPalette(pal) def size_window(self, w_factor, h_factor): self.w = self.geo.width() / w_factor self.h = self.geo.height() / h_factor self.resize(self.w, self.h) def centre_window(self): centre = self.geo.center() x = centre.x() y = centre.y() self.move(x - self.w / 2, y - self.h / 2) def create_grid(self): self.grid = QGridLayout() self.setLayout(self.grid) def animate_svg(self, svg_image): svg_image.opac_eff = QGraphicsOpacityEffect() svg_image.setGraphicsEffect(svg_image.opac_eff) svg_image.animation = QPropertyAnimation(svg_image.opac_eff, b"opacity") svg_image.animation.setDuration(2000) svg_image.animation.setStartValue(0.1) svg_image.animation.setEndValue(1) svg_image.animation.setEasingCurve(QEasingCurve.OutCirc) svg_image.animation.start()
def add_dipendente(self, modello): self.vista_lista_dipendente.list_dipendenti.addItem(modello.cognome + " " + modello.nome) items = self.vista_lista_dipendente.list_dipendenti.findItems( modello.cognome, Qt.MatchContains) for item in items: icon = QIcon() icon.addFile("images/Dipendente-Icon.png", QSize(), QIcon.Normal, QIcon.Off) item.setIcon(icon)
def __init__( self, protocols=[], metadata_animal=None, metadata_general=None, camera_config=None, display_config=None, tracking_config=None, recording_config=None, embedded=True, trigger=None, asset_dir=None, dir_save=None, record_stim_every=None, ): app = QApplication([]) class_kwargs = dict( app=app, dir_save=dir_save, asset_directory=asset_dir, rec_stim_every=record_stim_every, metadata_animal=metadata_animal, metadata_general=metadata_general, display_config=display_config, protocols=protocols, trigger=trigger, calibrator=(CircleCalibrator() if not embedded else None), ) base = Experiment if camera_config is not None: base = CameraExperiment class_kwargs["camera_config"] = camera_config if tracking_config is not None: class_kwargs["tracking_config"] = tracking_config base = TrackingExperiment if recording_config is not None: base = SwimmingRecordingExperiment app_icon = QIcon() for size in [32, 64, 128, 256]: app_icon.addFile( pkg_resources.resource_filename(__name__, "/icons/{}.png".format(size)), QSize(size, size)) app.setWindowIcon(app_icon) exp = base(**class_kwargs) exp.start_experiment() app.exec_()
def _set_window_icons(self) -> None: """ Set the window icons """ path_cur = os.path.dirname(os.path.abspath(__file__)) path_img = os.path.join(path_cur, "..", "assets", "images") app_icon = QIcon() for width in [16, 24, 32, 48, 256]: icon_path = os.path.join(path_img, f"favicon-{width}x{width}.png") app_icon.addFile(icon_path, QSize(width, width)) self.setWindowIcon(app_icon)
def main(argv=None): from PyQt5.QtWidgets import QApplication from PyQt5.QtGui import QIcon from PyQt5.QtCore import QSize from pyboat.ui import start_menu # --- initialize the Qt App --- # args get not parsed inside Qt app app = QApplication(sys.argv) # add an application icon abs_path = os.path.dirname(os.path.realpath(__file__)) icon_path = os.path.join(abs_path, 'logo_circ128x128.png') icon = QIcon() icon.addFile(icon_path, QSize(128, 128)) app.setWindowIcon(icon) # needed for QSettings app.setOrganizationName("tensionhead") app.setOrganizationDomain("https://github.com/tensionhead") app.setApplicationName("pyBOAT") # -- parse command line arguments --- parser = argparse.ArgumentParser() parser.add_argument('--debug', action='store_true') parser.add_argument('--version', action='version', version='pyBOAT ' + __version__) args = parser.parse_args(argv) debug = args.debug if debug: print(''' --------------- DEBUG enabled!! --------------- ''') screen = app.primaryScreen() print('Screen: %s' % screen.name()) size = screen.size() print('Size: %d x %d' % (size.width(), size.height())) rect = screen.availableGeometry() print('Available: %d x %d' % (rect.width(), rect.height())) # this starts up the Program window = start_menu.MainWindow(debug) return app.exec()
def main(argv=None): # import PyQt only here, no need to # generally import if only # scripting is needed.. from PyQt5.QtWidgets import QApplication from PyQt5.QtGui import QIcon from PyQt5.QtCore import QSize from pyboat.ui import start_menu # --- initialize the Qt App --- # args get not parsed inside Qt app app = QApplication(sys.argv) # add an application icon abs_path = os.path.dirname(os.path.realpath(__file__)) icon_path = os.path.join(abs_path, 'logo_circ128x128.png') icon = QIcon() icon.addFile(icon_path, QSize(128, 128)) app.setWindowIcon(icon) # -- parse command line arguments --- parser = argparse.ArgumentParser() parser.add_argument('--debug', action='store_true') parser.add_argument('--version', action='version', version='pyBOAT ' + __version__) args = parser.parse_args(argv) debug = args.debug if debug: print(''' ---------------- DEBUG enabled!! --------------- ''') screen = app.primaryScreen() print('Screen: %s' % screen.name()) size = screen.size() print('Size: %d x %d' % (size.width(), size.height())) rect = screen.availableGeometry() print('Available: %d x %d' % (rect.width(), rect.height())) window = start_menu.MainWindow(debug) sys.exit(app.exec_())
def _icon_from_project_directory(cls) -> QIcon: # pragma: no cover # Async """Try to retrieve the icon from the icons folder. Useful if vimiv was not installed but is used from the git project. """ icon = QIcon() file_dir = os.path.realpath(os.path.dirname(__file__)) project_dir = os.path.dirname(file_dir) icon_dir = os.path.join(project_dir, "icons") for size in (16, 32, 64, 128, 256, 512): path = os.path.join(icon_dir, f"vimiv_{size}x{size}.png") icon.addFile(path) return icon
def complete_icon(name): global complete_icons try: return complete_icons[name] except: nnic = QIcon() for size in (12, 16, 22, 24, 32, 48, 64, 72, 80, 128, 256, "scalable"): ic = icon(name + (".png" if size != "scalable" else ".svg"), size) try: nnic.addFile(ic) except: pass try: nic = QIcon().fromTheme(name, nnic) except: nic = nnic complete_icons[name] = nic return complete_icons[name]
def __init__(self, arg_list=[]): super().__init__(arg_list) # https://stackoverflow.com/a/1552105/146574 myappid = u'brunsgen.panosphere.0.1' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) # https://stackoverflow.com/a/21330349/146574 but it did not work for me app_icon = QIcon() for s in (16, 24, 32, 48, 64, 128, 256): icon_file = pkg_resources.resource_filename( 'wiggle.app.panosphere.images', f'PanosphereIcon{s}.png') app_icon.addFile(icon_file, QSize(s, s)) self.setWindowIcon(app_icon) self.main_window = MainWindow() self.main_window.show()
def __init__(self): super().__init__() self.setWindowTitle("Shutdowner") self.setGeometry(350, 150, 400, 200) # Set Window icon app_icon = QIcon() app_icon.addFile('icon.ico', QSize(64, 64)) self.setWindowIcon(app_icon) self.scheduled_actions = [] self.widgets() self.layouts() self.show()
def run(): app = QApplication(sys.argv) app.setOrganizationName("manuskript") app.setOrganizationDomain("www.theologeek.ch") app.setApplicationName("manuskript") app.setApplicationVersion(_version) icon = QIcon() for i in [16, 31, 64, 128, 256, 512]: icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i))) qApp.setWindowIcon(icon) app.setStyle("Fusion") # Load style from QSettings settings = QSettings(app.organizationName(), app.applicationName()) if settings.contains("applicationStyle"): style = settings.value("applicationStyle") app.setStyle(style) # Translation process locale = QLocale.system().name() appTranslator = QTranslator() # By default: locale translation = appPath( os.path.join("i18n", "manuskript_{}.qm".format(locale))) # Load translation from settings if settings.contains("applicationTranslation"): translation = appPath( os.path.join("i18n", settings.value("applicationTranslation"))) print("Found translation in settings:", translation) if appTranslator.load(translation): app.installTranslator(appTranslator) print(app.tr("Loaded translation: {}.").format(translation)) else: print( app.tr("Warning: failed to load translator for locale {}..."). format(locale)) QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")]) QIcon.setThemeName("NumixMsk") # qApp.setWindowIcon(QIcon.fromTheme("im-aim")) # Seperating launch to avoid segfault, so it seem. # Cf. http://stackoverflow.com/questions/12433491/is-this-pyqt-4-python-bug-or-wrongly-behaving-code launch()
def initUI(self): self.layout = QSplitter() self.in_layout = QVBoxLayout() self.table = QTableWidget() self.headers = ['Class', 'Title', 'Amazon', 'Bookstore', 'Edition', 'ISBN', 'Publisher', 'Author', 'Suggested Retail Price', 'Comments', 'Required'] self.table.setColumnCount(len(self.headers)) self.table.setHorizontalHeaderLabels(self.headers) self.table.cellDoubleClicked.connect(self.tableClicked) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # self.table.verticalHeader().setSectionResizeMode(QHeaderView.Stretch) self.le = [] for i in range(5): self.le.append(QLineEdit(self)) self.table.setRowCount(len(self.le)) #self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.submit_btn = QPushButton('Submit', self) self.submit_btn.clicked.connect(self.submit) self.add_btn = QPushButton('+', self) self.add_btn.clicked.connect(self.add_le) self.rm_btn = QPushButton('-', self) self.rm_btn.clicked.connect(self.rm_le) self.btn_layout = QHBoxLayout() self.in_layout.addWidget(self.submit_btn) self.btn_layout.addWidget(self.add_btn) self.btn_layout.addWidget(self.rm_btn) self.in_layout.addLayout(self.btn_layout) for l in self.le: l.textChanged.connect(self.textChanged) self.in_layout.addWidget(l) self.regex = re.compile("^[A-Z]{2,4}-\d{4}(?:-\d{2})?$") lside = QWidget(self) lside.setLayout(self.in_layout) self.layout.addWidget(lside) self.tab = QTabWidget(self) self.tab.addTab(self.table, 'Books') self.calendar = WeekView() self.tab.addTab(self.calendar, 'Calendar') self.layout.addWidget(self.tab) l = QVBoxLayout() l.addWidget(self.layout) self.setLayout(l) app_icon = QIcon() app_icon.addFile('tulsa.jpg') self.setWindowIcon(app_icon) self.setGeometry(300, 300, 800, 600) self.setWindowTitle('Tulsa class info') self.show()
def paint_grid_button(button, field_color): """Paints the button with the desired color. :param button: an instance of type QPushButton :param field_color: a string pointing to a correct image file in the resources """ icon = QIcon() icon.addFile(style.IMAGE_RESOURCE_ROOT + field_color, QSize(), QIcon.Normal, QIcon.Off) button.setIcon(icon)
def run(): app = QApplication(sys.argv) app.setOrganizationName("manuskript") app.setOrganizationDomain("www.theologeek.ch") app.setApplicationName("manuskript") app.setApplicationVersion(_version) icon = QIcon() for i in [16, 31, 64, 128, 256, 512]: icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i))) qApp.setWindowIcon(icon) app.setStyle("Fusion") # Load style from QSettings settings = QSettings(app.organizationName(), app.applicationName()) if settings.contains("applicationStyle"): style = settings.value("applicationStyle") app.setStyle(style) # Translation process locale = QLocale.system().name() appTranslator = QTranslator() # By default: locale translation = appPath(os.path.join("i18n", "manuskript_{}.qm".format(locale))) # Load translation from settings if settings.contains("applicationTranslation"): translation = appPath(os.path.join("i18n", settings.value("applicationTranslation"))) print("Found translation in settings:", translation) if appTranslator.load(translation): app.installTranslator(appTranslator) print(app.tr("Loaded translation: {}.").format(translation)) else: print(app.tr("Warning: failed to load translator for locale {}...").format(locale)) QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")]) QIcon.setThemeName("NumixMsk") # qApp.setWindowIcon(QIcon.fromTheme("im-aim")) # Seperating launch to avoid segfault, so it seem. # Cf. http://stackoverflow.com/questions/12433491/is-this-pyqt-4-python-bug-or-wrongly-behaving-code launch()
edit_current_action = QAction(mw) edit_current_action.setText(_(u"Edit current")) edit_current_action.setIcon(QIcon(os.path.join(icons_dir, 'edit_current.png'))) edit_current_action.setToolTip(_(u"Edit the current note.")) edit_current_action.triggered.connect(go_edit_current) edit_layout_action = QAction(mw) edit_layout_action.setText(_(u"Edit layout")) edit_layout_action.setIcon(QIcon(os.path.join(icons_dir, 'edit_layout.png'))) edit_layout_action.setToolTip(_(u"Edit the layout of the current card.")) edit_layout_action.triggered.connect(go_edit_layout) toggle_mark_action = QAction(mw) toggle_mark_action.setText(_(u"Mark")) toggle_mark_action.setCheckable(True) toggle_mark_action.setToolTip(_(u"Mark or unmark the current note.")) toggle_mark_icon = QIcon() toggle_mark_icon.addFile(os.path.join(icons_dir, 'mark_off.png')) toggle_mark_icon.addFile(os.path.join(icons_dir, 'mark_on.png'), QSize(), QIcon.Normal, QIcon.On) toggle_mark_action.setIcon(toggle_mark_icon) toggle_mark_action.triggered.connect(mw.reviewer.onMark) toggle_last_card_action = QAction(mw) toggle_last_card_action.setText(_(u"Last card")) toggle_last_card_action.setCheckable(True) toggle_last_card_action.setChecked(False) toggle_last_card_action.setToolTip(_(u"Make this card the last to review.")) toggle_last_card_icon = QIcon() toggle_last_card_icon.addFile(os.path.join(icons_dir, 'last_card_off.png')) toggle_last_card_icon.addFile(os.path.join(icons_dir, 'last_card_on.png'), QSize(), QIcon.Normal, QIcon.On) toggle_last_card_action.setIcon(toggle_last_card_icon) mute_action = QAction(mw)
def main(args=None): if args is None: args = sys.argv[1:] parser = argparse.ArgumentParser( description='Runs the inselect user-interface' ) parser.add_argument( "file", help='The inselect document to open', nargs='?', type=Path ) parser.add_argument( '-d', '--debug', action='store_true', help='Show debug messages' ) parser.add_argument( '-l', '--locale', action='store', help='Use LOCALE; intended for dev purposes only' ) parser.add_argument( '-q', '--quit', action='store_true', help='Exit immediately after showing the main window; intended for dev ' 'purposes only' ) parser.add_argument( '-s', '--stylesheet', action='store', type=Path, help='Use stylesheet; intended for dev purposes only' ) parser.add_argument( '-t', '--print-time', action='store_true', help='Will print, when a document is closed, the elapsed time for ' 'which the document was open' ) parser.add_argument( '-v', '--version', action='version', version='%(prog)s ' + inselect.__version__ ) parser.add_argument( '-w', '--window-size', action='store', type=_window_size, help='Set window size to WxH' ) parsed = parser.parse_args(args) # TODO LH A command-line switch to clear all QSettings inselect.lib.utils.DEBUG_PRINT = parsed.debug # Only one instance of QApplication can be created per process. The single # instance is stored in QtWidgets.qApp. When test plans are being run it is # likely that the QApplication will have been created by a unittest. QtWidgets.qApp = qapplication(args) # Install global exception hook only after the application has been created sys.excepthook = report_exception_to_user debug_print('Settings stored in [{0}]'.format(QSettings().fileName())) if parsed.locale: debug_print('Will set locale to [{0}]'.format(parsed.locale)) QLocale.setDefault(QLocale(parsed.locale)) locale.setlocale(locale.LC_ALL, parsed.locale) else: # Set Python's locale module to the user's default locale locale.setlocale(locale.LC_ALL, '') debug_print('Locale is [{0}]'.format(QLocale().name())) # Application icon icon = QIcon() path = ':/icons/inselect{0}.png' for size in (16, 24, 32, 48, 64, 128, 256, 512): icon.addFile(path.format(size), QSize(size, size)) QtWidgets.qApp.setWindowIcon(icon) # Stylesheet QtWidgets.qApp.setStyleSheet(_stylesheet(parsed.stylesheet)) # Create and show main windows window = MainWindow(parsed.print_time) if parsed.window_size: window.show_with_size(parsed.window_size) else: window.show_from_geometry_settings() if parsed.file: # Process messages before loading document QtWidgets.qApp.processEvents() window.open_file(parsed.file) if parsed.quit: sys.exit(0) else: QTimer.singleShot(100, window.show_shortcuts_post_startup) sys.exit(QtWidgets.qApp.exec_())
def initUI(self): app_icon = QIcon() app_icon.addFile("key.png", QSize(256, 256)) self.setWindowIcon(app_icon) # open openFile = QAction('Open', self) openFile.setShortcut('Ctrl+O') openFile.setStatusTip('Open new File') openFile.triggered.connect(self.fileOpen) # save saveFile = QAction('Save', self) saveFile.setShortcut('Ctrl+S') saveFile.setStatusTip('Save new File') saveFile.triggered.connect(self.fileSave) printAction = QAction("Print", self) printAction.triggered.connect(self.printSetup) # exit exitAction = QAction('Exit', self) exitAction.triggered.connect(self.closeEvent) # menu object menubar = self.menuBar() # file drop down fileMenu = menubar.addMenu('&File') fileMenu.addAction(openFile) fileMenu.addAction(saveFile) fileMenu.addAction(printAction) fileMenu.addAction(exitAction) # widgets grid = QGridLayout() horiz = QVBoxLayout() bigHoriz = QHBoxLayout() horizLayout = QHBoxLayout() window = QWidget() window.setLayout(bigHoriz) leftPane = QFormLayout() bigHoriz.addLayout(leftPane) bigHoriz.addLayout(horiz) self.setCentralWidget(window) btn = QPushButton('Generate', self) btn.clicked.connect(lambda: self.runGen()) clearBtn = QPushButton("Clear", self) clearBtn.clicked.connect(self.clearList) self.mainText = QListWidget(self) self.mainText.itemSelectionChanged.connect(self.listItemClicked) self.mainText.setFont( QFontDatabase.systemFont(QFontDatabase.FixedFont)) self.mastInput = [] i = 0 while i < 6: t = QLineEdit() t.setMaxLength(1) t.setAlignment(Qt.AlignHCenter) t.textChanged.connect(self.textInputed) self.mastInput.append(t) i = i + 1 for e in self.mastInput: horizLayout.addWidget(e) self.mast = QLineEdit() self.tenants = QLineEdit() self.inc = QLineEdit() self.title = QLineEdit() self.title.setMinimumWidth(200) self.desc = QLineEdit() self.address = QLineEdit() self.contact = QLineEdit() self.phone = QLineEdit() self.email = QLineEdit() self.notes = QTextEdit() self.keyway = QLineEdit() label = QLabel("Master Cuts") incLabel = QLabel("Increment") tenantLabel = QLabel("Tenants") # add widgets to layouts leftPane.addRow(QLabel("Title"), self.title) leftPane.addRow(QLabel("Description"), self.desc) leftPane.addRow(QLabel("Keyway"), self.keyway) leftPane.addRow(QLabel("Address"), self.address) leftPane.addRow(QLabel("contact"), self.contact) leftPane.addRow(QLabel("Phone"), self.phone) leftPane.addRow(QLabel("Email"), self.email) leftPane.addRow(QLabel("Notes"), self.notes) grid.addWidget(incLabel, 3, 0) grid.addWidget(tenantLabel, 2, 0) grid.addWidget(label, 1, 0) grid.addWidget(btn, 0, 0) horiz.addWidget(self.mainText) horiz.addLayout(grid) # horiz.addLayout(horizLayout) grid.addWidget(clearBtn, 0, 1) grid.addWidget(self.tenants, 2, 1) grid.addWidget(self.inc, 3, 1) grid.addLayout(horizLayout, 1, 1) # window properties self.setGeometry(300, 300, 500, 425) self.setWindowTitle('PySchlageGen') self.show()
def prepare(tests=False): app = QApplication(sys.argv) app.setOrganizationName("manuskript"+("_tests" if tests else "")) app.setOrganizationDomain("www.theologeek.ch") app.setApplicationName("manuskript"+("_tests" if tests else "")) app.setApplicationVersion(getVersion()) print("Running manuskript version {}.".format(getVersion())) icon = QIcon() for i in [16, 32, 64, 128, 256, 512]: icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i))) qApp.setWindowIcon(icon) app.setStyle("Fusion") # Load style from QSettings settings = QSettings(app.organizationName(), app.applicationName()) if settings.contains("applicationStyle"): style = settings.value("applicationStyle") app.setStyle(style) # Translation process locale = QLocale.system().name() appTranslator = QTranslator(app) # By default: locale def extractLocale(filename): # len("manuskript_") = 13, len(".qm") = 3 return filename[11:-3] if len(filename) >= 16 else "" def tryLoadTranslation(translation, source): if appTranslator.load(appPath(os.path.join("i18n", translation))): app.installTranslator(appTranslator) print(app.tr("Loaded translation from {}: {}.").format(source, translation)) return True else: print(app.tr("Note: No translator found or loaded from {} for locale {}."). format(source, extractLocale(translation))) return False # Load translation from settings translation = "" if settings.contains("applicationTranslation"): translation = settings.value("applicationTranslation") print("Found translation in settings:", translation) if (translation != "" and not tryLoadTranslation(translation, "settings")) or translation == "": # load from settings failed or not set, fallback translation = "manuskript_{}.qm".format(locale) tryLoadTranslation(translation, "system locale") QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")]) QIcon.setThemeName("NumixMsk") # Font siue if settings.contains("appFontSize"): f = qApp.font() f.setPointSize(settings.value("appFontSize", type=int)) app.setFont(f) # Main window from manuskript.mainWindow import MainWindow MW = MainWindow() # We store the system default cursor flash time to be able to restore it # later if necessary MW._defaultCursorFlashTime = qApp.cursorFlashTime() # Command line project if len(sys.argv) > 1 and sys.argv[1][-4:] == ".msk": if os.path.exists(sys.argv[1]): path = os.path.abspath(sys.argv[1]) MW._autoLoadProject = path return app, MW
def login(self, email, password): self.cw.authenticate(email, password) @pyqtSlot() def stop(self): self.cw.stop() sys.exit() if __name__ == "__main__": app = QGuiApplication(sys.argv) clipboard = app.clipboard() # add icon app_icon = QIcon() app_icon.addFile(path.join("qml", "img", "logo.jpg")) app.setWindowIcon(app_icon) engine = QQmlApplicationEngine() ctx = engine.rootContext() py = QMLNameSpace(engine, clipboard) ctx.setContextProperty("main", engine) ctx.setContextProperty("py", py) # engine.addImportPath(path.join(getcwd(), 'qml')) engine.setImportPathList([path.join(getcwd(), "qml", "lib")]) engine.load("qml/gui.qml") window = engine.rootObjects()[0] window.show()
def setupUi(self): super(ScreensharingToolbox, self).setupUi(self) # fix the SVG icons, as the generated code loads them as pixmaps, losing their ability to scale -Dan scale_icon = QIcon() scale_icon.addFile(Resources.get('icons/scale.svg'), mode=QIcon.Normal, state=QIcon.Off) viewonly_icon = QIcon() viewonly_icon.addFile(Resources.get('icons/viewonly.svg'), mode=QIcon.Normal, state=QIcon.Off) screenshot_icon = QIcon() screenshot_icon.addFile(Resources.get('icons/screenshot.svg'), mode=QIcon.Normal, state=QIcon.Off) fullscreen_icon = QIcon() fullscreen_icon.addFile(Resources.get('icons/fullscreen.svg'), mode=QIcon.Normal, state=QIcon.Off) fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Normal, state=QIcon.On) fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Active, state=QIcon.On) fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Disabled, state=QIcon.On) fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Selected, state=QIcon.On) minimize_icon = QIcon() minimize_icon.addFile(Resources.get('icons/minimize.svg'), mode=QIcon.Normal, state=QIcon.Off) minimize_icon.addFile(Resources.get('icons/minimize-active.svg'), mode=QIcon.Active, state=QIcon.Off) close_icon = QIcon() close_icon.addFile(Resources.get('icons/close.svg'), mode=QIcon.Normal, state=QIcon.Off) close_icon.addFile(Resources.get('icons/close-active.svg'), mode=QIcon.Active, state=QIcon.Off) self.scale_action.setIcon(scale_icon) self.viewonly_action.setIcon(viewonly_icon) self.screenshot_action.setIcon(screenshot_icon) self.fullscreen_action.setIcon(fullscreen_icon) self.minimize_action.setIcon(minimize_icon) self.close_action.setIcon(close_icon) self.scale_button.setIcon(scale_icon) self.viewonly_button.setIcon(viewonly_icon) self.screenshot_button.setIcon(screenshot_icon) self.fullscreen_button.setIcon(fullscreen_icon) self.minimize_button.setIcon(minimize_icon) self.close_button.setIcon(close_icon) self.scale_button.setDefaultAction(self.scale_action) self.viewonly_button.setDefaultAction(self.viewonly_action) self.screenshot_button.setDefaultAction(self.screenshot_action) self.fullscreen_button.setDefaultAction(self.fullscreen_action) self.minimize_button.setDefaultAction(self.minimize_action) self.close_button.setDefaultAction(self.close_action) self.color_depth_button.clear() self.color_depth_button.addItem('Default Color Depth', ServerDefault) self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor) self.color_depth_button.addItem('HighColor (16 bits)', HighColor) self.color_depth_button.addItem('LowColor (8 bits)', LowColor)
# Create application QT and create WebView app = QApplication([]) web = QWebView() # Get current theme command = "kreadconfig --group 'Icons' --key 'Theme'" theme = subprocess.getoutput(command) # Set Title title = _("Kaiana Control Panel") web.setWindowTitle(title) # Set icon icon = QIcon() icon.addFile(getIconPath('preferences-system', theme=theme, size=16), QSize(16,16)) icon.addFile(getIconPath('preferences-system', theme=theme, size=32), QSize(32,32)) icon.addFile(getIconPath('preferences-system', theme=theme, size=64), QSize(64,64)) icon.addFile(getIconPath('preferences-system', theme=theme, size=256), QSize(256,256)) web.setWindowIcon(icon) # Get dimensions from config file config = ConfigParser() configFile = None configFilePath = os.getenv("HOME") + "/.kcenter/conf" width, height = 800, 600 x = y = None if os.path.exists(configFilePath): config.read(configFilePath) width = config.get('window','width') if config.has_option('window','width') else width