Ejemplo n.º 1
3
 def on_styleActionGroup_triggered(self, action):
     """ Change current editor style """
     self.ui.genericEditor.currentStyle = styles.getStyle(action.text())
     stylesheet = ""
     if action.text() == "Dark":
         try:
             import qdarkstyle
             stylesheet = qdarkstyle.load_stylesheet()
         except ImportError:
             print "Failed to use the qdarkstyle. Please execute <pip install qdarkstyle> to fully use this theme."
     QApplication.instance().setStyleSheet(stylesheet)
Ejemplo n.º 2
0
Archivo: vtMain.py Proyecto: flatM/vnpy
def main():
    """主程序入口"""
    # 设置底部任务栏图标,win7以下请注释掉
    if platform.uname() == 'Windows':
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.py demo')  
    
    # Reload sys, Set default encode to UTF8
    reload(sys)
    sys.setdefaultencoding('utf8')

    # 初始化Qt应用对象
    app = QtGui.QApplication(sys.argv)
    app.setWindowIcon(QtGui.QIcon('vnpy.ico'))
    app.setFont(BASIC_FONT)
    
    # 设置Qt的皮肤
    try:
        f = file("VT_setting.json")
        setting = json.load(f)    
        if setting['darkStyle']:
            import qdarkstyle
            app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    except:
        pass
    
    # 初始化主引擎和主窗口对象
    mainEngine = MainEngine()
    mainWindow = MainWindow(mainEngine, mainEngine.eventEngine)
    mainWindow.showMaximized()
    
    # 在主线程中启动Qt事件循环
    sys.exit(app.exec_())
Ejemplo n.º 3
0
def main():
    """
    Application entry point
    """



    app = QtGui.QApplication(sys.argv)
    app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True))




    if len(sys.argv) >= 2:
        fileName = sys.argv[1]
    else:
        fileName = "."

    tabdialog = Ui_MainWindow()
    tabdialog.resize(500,200)

    sys.exit(tabdialog.exec_())

    # setup stylesheet


    # run
    window.show()
    app.exec_()
Ejemplo n.º 4
0
def main():
    
    app = QtGui.QApplication(sys.argv)
    baseWin = BaseWin()
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    baseWin.show()
    sys.exit(app.exec_())
Ejemplo n.º 5
0
    def applyChanges(self):

        self.n = int(self.op.tilesSpinBox.value())

        self.gameAll.n = self.n

        if self.op.difLevel.whichChosen() == "Easy":
            self.k = 0
        elif self.op.difLevel.whichChosen() == "Medium" and (self.n == 4 or self.n == 5):
            self.k = 1
        elif self.op.difLevel.whichChosen() == "Medium" and (self.n == 6 or self.n == 7 or self.n == 8):
            self.k = 2
        elif self.op.difLevel.whichChosen() == "Hard" and (self.n == 4 or self.n == 5):
            self.k = 2
        elif self.op.difLevel.whichChosen() == "Hard" and (self.n == 6 or self.n == 7):
            self.k = 3
        elif self.op.difLevel.whichChosen() == "Hard" and (self.n == 8):
            self.k = 4

        self.gameAll.k = self.k
        self.gameAll.tiles = Tile(self.gameAll.n, self.gameAll.k)
        self.gameAll.coords = self.gameAll.findCoords()
        self.gameAll.coordsT = self.gameAll.findCoordsText()

        if self.op.designWidgetParent.whichChosen() == "Fairstyle":
            self.designValue = "Fairstyle"
            self.setStyleSheet("plastique")
        elif self.op.designWidgetParent.whichChosen() == "Darkstyle":
            self.designValue = "Darkstyle"
            self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
        self.ab.designValue = self.op.designWidgetParent.whichChosen()
        self.ab.setDesign()
        self.gameAll.designValue = self.op.designWidgetParent.whichChosen()
        self.gameAll.setDesign()
        self.gameAll.scoreDisplay.display(self.gameAll.tiles.score)
Ejemplo n.º 6
0
def run():        
    app = QtGui.QApplication(sys.argv)
    #style_string = pyqtcss.get_style("dark_blue")
    #app.setStyleSheet(style_string)
    app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    GUI = Window()
    sys.exit(app.exec_())
Ejemplo n.º 7
0
def main():
    """
    Application entry point
    """
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtGui.QApplication(sys.argv)
    window = QtGui.QMainWindow()
    
    # setup ui
    ui = example_ui.Ui_MainWindow()
    ui.setupUi(window)
    window.setWindowTitle("QDarkStyle example")

    # tabify dock widgets to show bug #6
    window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)

    # setup stylesheet
    app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True))

        # auto quit after 2s when testing on travis-ci
    if "--travis" in sys.argv:
        QtCore.QTimer.singleShot(2000, app.exit)

    # run
    window.show()
    app.exec_()
Ejemplo n.º 8
0
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))
Ejemplo n.º 9
0
def main():
    """主程序入口"""
    # 重载sys模块,设置默认字符串编码方式为utf8
    reload(sys)
    sys.setdefaultencoding('utf8')
    
    # 设置Windows底部任务栏图标
    if platform.uname() == 'Windows':
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')  
    
    # 初始化Qt应用对象
    app = QtGui.QApplication(sys.argv)
    app.setWindowIcon(QtGui.QIcon(ICON_FILENAME))
    app.setFont(BASIC_FONT)
    
    # 设置Qt的皮肤
    try:
        f = file(SETTING_FILENAME)
        setting = json.load(f)    
        if setting['darkStyle']:
            import qdarkstyle
            app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    except:
        pass
    
    # 初始化主引擎和主窗口对象
    mainEngine = MainEngine()
    mainWindow = MainWindow(mainEngine, mainEngine.eventEngine)
    mainWindow.showMaximized()
    
    # 在主线程中启动Qt事件循环
    sys.exit(app.exec_())
Ejemplo n.º 10
0
 def applySettings(self):
     if Settings().globalStyle == 'white':
         QtWidgets.QApplication.instance().setStyleSheet("")
         self.frameRecents.setStyleSheet(home.frame_recent_white)
         self.labelRecents.setStyleSheet(home.label_recent_white)
         self.listWidgetRecents.setStyleSheet(home.list_recent_white)
     else:
         self.frameRecents.setStyleSheet(home.frame_recent_dark)
         self.labelRecents.setStyleSheet(home.label_recent_dark)
         self.listWidgetRecents.setStyleSheet(home.list_recent_dark)
         if '5' in os.environ['QT_API']:
             QtWidgets.QApplication.instance().setStyleSheet(
                 qdarkstyle.load_stylesheet_pyqt5())
         else:
             QtWidgets.QApplication.instance().setStyleSheet(
                 qdarkstyle.load_stylesheet(pyside=False))
     self.statusbar.setVisible(Settings().displayStatusBar)
     for i in range(self.tabWidgetEditors.count()):
         self.tabWidgetEditors.widget(i).updateSettings()
     self.setupIcons()
     self.menuBar.setVisible(Settings().displayMenuBar)
     if self.stackedWidget.currentIndex():
         self.toolBarCode.setVisible(Settings().displayToolBar)
         self.toolBarFile.setVisible(Settings().displayToolBar)
     self.lblFormat.setText('Free format' if Settings().free_format else 'Fixed format')
Ejemplo n.º 11
0
def main():
    app = QApplication(sys.argv)
    import qdarkstyle
    # setup stylesheet
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    pixmap = QPixmap(os.path.join(_resourcepath('images'), "splash.png"))
    splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
    splash.setMask(pixmap.mask())
    splash_font = splash.font()
    splash_font.setPixelSize(14)
    splash.setFont(splash_font)
    splash.show()
    splash.showMessage('Initialising...',
                       Qt.AlignBottom | Qt.AlignLeft |
                       Qt.AlignAbsolute,
                       Qt.white)
    app.processEvents()
    """
    for count in range(1, 6):
        splash.showMessage('Processing {0}...'.format(count),
                           Qt.AlignBottom | Qt.AlignLeft,
                           Qt.white)
        QApplication.processEvents()
        QThread.msleep(1000)
    """
    frame = ConfiguratorWindow()

    frame.show_and_raise()
    splash.finish(frame)
    sys.exit(app.exec_())
Ejemplo n.º 12
0
def createQApp():
    """创建PyQt应用对象"""
    # 创建Qt应用对象
    qApp = QtWidgets.QApplication([])
    
    # 设置Qt的皮肤
    if globalSetting['darkStyle']:
        try:
            import qdarkstyle
            qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
        except ImportError:
            pass
        
    # 设置Windows底部任务栏图标
    if 'Windows' in platform.uname():
        import ctypes
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')  
    
    # 设置Qt字体
    qApp.setFont(BASIC_FONT)
    
    # 设置Qt图标
    qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))
    
    # 返回创建好的QApp对象
    return qApp
Ejemplo n.º 13
0
def main():
    """

    :return:
    """
    app = QtGui.QApplication(sys.argv)

    # SplashScreen
    source_path = os.path.dirname(gui.__file__)
    # print(source_path)
    graphics_path = os.path.join(source_path, 'icons')
    # print(graphics_path)
    splash_picture = QtGui.QPixmap(os.path.join(graphics_path, 'pLEASE.png'))
    # print(os.path.join(graphics_path, 'pLEASE.png'))
    splash = QtGui.QSplashScreen(splash_picture, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(splash_picture.mask())
    splash.show()
    time.sleep(3.5)

    # Start UI
    view = gui.Viewer()
    splash.finish(view)
    max_ht = view.max_height
    max_wd = view.max_width

    # Small screens
    if max_ht <= 800 and max_wd <= 1280:
        view.showMaximized()
    view.raise_()

    if view.Style:
        app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    sys.exit(app.exec_())
Ejemplo n.º 14
0
def main():
    app = QtGui.QApplication(sys.argv)
    form = MainWindow()
    app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))

    form.show()
    app.exec_()
Ejemplo n.º 15
0
    def __init__(self, checkbool = True, end = False):
        super(NoticeWindow, self).__init__()
        self.setWindowTitle('Options Notice')
        self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
        
        check = QtGui.QWidget(self)
        x = "After changing color, your SuDoKu game will be restarted to apply new setting!"
        label = QtGui.QLabel(x)
 
        layout = QtGui.QVBoxLayout()
        layout.addWidget(label, 0, QtCore.Qt.AlignCenter)
        check.setLayout(layout)
        
        okbutton = QtGui.QPushButton('&OK')
        self.connect(okbutton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('accept()'))
            
        
        bbox = QtGui.QHBoxLayout()
        bbox.addStretch()
        bbox.addWidget(okbutton)
        bbox.addStretch()
        
        layout = QtGui.QVBoxLayout()
        layout.addWidget(check)
        layout.addLayout(bbox)
        self.setLayout(layout)
Ejemplo n.º 16
0
    def setDesign(self):

        if self.designWidgetParent.whichChosen() == "Fairstyle":
            self.designValue = "Fairstyle"
            self.setStyleSheet("plastique")
        elif self.designWidgetParent.whichChosen() == "Darkstyle":
            self.designValue = "Darkstyle"
            self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
Ejemplo n.º 17
0
def main():
    app = QtGui.QApplication.instance()
    if not app:
        app = QtGui.QApplication(sys.argv)
        app.setStyleSheet(qdarkstyle.load_stylesheet())
    ui = radarUI.MainWindow()
    ui.show()
    sys.exit(app.exec_())
Ejemplo n.º 18
0
def main():
    
    app = QtGui.QApplication(sys.argv)
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    win = HierarchyTreeview()
    win.show()
    win.treeview.expandAll()
    sys.exit(app.exec_())
Ejemplo n.º 19
0
    def __init__(self):
        super(OptionsGame, self).__init__()
        
        self.initUI()
        self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
        SudokuMainWindow.changeOptions = False

        self.reset = False
Ejemplo n.º 20
0
 def __init__(self):
     super(Levels, self).__init__()
     
     self.level = CreateLevels()
     self.level.createWindowLevels(self)
     self.setWindowModality(QtCore.Qt.WindowModal)
     self.chooseLevel()
     self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
Ejemplo n.º 21
0
def main():
    
    
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName("Calculatrice")
    myapp = Form()
    myapp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    myapp.show()
    sys.exit(app.exec_())
Ejemplo n.º 22
0
 def __init__(self):
     super(SudokuMainWindow, self).__init__()
     
     self.sudokufull= None
     self.sudoku0 = None
     self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
     self.createMainWindow()
     self.createMenuBar()
     self.newGame()
Ejemplo n.º 23
0
    def __init__(self):
        super(AboutGame, self).__init__()
        self.setWindowTitle("About SuDoKu")
        self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))

        aboutPage = QtGui.QWidget(self)
        logo = QtGui.QLabel()
        pixmap = QtGui.QPixmap("sudoku/sudoku.png")
        logo.setPixmap(pixmap)

        aboutLabel = QtGui.QLabel(about)

        aboutLayout = QtGui.QVBoxLayout()
        aboutLayout.addSpacing(30)
        aboutLayout.addWidget(logo, 0, QtCore.Qt.AlignCenter)
        aboutLayout.addWidget(aboutLabel, 0, QtCore.Qt.AlignCenter)
        aboutPage.setLayout(aboutLayout)

        sudoku = QtGui.QLabel()
        pixmap2 = QtGui.QPixmap("sudoku/sudoku2.png")
        sudoku.setPixmap(pixmap2)

        rulePage = QtGui.QWidget(self)
        ruleLabel = QtGui.QLabel(rules)
        ruleLayout = QtGui.QVBoxLayout()
        ruleLayout.addWidget(sudoku, 0, QtCore.Qt.AlignCenter)
        ruleLayout.addSpacing(30)
        ruleLayout.addWidget(ruleLabel)

        keysPage = QtGui.QWidget(self)
        keysLayout = QtGui.QGridLayout()
        i = 0
        for key, desc in keys:
            keysLayout.addWidget(QtGui.QLabel(key), i, 0)
            keysLayout.addWidget(QtGui.QLabel(desc), i, 1)
            i += 1
        keysPage.setLayout(keysLayout)

        rulePage.setLayout(ruleLayout)

        tabs = QtGui.QTabWidget(self)
        tabs.addTab(aboutPage, "About")
        tabs.addTab(rulePage, "Game Rules")
        tabs.addTab(keysPage, "Keys")

        okbutton = QtGui.QPushButton("OK")
        self.connect(okbutton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("accept()"))

        bbox = QtGui.QHBoxLayout()
        bbox.addStretch()
        bbox.addWidget(okbutton)
        bbox.addStretch()

        layout = QtGui.QVBoxLayout()
        layout.addWidget(tabs)
        layout.addLayout(bbox)
        self.setLayout(layout)
Ejemplo n.º 24
0
    def setDesign(self):

        sender = self.sender()
        if sender.text() == "Fairstyle":
            self.designValue = "Fairstyle"
            self.setStyleSheet("plastique")
        elif sender.text() == "Darkstyle":
            self.designValue = "Darkstyle"
            self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
        self.ab.setDesign()
Ejemplo n.º 25
0
 def __init__(self,parent=None):
     super(MainGui,self).__init__(parent)
     self.setupUi(self)
     self.setStyleSheet(qdarkstyle.load_stylesheet())
     self.baidu.setChecked(True)
     self.isMobile.setStyleSheet("color:#FFD700") 
     self.connect(self.pushButton,QtCore.SIGNAL("clicked()"),self.query)
     self.connect(self.pushButton_3,QtCore.SIGNAL("clicked()"),self.saveData)
     self.connect(self.pushButton_2,QtCore.SIGNAL("clicked()"),self.cls)
     self.se="baidu"
Ejemplo n.º 26
0
    def __init__(self):
        super(VCFEditor, self).__init__()

        self.setupUi(self)
        self.setStyleSheet(qdarkstyle.load_stylesheet())
        self.setWindowFlags(Qt.FramelessWindowHint)

        self.resizeEvent = self.ui_resize
        self.ui_resize("")

        self.initUi()
Ejemplo n.º 27
0
def main():
    
    # Create size constrains
    width = 0.9*1280
    height = 0.9*800
    
    app = QApplication(sys.argv)
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    view = MainView()
    view.resize(width, height)
    sys.exit(app.exec_())
Ejemplo n.º 28
0
def run():
    app = QtGui.QApplication(sys.argv)
    # setup stylesheet
    if globals.darkUI:
        app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    elif globals.fancyUI:
        app.setStyleSheet(fancyqt.firefox.style)
    form = LoveLogger()
    form.show()
    app.exec_()
    app.deleteLater()
    sys.exit(0)
Ejemplo n.º 29
0
    def __init__(self, uifile):
        self.qt_application = QApplication(sys.argv)
        super(PyQtWindow, self).__init__()
        uic.loadUi(uifile, self)

        signal.signal(signal.SIGINT, signal.SIG_DFL)

        # REPLACE STylesheet with custom paths
        if qdarkstyle:
            self.qt_application.setStyleSheet(
                qdarkstyle.load_stylesheet(pyside=False)
            )
Ejemplo n.º 30
0
def apply_default_stylesheet(app, force=False):
    global _applied_stylesheet
    global _USE_THEME

    if not _applied_stylesheet or force:
        if _USE_THEME == 'DARK':
            try:
                import qdarkstyle
            except ImportError:
                import sys
                sys.stderr.write('import qdarkstyle failed (using native style as a fallback).')
                _USE_THEME = 'NATIVE'

        _applied_stylesheet = True

        if _USE_THEME == 'DARK_ORANGE':
            from pyvmmonitor_qt.stylesheet.dark import STYLESHEET
            # app.setStyle("plastique")
            # app.setStyle("cleanlooks")
            # app.setStyle("motif")
            # app.setStyle("cde")
            is_dark = True
        elif _USE_THEME == 'DARK':
            import qdarkstyle
            # setup stylesheet
            STYLESHEET = qdarkstyle.load_stylesheet()
            is_dark = True
        else:  # Native or error...
            from pyvmmonitor_qt.stylesheet.light import STYLESHEET
            is_dark = False

        app.setStyleSheet(STYLESHEET)

        from pyvmmonitor_qt.qt.QtGui import QPalette
        from pyvmmonitor_qt.qt.QtGui import QIcon

        pal = QPalette(app.palette())
        foreground = get_app_stylesheet().get_foreground()
        pal.setColor(QPalette.Link, foreground)
        pal.setColor(QPalette.LinkVisited, foreground)
        app.setPalette(pal)

        _switch_resources_to_style(is_dark)
        for icon_name, styled_qobj in compat.iteritems(_styled_qt_objects):
            if callable(icon_name):
                icon_name = icon_name()

            if icon_name:
                for action in styled_qobj:
                    action.setIcon(QIcon(icon_name))

        on_stylesheet_changed()
    def initUI(self):

        self.setStyleSheet(qdarkstyle.load_stylesheet())

        self.horizontalLayout = QHBoxLayout()
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.verticalLayout.setSpacing(6)
        self.gridLayout = QGridLayout()

        self.imageLabel = QLabel()
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.imageLabel.sizePolicy().hasHeightForWidth())
        self.imageLabel.setSizePolicy(sizePolicy)
        self.imageLabel.setMinimumSize(QSize(200, 130))
        self.imageLabel.setMaximumSize(QSize(200, 130))
        self.imageLabel.setPixmap(
            QPixmap("./Arduino/logo/CUAtHomeLogo-Horz.png").scaled(
                200, 130, Qt.KeepAspectRatio, Qt.FastTransformation))
        self.verticalLayout.addWidget(self.imageLabel)

        self.startbutton = QPushButton("Start", self)
        self.startbutton.setCheckable(False)
        self.startbutton.clicked.connect(self.startbutton_pushed)
        self.startbutton.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.startbutton, 0, 0, 1, 1)

        self.stopbutton = QPushButton("Stop", self)
        self.stopbutton.setCheckable(False)
        self.stopbutton.clicked.connect(self.stopbutton_pushed)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.stopbutton.sizePolicy().hasHeightForWidth())
        self.stopbutton.setSizePolicy(sizePolicy)
        self.stopbutton.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.stopbutton, 0, 1, 1, 1)

        self.clearbutton = QPushButton("Clear", self)
        self.clearbutton.setCheckable(False)
        self.clearbutton.clicked.connect(self.clearbutton_pushed)
        self.clearbutton.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.clearbutton, 1, 0, 1, 1)

        self.savebutton = QPushButton("Save", self)
        self.savebutton.setCheckable(False)
        self.savebutton.clicked.connect(self.savebutton_pushed)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.savebutton.sizePolicy().hasHeightForWidth())
        self.savebutton.setSizePolicy(sizePolicy)
        self.savebutton.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.savebutton, 1, 1, 1, 1)

        self.settings = QPushButton("Settings", self)
        self.settings.clicked.connect(self.settingsMenu)
        self.settings.setMaximumSize(QSize(300, 20))
        self.gridLayout.addWidget(self.settings, 2, 0, 1, 2)

        self.checkBoxShowAll = QCheckBox("Show All Plots", self)
        self.checkBoxShowAll.setMaximumSize(QSize(100, 20))
        self.checkBoxShowAll.setChecked(True)
        self.checkBoxShowAll.toggled.connect(self.visibilityAll)
        self.gridLayout.addWidget(self.checkBoxShowAll, 3, 0, 1, 1)

        self.checkBoxHideAll = QCheckBox("Hide All Plots", self)
        self.checkBoxHideAll.setChecked(False)
        self.checkBoxHideAll.toggled.connect(self.hideAll)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.checkBoxHideAll.sizePolicy().hasHeightForWidth())
        self.checkBoxHideAll.setSizePolicy(sizePolicy)
        self.checkBoxHideAll.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.checkBoxHideAll, 3, 1, 1, 1)

        self.checkBoxPlot1 = QCheckBox("Plot 1", self)
        self.checkBoxPlot1.toggled.connect(self.visibility1)
        self.checkBoxPlot1.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.checkBoxPlot1, 4, 0, 1, 1)

        self.checkBoxPlot2 = QCheckBox("Plot 2", self)
        self.checkBoxPlot2.toggled.connect(self.visibility2)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.checkBoxPlot2.sizePolicy().hasHeightForWidth())
        self.checkBoxPlot2.setSizePolicy(sizePolicy)
        self.checkBoxPlot2.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.checkBoxPlot2, 4, 1, 1, 1)

        self.checkBoxShowAll.stateChanged.connect(self.checkbox_logic)
        self.checkBoxHideAll.stateChanged.connect(self.checkbox_logic)
        self.checkBoxPlot1.stateChanged.connect(self.checkbox_logic)
        self.checkBoxPlot2.stateChanged.connect(self.checkbox_logic)

        self.PowerScalingLabel = QLabel("Power Scaling (%)", self)
        self.PowerScalingLabel.setMinimumSize(QSize(100, 20))
        self.PowerScalingLabel.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.PowerScalingLabel, 7, 0, 1, 1)
        self.PowerScalingInput = QLineEdit("", self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.PowerScalingInput.sizePolicy().hasHeightForWidth())
        self.PowerScalingInput.setSizePolicy(sizePolicy)
        self.PowerScalingInput.setMaximumSize(QSize(100, 20))
        #self.PowerScalingInput.setValidator(QRegExpValidator(QRegExp("^[0-9][0-9]?$|^100$"))) #0-1 as a float FIX THIS
        self.gridLayout.addWidget(self.PowerScalingInput, 7, 1, 1, 1)

        self.FrequencyLabel = QLabel("Frequency (Hz)", self)
        self.FrequencyLabel.setMinimumSize(QSize(100, 20))
        self.FrequencyLabel.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.FrequencyLabel, 8, 0, 1, 1)
        self.FrequencyInput = QLineEdit("", self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.FrequencyInput.sizePolicy().hasHeightForWidth())
        self.FrequencyInput.setSizePolicy(sizePolicy)
        self.FrequencyInput.setMaximumSize(QSize(100, 20))
        self.FrequencyInput.setValidator(QDoubleValidator())
        self.gridLayout.addWidget(self.FrequencyInput, 8, 1, 1, 1)

        PID_validator = QDoubleValidator(
            0.0000, 50.000, 4, notation=QDoubleValidator.StandardNotation)

        self.PCheckBox = QCheckBox("P", self)
        self.PCheckBox.setMaximumSize(QSize(100, 20))
        self.PCheckBox.setChecked(True)
        self.PCheckBox.toggled.connect(self.PCheckBoxLogic)
        self.gridLayout.addWidget(self.PCheckBox, 9, 0, 1, 1)
        self.PInput = QLineEdit("", self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.PInput.sizePolicy().hasHeightForWidth())
        self.PInput.setSizePolicy(sizePolicy)
        self.PInput.setMaximumSize(QSize(100, 20))
        self.PInput.setValidator(PID_validator)
        self.gridLayout.addWidget(self.PInput, 9, 1, 1, 1)

        self.ICheckBox = QCheckBox("I", self)
        self.ICheckBox.setMaximumSize(QSize(100, 20))
        self.ICheckBox.setChecked(True)
        self.ICheckBox.toggled.connect(self.ICheckBoxLogic)
        self.gridLayout.addWidget(self.ICheckBox, 10, 0, 1, 1)
        self.IInput = QLineEdit("", self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.IInput.sizePolicy().hasHeightForWidth())
        self.IInput.setSizePolicy(sizePolicy)
        self.IInput.setMaximumSize(QSize(100, 20))
        self.IInput.setValidator(PID_validator)
        self.gridLayout.addWidget(self.IInput, 10, 1, 1, 1)

        self.DCheckBox = QCheckBox("D", self)
        self.DCheckBox.setMaximumSize(QSize(100, 20))
        self.DCheckBox.setChecked(True)
        self.DCheckBox.toggled.connect(self.DCheckBoxLogic)
        self.gridLayout.addWidget(self.DCheckBox, 11, 0, 1, 1)
        self.DInput = QLineEdit("", self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.DInput.sizePolicy().hasHeightForWidth())
        self.DInput.setSizePolicy(sizePolicy)
        self.DInput.setMaximumSize(QSize(100, 20))
        self.DInput.setValidator(PID_validator)
        self.gridLayout.addWidget(self.DInput, 11, 1, 1, 1)

        self.LabType = QComboBox()
        self.LabType.addItems(["Position", "Speed"])
        #self.LabType.activated.connect(self.getLabType)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.LabType.sizePolicy().hasHeightForWidth())
        self.LabType.setSizePolicy(sizePolicy)
        self.LabType.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.LabType, 5, 1, 1, 1)
        self.LabLabel = QLabel("Lab Type")
        self.LabLabel.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.LabLabel, 5, 0, 1, 1)

        self.inputForms = QComboBox()
        self.inputForms.addItems(["Sine", "Step"])
        self.inputForms.activated.connect(self.getInput)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.inputForms.sizePolicy().hasHeightForWidth())
        self.inputForms.setSizePolicy(sizePolicy)
        self.inputForms.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.inputForms, 6, 1, 1, 1)
        self.inputType = QLabel("Input Type")
        self.inputType.setMaximumSize(QSize(100, 20))
        self.gridLayout.addWidget(self.inputType, 6, 0, 1, 1)

        self.verticalLayout.addLayout(self.gridLayout)
        spacerItem = QSpacerItem(20, 80, QSizePolicy.Minimum,
                                 QSizePolicy.Fixed)
        self.verticalLayout.addItem(spacerItem)

        #What is this?

        self.label = QLabel()
        self.label.setMaximumSize(QSize(200, 130))
        self.label.setText("")
        self.verticalLayout.addWidget(self.label)

        self.horizontalLayout.addLayout(self.verticalLayout)
        self.rightVerticalLayout = QVBoxLayout()

        self.graphWidgetOutput = PlotWidget()
        self.graphWidgetInput = PlotWidget()

        #Adds grid lines
        self.graphWidgetOutput.showGrid(x=True, y=True, alpha=None)
        self.graphWidgetInput.showGrid(x=True, y=True, alpha=None)

        #self.graphWidget.setXRange(0, 100, padding=0) #Doesn't move with the plot. Can drag around
        #self.graphWidget.setLimits(xMin=0, xMax=100)#, yMin=c, yMax=d) #Doesn't move with the plot. Cannot drag around

        #self.graphWidget.setYRange(0, 4, padding=0)
        self.graphWidgetOutput.setYRange(-11, 11, padding=0)
        self.graphWidgetOutput.enableAutoRange()
        self.graphWidgetInput.setYRange(-11, 11, padding=0)
        self.graphWidgetInput.enableAutoRange()

        #Changes background color of graph
        self.graphWidgetOutput.setBackground((0, 0, 0))
        self.graphWidgetInput.setBackground((0, 0, 0))

        #Adds a legend after data starts to plot NOT before
        self.graphWidgetOutput.addLegend()

        #Adds title to graphs
        self.graphWidgetOutput.setTitle("Response", color="w", size="12pt")
        self.graphWidgetInput.setTitle("PWM Actuation Signal",
                                       color="w",
                                       size="12pt")

        self.rightVerticalLayout.addWidget(self.graphWidgetOutput)
        self.rightVerticalLayout.addWidget(self.graphWidgetInput)
        self.horizontalLayout.addLayout(self.rightVerticalLayout)

        self.setLayout(self.horizontalLayout)

        #Plot time update settings
        self.timer = QTimer()
        self.timer.setInterval(
            50
        )  #Changes the plot speed. Defaulted to 50. Can be placed in startbutton_pushed() method
        self.initialState()
        time.sleep(2)
        try:
            self.timer.timeout.connect(self.update)
        except:
            raise Exception("Not Connected")
                "Some sample images are in the folder " + "\"sample_images\""))
        self.action_generuj_obrazek.setText(
            _translate("MainWindow", "Generate random image"))
        self.action_generuj_obrazek.setToolTip(
            _translate("MainWindow", "Synthetic random image"))
        self.action_rozpoznej_karty.setText(
            _translate("MainWindow", "Identify"))
        self.action_rozpoznej_karty.setToolTip(
            _translate(
                "MainWindow",
                "Identifies all the cards on the image and assigns" +
                " them to players"))
        self.action_odkryj_karty.setText(_translate("MainWindow", "Next step"))
        self.action_odkryj_karty.setToolTip(
            _translate("MainWindow", "Simulates the next game state"))
        self.action_spocti_pravdepodobnosti.setText(
            _translate("MainWindow", "Compute probabilities"))
        self.action_spocti_pravdepodobnosti.setToolTip(
            _translate("MainWindow",
                       "Probabilities of win and draw for every player"))


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    app.setStyleSheet(qdarkstyle.load_stylesheet())  # tmavy styl GUI
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
Ejemplo n.º 33
0
def main():
    """Execute QDarkStyle example."""
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        '--palette',
        default='dark',
        type=str,
        choices=['dark', 'light', 'none'],
        help=
        "Palette to display. Using 'none' there is no style sheet applied, OS like."
    )
    parser.add_argument(
        '--qt_from',
        default='qtpy',
        type=str,
        choices=[
            'pyqt5', 'pyqt', 'pyside2', 'pyside', 'qtpy', 'pyqtgraph', 'qt.py'
        ],
        help=
        "Choose which binding and/or abstraction is to be used to run the example. Default is 'qtpy'"
    )
    parser.add_argument('--test',
                        action='store_true',
                        help="Auto close window after 2s.")
    parser.add_argument('--screenshots',
                        action='store_true',
                        help="Generate screenshots on images folder.")
    parser.add_argument(
        '--offscreen',
        action='store_true',
        help="Do not try to show the screen (running on server).")
    parser.add_argument('--reset',
                        action='store_true',
                        help="Reset GUI settings (position, size) then opens.")

    # Parsing arguments from command line
    args = parser.parse_args()

    # To avoid problems when testing without screen
    if args.test or args.offscreen:
        os.environ['QT_QPA_PLATFORM'] = 'offscreen'

    # Set QT_API variable before importing QtPy
    if args.qt_from in ['pyqt', 'pyqt5', 'pyside', 'pyside2']:
        os.environ['QT_API'] = args.qt_from
    elif args.qt_from == 'pyqtgraph':
        os.environ['QT_API'] = os.environ['PYQTGRAPH_QT_LIB']
    elif args.qt_from in ['qt.py', 'qt']:
        try:
            import Qt
        except ImportError:
            print('Could not import Qt (Qt.Py)')
        else:
            os.environ['QT_API'] = Qt.__binding__

    # QtPy imports
    from qtpy import API_NAME, QT_VERSION, PYQT_VERSION, PYSIDE_VERSION, uic
    from qtpy import __version__ as QTPY_VERSION
    from qtpy import QtCore, QtGui, QtWidgets

    # Set API_VERSION variable
    API_VERSION = ''

    if PYQT_VERSION:
        API_VERSION = PYQT_VERSION
    elif PYSIDE_VERSION:
        API_VERSION = PYSIDE_VERSION
    else:
        API_VERSION = 'Not found'

    # create the application
    app = QtWidgets.QApplication(sys.argv)
    app.setOrganizationName('QDarkStyle')
    app.setApplicationName('QDarkStyle Example')

    style = ''

    if args.palette == 'dark':
        style = qdarkstyle.load_stylesheet(palette=DarkPalette)
    elif args.palette == 'light':
        style = qdarkstyle.load_stylesheet(palette=LightPalette)

    app.setStyleSheet(style)

    # create main window
    window = QtWidgets.QMainWindow()
    window.setObjectName('mainwindow')
    uic.loadUi(os.path.join(here, 'ui/mw_menus.ui'), window)

    title = (
        "QDarkStyle Example - (" + f"QDarkStyle=v{qdarkstyle.__version__}, " +
        f"QtPy=v{QTPY_VERSION}, " + f"{API_NAME}=v{API_VERSION}, " +
        f"Qt=v{QT_VERSION}, " + f"Python=v{platform.python_version()}, "
        # Operating system info are maybe too much,
        # but different OS add info in different places
        + f"System={platform.system()}, " + f"Release={platform.release()}, " +
        f"Version={platform.version()}, " + f"Platform={platform.platform()}" +
        ")")

    _logger.info(title)
    window.setWindowTitle(title)

    # Create docks for buttons
    dw_buttons = QtWidgets.QDockWidget()
    dw_buttons.setObjectName('buttons')
    uic.loadUi(os.path.join(here, 'ui/dw_buttons.ui'), dw_buttons)
    window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_buttons)

    # Set state indeterminate (value=1)
    dw_buttons.checkBoxTristate.stateChanged.connect(
        dw_buttons.checkBoxTristateDis.setCheckState)
    dw_buttons.checkBoxTristate.setCheckState(1)

    # Add actions on popup toolbuttons
    menu = QtWidgets.QMenu()

    for action in ['Action A', 'Action B', 'Action C']:
        menu.addAction(action)

    # Add menu in special tool buttons
    dw_buttons.toolButtonDelayedPopup.setMenu(menu)
    dw_buttons.toolButtonInstantPopup.setMenu(menu)
    dw_buttons.toolButtonMenuButtonPopup.setMenu(menu)

    # Add menu in toolbar #251
    action_menu = QtWidgets.QAction(u'Menu action', window.toolBarMenus)
    action_menu.setMenu(menu)
    window.toolBarMenus.addAction(action_menu)

    # Add color to tab title text #212
    window.tabWidget.tabBar().setTabTextColor(3, QtGui.QColor('red'))

    # Connect dialogs to buttons
    window.toolButtonColorDialog.clicked.connect(
        lambda: QtWidgets.QColorDialog().exec())
    window.toolButtonFileDialog.clicked.connect(
        lambda: QtWidgets.QFileDialog().exec())
    window.toolButtonFileDialogStatic.clicked.connect(
        lambda: QtWidgets.QFileDialog.getOpenFileNames())
    window.toolButtonFontDialog.clicked.connect(
        lambda: QtWidgets.QFontDialog().exec())
    window.toolButtonInputDialog.clicked.connect(
        lambda: QtWidgets.QInputDialog().exec())
    window.toolButtonMessageBox.clicked.connect(
        lambda: QtWidgets.QMessageBox().exec())
    window.toolButtonMessageBoxStatic.clicked.connect(
        lambda: QtWidgets.QMessageBox.critical(window, "Critical title",
                                               "Critical message"))
    window.toolButtonProgressDialog.clicked.connect(
        lambda: QtWidgets.QProgressDialog().exec())

    # Create docks for buttons
    dw_displays = QtWidgets.QDockWidget()
    dw_displays.setObjectName('displays')
    uic.loadUi(os.path.join(here, 'ui/dw_displays.ui'), dw_displays)
    window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_displays)

    # Create docks for inputs - no fields
    dw_inputs_no_fields = QtWidgets.QDockWidget()
    dw_inputs_no_fields.setObjectName('inputs_no_fields')
    uic.loadUi(os.path.join(here, 'ui/dw_inputs_no_fields.ui'),
               dw_inputs_no_fields)
    window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_inputs_no_fields)

    # Create docks for inputs - fields
    dw_inputs_fields = QtWidgets.QDockWidget()
    dw_inputs_fields.setObjectName('inputs_fields')
    uic.loadUi(os.path.join(here, 'ui/dw_inputs_fields.ui'), dw_inputs_fields)
    window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_inputs_fields)

    # Create docks for widgets
    dw_widgets = QtWidgets.QDockWidget()
    dw_widgets.setObjectName('widgets')
    uic.loadUi(os.path.join(here, 'ui/dw_widgets.ui'), dw_widgets)
    window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_widgets)

    # Create docks for views
    dw_views = QtWidgets.QDockWidget()
    dw_views.setObjectName('views')
    uic.loadUi(os.path.join(here, 'ui/dw_views.ui'), dw_views)
    window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_views)

    # Create docks for containers - no tabs
    dw_containers_no_tabs = QtWidgets.QDockWidget()
    dw_containers_no_tabs.setObjectName('containers_no_tabs')
    uic.loadUi(os.path.join(here, 'ui/dw_containers_no_tabs.ui'),
               dw_containers_no_tabs)
    window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_containers_no_tabs)

    # Create docks for containters - tabs
    dw_containers_tabs = QtWidgets.QDockWidget()
    dw_containers_tabs.setObjectName('containers_tabs')
    uic.loadUi(os.path.join(here, 'ui/dw_containers_tabs.ui'),
               dw_containers_tabs)
    window.addDockWidget(QtCore.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 left 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 = QtWidgets.QStatusBar()
    qstatusbar.addWidget(
        QtWidgets.QLabel(
            'Issue Spyder #9120, #9121 - background not matching.'))
    qstatusbar.addWidget(QtWidgets.QPushButton('OK'))

    # Add info also in status bar for screenshots get it
    qstatusbar.addWidget(QtWidgets.QLabel('INFO: ' + title))
    window.setStatusBar(qstatusbar)

    # Todo: add report info and other info in HELP graphical

    # Auto quit after 2s when in test mode
    if args.test:
        QtCore.QTimer.singleShot(2000, app.exit)

    # Save screenshots for different displays and quit
    if args.screenshots:
        window.showFullScreen()
        create_screenshots(app, window, args)
    # Do not read settings when taking screenshots - like reset
    else:
        _read_settings(window, args.reset, QtCore.QSettings)
        window.showMaximized()

    app.exec_()
    _write_settings(window, QtCore.QSettings)
    args = parse_args()

    for arg in vars(args):
        print('[%s] =' % arg, getattr(args, arg))

    if(args.cpu_mode):
        args.gpu = -1

    args.win_size = int(args.win_size / 4.0) * 4  # make sure the width of the image can be divided by 4

    # initialize the colorization model
    colorModel = CI.ColorizeImageCaffe(Xd=args.load_size)
    colorModel.prep_net(args.gpu,args.color_prototxt,args.color_caffemodel)

    if (args.no_dist):
        distModel = None
    else:
        distModel = CI.ColorizeImageCaffeDist(Xd=args.load_size)
        distModel.prep_net(args.gpu,args.dist_prototxt,args.dist_caffemodel)

    # initialize application
    app = QApplication(sys.argv)
    window = gui_design.GUIDesign(color_model=colorModel, dist_model=distModel,
                                  img_file=args.image_file, load_size=args.load_size, win_size=args.win_size, user_study=args.user_study, ui_time=args.ui_time)
    app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))  # comment this if you do not like dark stylesheet
    app.setWindowIcon(QIcon('imgs/logo.png'))  # load logo
    window.setWindowTitle('iColor')
    window.setWindowFlags(window.windowFlags() & ~Qt.WindowMaximizeButtonHint)   # fix window siz
    window.show()
    app.exec_()
Ejemplo n.º 35
0
    def __init__(self):
        super().__init__()
        appid = 'HikyuuAdmin'
        QtWidgets.QApplication.setApplicationName(appid)
        QtWidgets.QApplication.setOrganizationName("org.hikyuu")

        # 国际化支持
        loc = QtCore.QLocale()
        if loc.language() == QtCore.QLocale.Chinese:
            self.trans = QtCore.QTranslator()
            self.trans.load("{}/language/zh_CN.qm".format(
                os.path.dirname(__file__)))  # 读取qm语言包
            _app = QtWidgets.QApplication.instance()  # 应用实例
            _app.installTranslator(self.trans)  # 将翻译者安装到实例中

        # 设置程序图标资源
        # 如未能正常显示图标,请检查 "import resource" 是否
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/logo/logo_16.png"))
        icon.addPixmap(QtGui.QPixmap(":/logo/logo_32.png"))
        icon.addPixmap(QtGui.QPixmap(":/logo/logo_48.png"))
        icon.addPixmap(QtGui.QPixmap(":/logo/logo_64.png"))
        icon.addPixmap(QtGui.QPixmap(":/logo/logo_128.png"))
        icon.addPixmap(QtGui.QPixmap(":/logo/logo_256.png"))
        self.setWindowIcon(icon)
        if sys.platform == 'win32':
            # window下设置任务栏图片
            import ctypes
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
                appid)

        self.ui_config = UiConfig()
        self.setObjectName("HikyuuAdminMainWindow")
        self.setWindowTitle(
            _translate("MainWindow", "Hikyuu Strategy Server Manager"))

        # 绑定本地数据库,辅助使用,尽量直接使用 Model 中的方法
        self.db = get_local_db()

        self.initAction()
        self.initMenuBar()
        self.initMenu()
        self.initToolBar()
        self.initActionConnect()
        self.initMainTabWidget()
        self.initDockWidgets()
        self.statusBar().showMessage(_translate('MainWindow', 'Running'))

        # 在窗口初始化完毕后,根据历史信息对窗口风格和大小进行重置
        style = self.ui_config.get('main_window',
                                   'style',
                                   fallback='normal_style')
        if style == 'dark_style':
            QtWidgets.qApp.setStyleSheet(
                qdarkstyle.load_stylesheet(qt_api='pyqt5'))

        if self.ui_config.getboolean('main_window',
                                     'maximized',
                                     fallback=False):
            self.showMaximized()
        else:
            self.resize(
                self.ui_config.getint('main_window', 'width', fallback=800),
                self.ui_config.getint('main_window', 'height', fallback=500))

        QtCore.QMetaObject.connectSlotsByName(self)
#!/usr/bin/python
import sys

try:
    from PySide2.QtCore import *
    from PySide2.QtGui import *
    from PySide2 import __version__
except ImportError:
    from PySide.QtCore import *
    from PySide.QtGui import *
    from PySide import __version__

from gui import assetManagerUI
reload(assetManagerUI)

import qdarkstyle

# Get entrypoint through which we control underlying Qt framework
app = QApplication([])

window = assetManagerUI.AssetManagerUI()
window.setStyleSheet(qdarkstyle.load_stylesheet())
window.show()

app.exec_()
sys.exit()
Ejemplo n.º 37
0
        print("You've decided to leave right?")
        # todo: call miniSQL stuff to finish up
        self.close()

    ''''''


''' End Class '''

if __name__ == '__main__':
    app = QApplication(sys.argv)
    font_db = QFontDatabase()
    font_name_list = os.listdir("font")

    for font_name in font_name_list:
        if font_name.endswith("ttf") or font_name.endswith(
                "otf") or font_name.endswith("ttc"):
            font_full_name = "font/" + font_name
            font_stream = QFile(font_full_name)
            if font_stream.open(QFile.ReadOnly):
                font_data = font_stream.readAll()
                font_id = font_db.addApplicationFontFromData(font_data)
                families = font_db.applicationFontFamilies(font_id)
    # todo: change to svg icon
    app.setWindowIcon(QIcon('figure/miniSQL.png'))
    style_sheet = qdarkstyle.load_stylesheet(qt_api='pyqt5')
    app.setStyleSheet(style_sheet)
    myGUI = CustomMainWindow()
    sys.exit(app.exec_())
''''''
Ejemplo n.º 38
0
def run_qtractor(
    func: Callable,
    args: Tuple,
    main_widget: QtGui.QWidget,
    tractor_kwargs: Dict[str, Any] = {},
    window_type: QtGui.QMainWindow = None,
) -> None:
    # avoids annoying message when entering debugger from qt loop
    pyqtRemoveInputHook()

    app = QtGui.QApplication.instance()
    if app is None:
        app = PyQt5.QtWidgets.QApplication([])

    # TODO: we might not need this if it's desired
    # to cancel the tractor machinery on Qt loop
    # close, however the details of doing that correctly
    # currently seem tricky..
    app.setQuitOnLastWindowClosed(False)

    # XXX: lmfao, this is how you disable text edit cursor blinking..smh
    app.setCursorFlashTime(0)

    # This code is from Nathaniel, and I quote:
    # "This is substantially faster than using a signal... for some
    # reason Qt signal dispatch is really slow (and relies on events
    # underneath anyway, so this is strictly less work)."

    # source gist and credit to njs:
    # https://gist.github.com/njsmith/d996e80b700a339e0623f97f48bcf0cb
    REENTER_EVENT = QtCore.QEvent.Type(QtCore.QEvent.registerEventType())

    class ReenterEvent(QtCore.QEvent):
        pass

    class Reenter(QtCore.QObject):
        def event(self, event):
            event.fn()
            return False

    reenter = Reenter()

    def run_sync_soon_threadsafe(fn):
        event = ReenterEvent(REENTER_EVENT)
        event.fn = fn
        app.postEvent(reenter, event)

    def done_callback(outcome):

        if isinstance(outcome, Error):
            exc = outcome.error

            if isinstance(outcome.error, KeyboardInterrupt):
                # make it kinda look like ``trio``
                print("Terminated!")

            else:
                traceback.print_exception(type(exc), exc, exc.__traceback__)

        app.quit()

    # load dark theme
    stylesheet = qdarkstyle.load_stylesheet(
        qt_api='pyqt5',
        palette=DarkPalette,
    )
    app.setStyleSheet(stylesheet)

    # make window and exec
    from . import _window

    if window_type is None:
        window_type = _window.MainWindow

    window = window_type()

    # set global app's main window singleton
    _window._qt_win = window

    # configure global DPI aware font sizes now that a screen
    # should be active from which we can read a DPI.
    _style._config_fonts_to_screen()

    # hook into app focus change events
    app.focusChanged.connect(window.on_focus_change)

    instance = main_widget()
    instance.window = window

    # override tractor's defaults
    tractor_kwargs.update(_tractor_kwargs)

    # define tractor entrypoint
    async def main():

        async with maybe_open_pikerd(**tractor_kwargs, ):
            await func(*((instance, ) + args))

    # guest mode entry
    trio.lowlevel.start_guest_run(
        main,
        run_sync_soon_threadsafe=run_sync_soon_threadsafe,
        done_callback=done_callback,
        # restrict_keyboard_interrupt_to_checkpoints=True,
    )

    window.main_widget = main_widget
    window.setCentralWidget(instance)
    if is_windows:
        window.configure_to_desktop()

    # actually render to screen
    window.show()
    app.exec_()
Ejemplo n.º 39
0
    def __init__(self):
        super().__init__()
        self.version = 1.1
        self.icon = self.processIcon(app_icon)

        # Add window icon
        self.setWindowIcon(self.icon)
        self.setupUi(self)
        self.setStyleSheet(load_stylesheet())

        # Main Props
        self.scanner = Scanner()
        self.killer = Killer()

        # Settings props
        self.minimize = True
        self.remember = False

        self.from_tray = False

        # We send elmocut to the settings window
        self.settings_window = Settings(self, self.icon)
        self.about_window = About(self, self.icon)

        self.applySettings()

        # Threading
        self.scan_thread = ScanThread()
        self.scan_thread.thread_finished.connect(self.ScanThread_Reciever)
        self.scan_thread.progress.connect(self.pgbar.setValue)

        # Connect buttons
        self.buttons = [
            (self.btnScanEasy, self.scanEasy, scan_easy_icon, 'Arping Scan'),
            (self.btnScanHard, self.scanHard, scan_hard_icon, 'Pinging Scan'),
            (self.btnKill, self.kill, kill_icon, 'Kill selected device'),
            (self.btnUnkill, self.unkill, unkill_icon,
             'Un-kill selected device'),
            (self.btnKillAll, self.killAll, killall_icon, 'Kill all devices'),
            (self.btnUnkillAll, self.unkillAll, unkillall_icon,
             'Un-kill all devices'),
            (self.btnSettings, self.openSettings, settings_icon,
             'View elmoCut settings'),
            (self.btnAbout, self.openAbout, about_icon, 'About elmoCut')
        ]

        for btn, btn_func, btn_icon, btn_tip in self.buttons:
            btn.setToolTip(btn_tip)
            btn.clicked.connect(btn_func)
            btn.setIcon(self.processIcon(btn_icon))

        self.pgbar.setVisible(False)

        # Table Widget
        self.tableScan.itemClicked.connect(self.deviceClicked)
        self.tableScan.cellClicked.connect(self.cellClicked)
        self.tableScan.setColumnCount(4)
        self.tableScan.verticalHeader().setVisible(False)
        self.tableScan.setHorizontalHeaderLabels(
            ['IP Address', 'MAC Address', 'Vendor', 'Type'])
        '''
           System tray icon and it's tray menu
        '''
        show_option = QAction('Show', self)
        hide_option = QAction('Hide', self)
        quit_option = QAction('Quit', self)
        kill_option = QAction(self.processIcon(kill_icon), '&Kill All', self)
        unkill_option = QAction(self.processIcon(unkill_icon), '&Unkill All',
                                self)

        show_option.triggered.connect(self.show)
        hide_option.triggered.connect(self.hide_all)
        quit_option.triggered.connect(self.quit_all)
        kill_option.triggered.connect(self.killAll)
        unkill_option.triggered.connect(self.unkillAll)

        tray_menu = QMenu()
        tray_menu.addAction(show_option)
        tray_menu.addAction(hide_option)
        tray_menu.addSeparator()
        tray_menu.addAction(kill_option)
        tray_menu.addAction(unkill_option)
        tray_menu.addSeparator()
        tray_menu.addAction(quit_option)

        self.tray_icon = QSystemTrayIcon(self)
        self.tray_icon.setIcon(self.icon)
        self.tray_icon.setToolTip('elmoCut')
        self.tray_icon.setContextMenu(tray_menu)
        self.tray_icon.show()
        self.tray_icon.activated.connect(self.tray_clicked)
Ejemplo n.º 40
0
def main():
    """Execute QDarkStyle example."""
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        '--qt_from',
        default='qtpy',
        type=str,
        choices=[
            'pyqt5', 'pyqt', 'pyside2', 'pyside', 'qtpy', 'pyqtgraph', 'qt.py'
        ],
        help=
        "Choose which binding and/or abstraction is to be used to run the example."
    )
    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) then opens.")
    parser.add_argument('--screenshots',
                        action='store_true',
                        help="Generate screenshots on images folder.")

    # Parsing arguments from command line
    args = parser.parse_args()

    # To avoid problems when testing without screen
    if args.test or args.screenshots:
        os.environ['QT_QPA_PLATFORM'] = 'offscreen'

    # Set QT_API variable before importing QtPy
    if args.qt_from in ['pyqt', 'pyqt5', 'pyside', 'pyside2']:
        os.environ['QT_API'] = args.qt_from
    elif args.qt_from == 'pyqtgraph':
        os.environ['QT_API'] = os.environ['PYQTGRAPH_QT_LIB']
    elif args.qt_from in ['qt.py', 'qt']:
        try:
            import Qt
        except ImportError:
            print('Could not import Qt (Qt.Py)')
        else:
            os.environ['QT_API'] = Qt.__binding__

    # QtPy imports
    from qtpy import API_NAME, QT_VERSION, PYQT_VERSION, PYSIDE_VERSION
    from qtpy import __version__ as QTPY_VERSION
    from qtpy.QtWidgets import (QApplication, QMainWindow, QDockWidget,
                                QStatusBar, QLabel, QPushButton, QMenu)
    from qtpy.QtCore import QTimer, Qt, QSettings

    # Set API_VERSION variable
    API_VERSION = ''

    if PYQT_VERSION:
        API_VERSION = PYQT_VERSION
    elif PYSIDE_VERSION:
        API_VERSION = PYSIDE_VERSION
    else:
        API_VERSION = 'Not found'

    # Import examples UI
    from mw_menus_ui import Ui_MainWindow as ui_main

    from dw_buttons_ui import Ui_DockWidget as ui_buttons
    from dw_displays_ui import Ui_DockWidget as ui_displays
    from dw_inputs_fields_ui import Ui_DockWidget as ui_inputs_fields
    from dw_inputs_no_fields_ui import Ui_DockWidget as ui_inputs_no_fields

    from dw_widgets_ui import Ui_DockWidget as ui_widgets
    from dw_views_ui import Ui_DockWidget as ui_views
    from dw_containers_tabs_ui import Ui_DockWidget as ui_containers_tabs
    from dw_containers_no_tabs_ui import Ui_DockWidget as ui_containers_no_tabs

    # create the application
    app = QApplication(sys.argv)
    app.setOrganizationName('QDarkStyle')
    app.setApplicationName('QDarkStyle Example')

    style = ''

    if not args.no_dark:
        style = qdarkstyle.load_stylesheet()

    app.setStyleSheet(style)

    # create main window
    window = QMainWindow()
    window.setObjectName('mainwindow')

    ui = ui_main()
    ui.setupUi(window)

    title = ("QDarkStyle Example - " + "(QDarkStyle=v" +
             qdarkstyle.__version__ + ", QtPy=v" + QTPY_VERSION + ", " +
             API_NAME + "=v" + API_VERSION + ", Qt=v" + QT_VERSION +
             ", Python=v" + platform.python_version() + ")")

    _logger.info(title)

    window.setWindowTitle(title)

    # 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)

    # Add actions on popup toolbuttons
    menu = QMenu()

    for action in ['Action A', 'Action B', 'Action C']:
        menu.addAction(action)

    ui_buttons.toolButtonDelayedPopup.setMenu(menu)
    ui_buttons.toolButtonInstantPopup.setMenu(menu)
    ui_buttons.toolButtonMenuButtonPopup.setMenu(menu)

    # 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('inputs_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_tabs')
    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 left 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'))

    # Add info also in status bar for screenshots get it
    qstatusbar.addWidget(QLabel('INFO: ' + title))
    window.setStatusBar(qstatusbar)

    # Todo: add report info and other info in HELP graphical

    # Auto quit after 2s when in test mode
    if args.test:
        QTimer.singleShot(2000, app.exit)

    # Save screenshots for different displays and quit
    if args.screenshots:
        window.showFullScreen()
        create_screenshots(app, window, args.no_dark)
    # Do not read settings when taking screenshots - like reset
    else:
        _read_settings(window, args.reset, QSettings)
        window.showMaximized()

    app.exec_()
    _write_settings(window, QSettings)
Ejemplo n.º 41
0
        newitem = QtGui.QStandardItem(item.text())
        newitem.setEditable(False)
        
        # Remove item from similar list
        self.modelSimilar.removeRow(index.row())
        self.lstSimilar.setModel(self.modelSimilar)
        
        # Move to search list
        self.modelSearch.appendRow(newitem)
        self.lstSearch.setModel(self.modelSearch)
        
    def eventFilter(self, obj, event):
        # Call the search function if you press Return
        if event.type() == QtCore.QEvent.KeyPress and event.key() == QtCore.Qt.Key_Return:
            self.search()
            return True
        # Default case, writes text to the textbox
        QtGui.QWidget.eventFilter(self, obj, event)
        return False

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    myapp = MyDialog()
    app.setStyleSheet(qdarkstyle.load_stylesheet()) # For dark theme
    myapp.show()
    sys.exit(app.exec_())

    # Close the sql connection
    cursor.close()
    conn.close()
Ejemplo n.º 42
0
    def __init__(self, application, runtime, args, open_file=True):
        super(PETreeWindow, self).__init__()

        self.application = application

        # Create container widget, runtime and PE Tree form
        widget = QtWidgets.QWidget()
        self.runtime = runtime(widget, args)
        self.pe_tree_form = pe_tree.form.PETreeForm(widget, application,
                                                    self.runtime)
        self.pe_tree_form.dispatcher = application.eventDispatcher()
        application.aboutToQuit.connect(self.pe_tree_form.wait_for_threads)
        self.runtime.pe_tree_form = self.pe_tree_form

        if HAVE_DARKSTYLE:
            application.setStyleSheet(
                qdarkstyle.load_stylesheet(qt_api="pyqt5"))

        self.setWindowTitle(pe_tree.info.__title__)
        self.resize(1024, 768)
        self.setCentralWidget(widget)
        self.setAcceptDrops(True)

        # Construct application main menu
        self.open_menu = QtWidgets.QMenu("Open", self)

        open_file_action = QtWidgets.QAction("File", self)
        open_file_action.setShortcut("Ctrl+O")
        open_file_action.setStatusTip("Open PE file")
        open_file_action.triggered.connect(self.open_file)

        open_directory_action = QtWidgets.QAction("Folder", self)
        open_directory_action.setShortcut("Ctrl+Shift+O")
        open_directory_action.setStatusTip("Scan folder for PE files")
        open_directory_action.triggered.connect(self.open_folder)

        self.open_menu.addAction(open_file_action)
        self.open_menu.addAction(open_directory_action)

        exit_action = QtWidgets.QAction("Exit", self)
        exit_action.setShortcut("Ctrl+X")
        exit_action.setStatusTip("Exit")
        exit_action.triggered.connect(application.quit)

        about_action = QtWidgets.QAction("About", self)
        about_action.triggered.connect(self.runtime.about_box)

        menu = self.menuBar()
        file_menu = menu.addMenu("&File")
        file_menu.addMenu(self.open_menu)
        file_menu.addAction(exit_action)

        help_menu = menu.addMenu("&Help")
        help_menu.addAction(about_action)

        self.showMaximized()

        # Process command line
        if open_file:
            if args.filenames:
                # Map all files/folders specified on the command line
                for filename in args.filenames:
                    if os.path.exists(filename):
                        self.pe_tree_form.threadpool.start(
                            pe_tree.scandir.ScanDir(self.pe_tree_form,
                                                    filename))
            else:
                # Ask user to select file/folder
                self.open_file()
Ejemplo n.º 43
0
# encoding: UTF-8

from vnpy.trader.uiBackMainWindow import *
import qdarkstyle  #Qt黑色主题
from vnpy.trader.widget.BackManage import *

import sys

reload(sys)
sys.setdefaultencoding('utf8')

if __name__ == '__main__':  #加载本地trade.csv合约数据
    optKType = ["15min"
                ]  ## 操作周期k线类型   1min  3min  5min  15min  30min  60min  day
    app = QtWidgets.QApplication(sys.argv)
    styleSheet = qdarkstyle.load_stylesheet(pyside=False)
    app.setStyleSheet(styleSheet)

    main = MainWindow()
    tradePath = getTempPath("trade.csv")
    abc = BackManager(main, tradePath, "G:/tick_bar/rb/", optKType)

    main.showMaximized()
    main.show()
    app.exec_()
Ejemplo n.º 44
0
            return None
        self.users_edit.clear()
        self.user_txtarea.append(user_word)

        # サーバー(エンジン)へユーザワードを送信
        self.operator.send(user_word)

    @Slot()
    def speak_ai(self, word):
        # AIのトークを表示
        # ディレイを使ってテンポを整える
        def wrapper():
            self.ai_txtarea.append(word)

        QTimer.singleShot(TALK_DELAY, wrapper)


if __name__ == '__main__':

    import traceback

    try:
        app = QApplication(sys.argv)
        app.setStyleSheet(qdarkstyle.load_stylesheet())
        dialog = CardBordAIApp()
        dialog.show()
        sys.exit(app.exec_())
    except:
        # logger.error(traceback.format_exc())
        print(traceback.format_exc())
Ejemplo n.º 45
0
    def __init__(self, dev=False, preload=False):
        super().__init__()
        self.title = 'cidan'
        scale = (self.logicalDpiX() / 96.0 - 1) / 2 + 1
        sizeObject = QtGui.QGuiApplication.primaryScreen().availableGeometry()

        self.width = 1500 * scale
        self.height = 1066.6 * scale
        if self.height > sizeObject.height() * .95:
            self.height = sizeObject.height() * .95
        if self.width > sizeObject.width() * .95:
            self.width = sizeObject.width() * .95
        self.setWindowTitle(self.title)
        self.setMinimumSize(int(self.width), int(self.height))
        self.main_menu = self.menuBar()
        self.setContentsMargins(0, 0, 0, 0)

        import cidan
        cidanpath = os.path.dirname(os.path.realpath(cidan.__file__))
        print(cidanpath)
        icon_path = os.path.join(cidanpath, "logo", "logo.png")

        app_icon = QtGui.QIcon()
        app_icon.addFile(icon_path, QtCore.QSize(16, 16))
        app_icon.addFile(icon_path, QtCore.QSize(24, 24))
        app_icon.addFile(icon_path, QtCore.QSize(32, 32))
        app_icon.addFile(icon_path, QtCore.QSize(48, 48))
        app_icon.addFile(icon_path, QtCore.QSize(96, 96))
        app_icon.addFile(icon_path, QtCore.QSize(256, 256))
        self.setWindowIcon(app_icon)
        self.table_widget = MainWidget(self, dev=dev, preload=preload)
        self.setCentralWidget(self.table_widget)
        # self.setStyleSheet(qdarkstyle.load_stylesheet())
        style = str("""
            
            QWidget {font-size: %dpx;}
            QTabWidget {font-size: %dpx; padding:0px; margin:%dpx;
                border:0px;}
            QTabBar::tab {
                background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                           stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
                                          stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
                /*border: 2px solid #C4C4C3;*/
                /*border-bottom-color: #C2C7CB; !* same as the pane color *!*/
                
                min-width: 8ex;
                padding:%dpx;
                border:%dpx;
            }
            
            QComboBox::item:checked {
              font-weight: bold;
              height: %dpx;
            }
            """ % (20 * scale, 20 * scale, 0 * scale, 0 * scale, 0 * scale,
                   20 * scale))
        self.setStyleSheet(qdarkstyle.load_stylesheet() + style)

        # extractAction.triggered.connect()

        self.show()
Ejemplo n.º 46
0
	def __init__(self, ba=None, bPlugin=None, startStop=None, options=None, parent=None):
		"""
		Args:
			ba (sanpy.bAnalysis): [bAnalysis][sanpy.bAnalysis.bAnalysis] object representing one file.
			bPlugin (sanpy.interface.bPlugin): Used in Qt to get SanPy App and to set up signal/slot.
			startStop (list of float): Start and stop (s) of x-axis.
			options (dict): Dictionary of optional plugins.
							Used by 'plot tool' to plot a pool using app analysisDir dfMaster.
							Note: NOT USED.
		"""
		super(sanpyPlugin, self).__init__(parent)
		self._ba = ba
		self._bPlugins = bPlugin # pointer to object, send signal back on close

		self._sweepNumber = 0

		if startStop is not None:
			self._startSec = startStop[0]
			self._stopSec = startStop[1]
		else:
			self._startSec = None
			self._stopSec = None

		# keep track of analysis parameters
		#self.fileRowDict = None  # for detectionParams plugin

		# TODO: keep track of spike selection
		self.selectedSpike = None
		self.selectedSpikeList = []

		self.windowTitle = 'xxx'

		#
		# build a dict of boolean from ResponseType enum class
		self.responseOptions = {}
		for option in (self.responseTypes):
			#print(type(option))
			self.responseOptions[option.name] = True

		# created in self.pyqtWindow()
		#self.mainWidget = QtWidgets.QWidget()

		doDark = True
		if doDark and qdarkstyle is not None:
			self.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
		else:
			self.setStyleSheet("")

		#self.scrollArea = QtWidgets.QScrollArea()
		#self.scrollArea.setWidget(self)

		self.layout = None

		# created in self.mplWindow()
		self.fig = None
		self.ax = None
		self.mplToolbar = None

		self.keyIsDown = None

		self.winWidth_inches = 4  # used by mpl
		self.winHeight_inches = 4

		# connect self to main app with signals/slots
		self._installSignalSlot()
Ejemplo n.º 47
0
 def actionChangStyle(self):
     QtWidgets.qApp.setStyleSheet('')
     style_name = self.sender().objectName()
     if style_name == 'dark_style':
         QtWidgets.qApp.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
     self.ui_config.set('main_window', 'style', style_name)
Ejemplo n.º 48
0
    def initUI(self):

        self.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
        '''
		myPath = os.path.dirname(os.path.abspath(__file__))
		mystylesheet_css = os.path.join(myPath, 'css', 'mystylesheet.css')
		myStyleSheet = None
		if os.path.isfile(mystylesheet_css):
			with open(mystylesheet_css) as f:
				myStyleSheet = f.read()

		if myStyleSheet is not None:
			self.setStyleSheet(myStyleSheet)
		'''

        #self.setGeometry(100, 100, 1000, 600)
        self.center()

        if self.path:
            windowTitle = os.path.split(self.path)[1]
            self.setWindowTitle('Export Trace: ' + windowTitle)
        else:
            self.setWindowTitle('Export Trace: ' + 'None')

        myAlignLeft = QtCore.Qt.AlignLeft
        myAlignTop = QtCore.Qt.AlignTop

        hMasterLayout = QtWidgets.QHBoxLayout()
        hMasterLayout.setAlignment(QtCore.Qt.AlignTop)
        self.setLayout(hMasterLayout)

        left_container = QtWidgets.QWidget(self)
        left_container.setFixedWidth(350)

        hMasterLayout.addWidget(left_container, myAlignTop)

        vBoxLayout = QtWidgets.QVBoxLayout(left_container)  # VBox for controls
        vBoxLayout.setAlignment(QtCore.Qt.AlignTop)

        hBoxRow0 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow0, myAlignTop)

        #
        # first row of controls

        # x axis on/off (todo: does not need self)
        self.xAxisCheckBox = QtWidgets.QCheckBox('')
        self.xAxisCheckBox.setToolTip('Toggle X-Axis On/Off')
        self.xAxisCheckBox.setChecked(True)
        self.xAxisCheckBox.stateChanged.connect(self.xAxisToggle)
        hBoxRow0.addWidget(self.xAxisCheckBox, myAlignLeft)

        # x min
        xMinLabel = QtWidgets.QLabel('X-Min')
        hBoxRow0.addWidget(xMinLabel, myAlignLeft)
        self.xMinSpinBox = QtWidgets.QDoubleSpinBox()
        self.xMinSpinBox.setToolTip('X-Axis Minimum')
        self.xMinSpinBox.setSingleStep(0.1)
        self.xMinSpinBox.setMinimum(-1e6)
        self.xMinSpinBox.setMaximum(1e6)
        self.xMinSpinBox.setValue(0)
        self.xMinSpinBox.setToolTip('X-Axis Minimum')
        self.xMinSpinBox.setKeyboardTracking(False)
        self.xMinSpinBox.valueChanged.connect(self._setXAxis)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow0.addWidget(self.xMinSpinBox, myAlignLeft)

        # x max
        xMax = np.nanmax(
            self.mySweepX_Downsample)  # self.mySweepX_Downsample[-1]
        xMaxLabel = QtWidgets.QLabel('X-Max')
        hBoxRow0.addWidget(xMaxLabel, myAlignLeft)
        self.xMaxSpinBox = QtWidgets.QDoubleSpinBox()
        self.xMaxSpinBox.setToolTip('X-Axis Maximum')
        self.xMaxSpinBox.setSingleStep(0.1)
        self.xMaxSpinBox.setMinimum(-1e6)
        self.xMaxSpinBox.setMaximum(1e6)
        self.xMaxSpinBox.setValue(xMax)
        self.xMaxSpinBox.setToolTip('X-Axis Maximum')
        self.xMaxSpinBox.setKeyboardTracking(False)
        self.xMaxSpinBox.valueChanged.connect(self._setXAxis)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow0.addWidget(self.xMaxSpinBox, myAlignLeft)

        #
        # second row
        hBoxRow1 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow1)

        # y axis
        self.yAxisCheckBox = QtWidgets.QCheckBox('')
        self.yAxisCheckBox.setToolTip('Toggle Y-Axis On/Off')
        self.yAxisCheckBox.setChecked(True)
        self.yAxisCheckBox.stateChanged.connect(self.yAxisToggle)
        hBoxRow1.addWidget(self.yAxisCheckBox)

        # y min
        yMinLabel = QtWidgets.QLabel('Y-Min')
        hBoxRow1.addWidget(yMinLabel)
        yMinValue = np.nanmin(self.mySweepY_Downsample)
        self.yMinSpinBox = QtWidgets.QDoubleSpinBox()
        self.yMinSpinBox.setSingleStep(0.1)
        self.yMinSpinBox.setMinimum(-1e6)
        self.yMinSpinBox.setMaximum(1e6)
        self.yMinSpinBox.setValue(yMinValue)  # flipped
        self.yMinSpinBox.setToolTip('Y-Axis Minimum')
        self.yMinSpinBox.setKeyboardTracking(False)
        self.yMinSpinBox.valueChanged.connect(self._setYAxis)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow1.addWidget(self.yMinSpinBox)

        # y max
        yMaxLabel = QtWidgets.QLabel('Y-Max')
        hBoxRow1.addWidget(yMaxLabel)
        yMaxValue = np.nanmax(self.mySweepY_Downsample)
        self.yMaxSpinBox = QtWidgets.QDoubleSpinBox()
        self.yMaxSpinBox.setSingleStep(0.1)
        self.yMaxSpinBox.setMinimum(-1e6)
        self.yMaxSpinBox.setMaximum(1e6)
        self.yMaxSpinBox.setValue(yMaxValue)  # flipped
        self.yMaxSpinBox.setToolTip('Y-Axis Maximum')
        self.yMaxSpinBox.setKeyboardTracking(False)
        self.yMaxSpinBox.valueChanged.connect(self._setYAxis)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow1.addWidget(self.yMaxSpinBox)

        #
        # one 1/2 row
        hBoxRow1_5 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow1_5)

        # x-tick major
        lineWidthLabel = QtWidgets.QLabel('X-Tick Major')
        hBoxRow1_5.addWidget(lineWidthLabel)
        self.xTickIntervalSpinBox = QtWidgets.QDoubleSpinBox()
        self.xTickIntervalSpinBox.setSingleStep(0.1)
        self.xTickIntervalSpinBox.setMinimum(0.0)
        self.xTickIntervalSpinBox.setMaximum(1e6)
        self.xTickIntervalSpinBox.setValue(10)
        self.xTickIntervalSpinBox.setToolTip(
            'Major Tick Interval, 0 To Turn Off')
        self.xTickIntervalSpinBox.setKeyboardTracking(False)
        self.xTickIntervalSpinBox.valueChanged.connect(
            self._setTickMajorInterval)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow1_5.addWidget(self.xTickIntervalSpinBox)

        # x-tick minor
        lineWidthLabel = QtWidgets.QLabel('Minor')
        hBoxRow1_5.addWidget(lineWidthLabel)
        self.xTickMinorIntervalSpinBox = QtWidgets.QDoubleSpinBox()
        self.xTickMinorIntervalSpinBox.setSingleStep(0.1)
        self.xTickMinorIntervalSpinBox.setMinimum(0.0)
        self.xTickMinorIntervalSpinBox.setMaximum(1e6)
        self.xTickMinorIntervalSpinBox.setValue(10)
        self.xTickMinorIntervalSpinBox.setToolTip(
            'Minor Tick Interval, 0 To Turn Off')
        self.xTickMinorIntervalSpinBox.setKeyboardTracking(False)
        self.xTickMinorIntervalSpinBox.valueChanged.connect(
            self._setTickMinorInterval)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow1_5.addWidget(self.xTickMinorIntervalSpinBox)

        #
        # one 3/4 row
        hBoxRow1_ytick = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow1_ytick)

        # y-tick major
        lineWidthLabel = QtWidgets.QLabel('Y-Tick Major')
        hBoxRow1_ytick.addWidget(lineWidthLabel)
        self.yTickIntervalSpinBox = QtWidgets.QDoubleSpinBox()
        self.yTickIntervalSpinBox.setSingleStep(0.1)
        self.yTickIntervalSpinBox.setMinimum(0.0)
        self.yTickIntervalSpinBox.setMaximum(1e6)
        self.yTickIntervalSpinBox.setValue(20)
        self.yTickIntervalSpinBox.setToolTip(
            'Major Y-Tick Interval, 0 To Turn Off')
        self.yTickIntervalSpinBox.setKeyboardTracking(False)
        self.yTickIntervalSpinBox.valueChanged.connect(
            self._setYTickMajorInterval)
        #todo: FIX THIS RECURSION WITH USING UP/DOWN ARROWS
        #self.yTickIntervalSpinBox.editingFinished.connect(self._setYTickMajorInterval)
        hBoxRow1_ytick.addWidget(self.yTickIntervalSpinBox)

        # y-tick minor
        lineWidthLabel = QtWidgets.QLabel('Minor')
        hBoxRow1_ytick.addWidget(lineWidthLabel)
        self.yTickMinorIntervalSpinBox = QtWidgets.QDoubleSpinBox()
        self.yTickMinorIntervalSpinBox.setSingleStep(0.1)
        self.yTickMinorIntervalSpinBox.setMinimum(0.0)
        self.yTickMinorIntervalSpinBox.setMaximum(1e6)
        self.yTickMinorIntervalSpinBox.setValue(20)
        self.yTickMinorIntervalSpinBox.setToolTip(
            'Minor Y-Tick Interval, 0 To Turn Off')
        self.yTickMinorIntervalSpinBox.setKeyboardTracking(False)
        self.yTickMinorIntervalSpinBox.valueChanged.connect(
            self._setYTickMinorInterval)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow1_ytick.addWidget(self.yTickMinorIntervalSpinBox)

        #
        # third row
        hBoxRow2 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow2)

        # x margin
        xMaxLabel = QtWidgets.QLabel('X-Margin')
        hBoxRow2.addWidget(xMaxLabel)
        self.xMarginSpinBox = QtWidgets.QDoubleSpinBox()
        self.xMarginSpinBox.setToolTip('X-Axis Maximum')
        self.xMarginSpinBox.setSingleStep(0.1)
        self.xMarginSpinBox.setMinimum(0)
        self.xMarginSpinBox.setMaximum(1e6)
        self.xMarginSpinBox.setValue(self.xMargin)
        self.xMarginSpinBox.setKeyboardTracking(False)
        self.xMarginSpinBox.valueChanged.connect(self._setXMargin)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow2.addWidget(self.xMarginSpinBox)

        #
        # fourth row
        hBoxRow3 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow3)

        # line width
        lineWidthLabel = QtWidgets.QLabel('Line Width')
        hBoxRow3.addWidget(lineWidthLabel)
        self.lineWidthSpinBox = QtWidgets.QDoubleSpinBox()
        self.lineWidthSpinBox.setSingleStep(0.1)
        self.lineWidthSpinBox.setMinimum(0.01)
        self.lineWidthSpinBox.setMaximum(100.0)
        self.lineWidthSpinBox.setValue(0.5)
        self.lineWidthSpinBox.setKeyboardTracking(False)
        self.lineWidthSpinBox.valueChanged.connect(self._setLineWidth)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        hBoxRow3.addWidget(self.lineWidthSpinBox)

        # color
        colorList = [
            'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black',
            'white'
        ]
        wIdx = colorList.index('white')
        kIdx = colorList.index('black')
        colorLabel = QtWidgets.QLabel('Line Color')
        hBoxRow3.addWidget(colorLabel)
        self.colorDropdown = QtWidgets.QComboBox()
        self.colorDropdown.addItems(colorList)
        self.colorDropdown.setCurrentIndex(wIdx if self.darkTheme else kIdx)
        self.colorDropdown.currentIndexChanged.connect(self._setLineColor)
        hBoxRow3.addWidget(self.colorDropdown)

        #
        # fifth row
        hBoxRow4 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow4)

        # downsample
        downsampleLabel = QtWidgets.QLabel('Downsample')
        hBoxRow4.addWidget(downsampleLabel)
        self.downSampleSpinBox = QtWidgets.QSpinBox()
        self.downSampleSpinBox.setSingleStep(1)
        self.downSampleSpinBox.setMinimum(1)
        self.downSampleSpinBox.setMaximum(200)
        self.downSampleSpinBox.setValue(1)
        self.downSampleSpinBox.setKeyboardTracking(False)
        self.downSampleSpinBox.valueChanged.connect(self._setDownSample)
        #self.downSampleSpinBox.editingFinished.connect(self._setDownSample)
        hBoxRow4.addWidget(self.downSampleSpinBox)

        # meadianFilter
        medianFilterLabel = QtWidgets.QLabel('Median Filter (points)')
        hBoxRow4.addWidget(medianFilterLabel)
        self.medianFilterSpinBox = QtWidgets.QSpinBox()
        #self.medianFilterSpinBox.setStyle(CustomStyle())
        self.medianFilterSpinBox.setSingleStep(2)
        self.medianFilterSpinBox.setMinimum(1)
        self.medianFilterSpinBox.setMaximum(1000)
        self.medianFilterSpinBox.setValue(1)
        self.medianFilterSpinBox.setKeyboardTracking(False)
        self.medianFilterSpinBox.valueChanged.connect(self._setDownSample)
        #self.medianFilterSpinBox.editingFinished.connect(self._setDownSample)
        hBoxRow4.addWidget(self.medianFilterSpinBox)

        #
        # fifth row
        hBoxRow4_5 = QtWidgets.QHBoxLayout()
        vBoxLayout.addLayout(hBoxRow4_5, myAlignTop)

        # dark theme
        self.darkThemeCheckBox = QtWidgets.QCheckBox('Dark Theme')
        self.darkThemeCheckBox.setChecked(self.darkTheme)
        self.darkThemeCheckBox.stateChanged.connect(self._changeTheme)
        hBoxRow4_5.addWidget(self.darkThemeCheckBox)

        #
        # sixth row
        scaleBarGroupBox = QtWidgets.QGroupBox('Scale Bar')
        scaleBarGroupBox.setAlignment(myAlignTop)
        vBoxLayout.addWidget(scaleBarGroupBox, myAlignTop)

        gridBoxScaleBar = QtWidgets.QGridLayout()
        scaleBarGroupBox.setLayout(gridBoxScaleBar)

        hLength = self.scaleBarDict['hLength']
        vLength = self.scaleBarDict['vLength']
        lineWidth = self.scaleBarDict['lineWidth']

        # scale bar width (length)
        scaleBarWidthLabel = QtWidgets.QLabel('Width')
        gridBoxScaleBar.addWidget(scaleBarWidthLabel, 0, 0)
        self.scaleBarWidthSpinBox = QtWidgets.QDoubleSpinBox()
        self.scaleBarWidthSpinBox.setToolTip('X Scale Bar Width (0 to remove)')
        self.scaleBarWidthSpinBox.setSingleStep(0.1)
        self.scaleBarWidthSpinBox.setMinimum(-1e6)
        self.scaleBarWidthSpinBox.setMaximum(1e6)
        self.scaleBarWidthSpinBox.setValue(hLength)
        self.scaleBarWidthSpinBox.setKeyboardTracking(False)
        self.scaleBarWidthSpinBox.valueChanged.connect(self._setScaleBarSize)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        gridBoxScaleBar.addWidget(self.scaleBarWidthSpinBox, 0, 1)

        # scale bar height (length)
        scaleBarHeightLabel = QtWidgets.QLabel('Height')
        gridBoxScaleBar.addWidget(scaleBarHeightLabel, 1, 0)
        self.scaleBarHeightSpinBox = QtWidgets.QDoubleSpinBox()
        self.scaleBarHeightSpinBox.setToolTip(
            'Y Scale Bar Height (0 to remove)')
        self.scaleBarHeightSpinBox.setSingleStep(0.1)
        self.scaleBarHeightSpinBox.setMinimum(-1e6)
        self.scaleBarHeightSpinBox.setMaximum(1e6)
        self.scaleBarHeightSpinBox.setValue(vLength)
        self.scaleBarHeightSpinBox.setKeyboardTracking(False)
        self.scaleBarHeightSpinBox.valueChanged.connect(self._setScaleBarSize)
        #self.lineWidthSpinBox.editingFinished.connect(self._setLineWidth)
        gridBoxScaleBar.addWidget(self.scaleBarHeightSpinBox, 1, 1)

        # scale bar line thickness
        scaleBarThicknessLabel = QtWidgets.QLabel('Thickness')
        gridBoxScaleBar.addWidget(scaleBarThicknessLabel, 2, 0)
        self.scaleBarThicknessSpinBox = QtWidgets.QDoubleSpinBox()
        self.scaleBarThicknessSpinBox.setToolTip('Scale Bar Thickness')
        self.scaleBarThicknessSpinBox.setSingleStep(1)
        self.scaleBarThicknessSpinBox.setMinimum(0.1)
        self.scaleBarThicknessSpinBox.setMaximum(1e6)
        self.scaleBarThicknessSpinBox.setValue(lineWidth)
        self.scaleBarThicknessSpinBox.setKeyboardTracking(False)
        self.scaleBarThicknessSpinBox.valueChanged.connect(
            self._setScaleBarThickness)
        gridBoxScaleBar.addWidget(self.scaleBarThicknessSpinBox, 2, 1)

        # save button
        saveButton = QtWidgets.QPushButton('Save', self)
        saveButton.resize(saveButton.sizeHint())
        saveButton.clicked.connect(self.save)
        vBoxLayout.addWidget(saveButton)

        #vBoxLayout.addStretch()

        self.figure = matplotlib.figure.Figure()
        self.canvas = FigureCanvas(self.figure)

        # set defaullt save name
        baseName = 'export'
        if self.path:
            baseName = os.path.splitext(self.path)[0]
        self.canvas.get_default_filename = lambda: f'{baseName}'

        # matplotlib navigation toolbar
        self.toolbar = NavigationToolbar(self.canvas, self)
        #self.toolbar.zoom()

        # need self. here to set theme
        self.plotVBoxLayout = QtWidgets.QVBoxLayout()
        self.plotVBoxLayout.addWidget(self.toolbar)
        self.plotVBoxLayout.addWidget(self.canvas)

        hMasterLayout.addLayout(self.plotVBoxLayout)  #, stretch=8)

        #self.myAxis = None
        self.plotRaw(firstPlot=True)

        self.show()
Ejemplo n.º 49
0
    def settingsPushed(self):
        self.settingsDialog = QDialog()
        self.settingsDialog.setStyleSheet(qdarkstyle.load_stylesheet())
        self.settingsDialog.setWindowTitle("Settings")
        
        layout = QVBoxLayout(self.settingsDialog)
        
        # com_widget = QComboBox(self.settingsDialog)
        # self.list_ports()
        # com_widget.addItems(self.com_ports)
        # com_widget.setCurrentIndex(self.com_ports.index(self.COM))
        # layout.addWidget(com_widget)
        
        fs_layout = QHBoxLayout()
        fs_label = QLabel()
        fs_label.setText("Sampling Rate (fs)")
        fs_widget = QLineEdit(self.settingsDialog)
        fs_widget.setText(str(self.fs))
        fs_layout.addWidget(fs_label)
        fs_layout.addWidget(fs_widget)
        layout.addLayout(fs_layout)
        
        N_layout = QHBoxLayout()
        N_label = QLabel()
        N_label.setText("Number of Samples (N)")
        N_widget = QLineEdit(self.settingsDialog)
        N_widget.setText(str(self.N))
        N_layout.addWidget(N_label)
        N_layout.addWidget(N_widget)
        layout.addLayout(N_layout)
        
        delay_layout = QHBoxLayout()
        delay_label = QLabel()
        delay_label.setText("Record Delay (s)")
        delay_widget = QLineEdit(self.settingsDialog)
        delay_widget.setText(str(self.delay))
        delay_layout.addWidget(delay_label)
        delay_layout.addWidget(delay_widget)
        layout.addLayout(delay_layout)
        
        R1_layout = QHBoxLayout()
        R1_label = QLabel()
        R1_label.setText("Resistor 1 (Ohm)")
        R1_widget = QLineEdit(self.settingsDialog)
        R1_widget.setText(str(self.R1))
        R1_layout.addWidget(R1_label)
        R1_layout.addWidget(R1_widget)
        layout.addLayout(R1_layout)
        
        R2_layout = QHBoxLayout()
        R2_label = QLabel()
        R2_label.setText("Resistor 2 (Ohm)")
        R2_widget = QLineEdit(self.settingsDialog)
        R2_widget.setText(str(self.R2))
        R2_layout.addWidget(R2_label)
        R2_layout.addWidget(R2_widget)
        layout.addLayout(R2_layout)
        
        buttonBox = QDialogButtonBox(QDialogButtonBox.Save
                             | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.settingsDialog.accept)
        buttonBox.rejected.connect(self.settingsDialog.reject)
        layout.addWidget(buttonBox)
        
        self.settingsDialog.setLayout(layout)
        
        if self.settingsDialog.exec_() == QDialog.Accepted:
            self.fs = int(fs_widget.text())
            self.N = int(N_widget.text())
            self.dt = 1.0/self.fs
            self.sample_time = self.N*self.dt
            
            # if self.fs > 1000:
                # print('WARNING: sample rate for the Accelerometer must not exceed 1000 Hz.')

            self.delay = int(delay_widget.text())
            
            self.R1 = int(R1_widget.text())
            self.R2 = int(R2_widget.text())
            
            write_string = f"S0,N{self.N},%".encode('utf-8')
            self.ser.write(write_string)
        
            write_string = f"S1,T{self.fs},%".encode('utf-8')
            self.ser.write(write_string)
            
            write_string = f"S2,T{self.delay},%".encode('utf-8')
            self.ser.write(write_string)
            print('Settings saved.')
        else:
            print('Settings NOT saved.')
Ejemplo n.º 50
0
def main():
    app = makeApp()
    app.setStyleSheet(load_stylesheet(qt_api="pyqt5"))
    MainWindow()
    sys.exit(app.exec())
Ejemplo n.º 51
0
Archivo: uiQt.py Proyecto: haotin/vnpy
import platform

from PyQt4 import QtGui, QtCore

from vnpy.trader.vtGlobal import globalSetting
from vnpy.trader.vtFunction import loadIconPath

# 创建Qt应用对象
qApp = QtGui.QApplication([])

# 设置Qt的皮肤
if globalSetting['darkStyle']:
    try:
        import qdarkstyle
        qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    except ImportError:
        pass

# 设置Windows底部任务栏图标
if 'Windows' in platform.uname():
    import ctypes
    ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')

# 设置Qt字体
try:
    family = globalSetting['fontFamily']
    size = globalSetting['fontSize']
    BASIC_FONT = QtGui.QFont(family, size)
except:
    BASIC_FONT = QtGui.QFont(u'微软雅黑', 12)
Ejemplo n.º 52
0
import os
import sys

import qdarkstyle as qdarkstyle
from PySide2.QtWidgets import QApplication

from user_interface import MainWindow
# Run app
if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setStyleSheet(
        qdarkstyle.load_stylesheet(qt_api=os.environ['PYQTGRAPH_QT_LIB']))
    window = MainWindow()
    window.show()
    app.exec_()
Ejemplo n.º 53
0
                pass

    class StockSources(IntEnum):
        YAHOO_FIN = 0
        ASTRASS = 1
        YFINANCE = 2

    class SampleRates(Enum):
        ONE_DAY = "1 Day"
        ONE_HOUR = "1 Hour"
        THIRTY_MINUTES = "30 Minutes"

    class TimeDeltas(Enum):
        MAX = "MAX"
        FIVE_YEARS = "5 years"
        ONE_YEAR = "1 year"
        YEAR_TO_DATE = "YTD"
        SIX_MONTHS = "6 months"
        ONE_MONTH = "1 month"
        FIVE_DAYS = "5 days"


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    sat = Ui_StockAnalysisTool(relative_path_correction=".." + sep + ".." +
                               sep)
    sat.show()
    app.setStyleSheet(load_stylesheet(qt_api="pyqt5"))
    sys.exit(app.exec_())
Ejemplo n.º 54
0
        else:
            QMessageBox.question(self, 'Message', "Invalid input", QMessageBox.Ok, QMessageBox.Ok)

    @pyqtSlot()
    def on_previous_click(self):
        global i
        if i > 0:  # if counter i is more than 0, undo the move and create the svg file
            i -= 1
            board.pop()
            writefile(board)
            self.board_widget2.load("Images/board.svg")  # Refresh the board widget
        else:
            pass

    @pyqtSlot()
    def on_next_click(self):
        global i, final_move_list
        if i < len(
                final_move_list):  # if counter i is less than the length of move_list, move the piece and create the svg file
            board.push(board.parse_san(final_move_list[i]))
            writefile(board)
            i += 1
            self.board_widget2.load("Images/board.svg")  # Refresh the board widget
        else:
            pass

app = QApplication(sys.argv)  # initialise the pyqt application
app.setStyleSheet(qdarkstyle.load_stylesheet())  # load third party dark theme
ex = App()
sys.exit(app.exec_())
Ejemplo n.º 55
0
        import qdarkstyle
        app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
    myWin = MyMainWindow(capture_output=True, use_dark_style=use_dark_style)
    myWin.show()
    sys.exit(app.exec())


if __name__ == "__main__":
    import requests
    import urllib
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("urllib3").setLevel(logging.WARNING)
    app = QApplication(sys.argv)
    use_dark_style = False  # 使用暗黑主题
    if use_dark_style:
        import qdarkstyle
        app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
    if (len(sys.argv) > 1 and sys.argv[1] == '0'):
        FORMAT = '%(asctime)-15s [%(levelname)s]: %(message)s [%(name)s::%(funcName)s]'
        logging.basicConfig(
            format=FORMAT, level=logging.INFO, handlers=[
                logging.StreamHandler(),
            ]
        )
        myWin = MyMainWindow(capture_output=False, use_dark_style=use_dark_style)
    else:
        myWin = MyMainWindow(capture_output=True, use_dark_style=use_dark_style)

    myWin.show()
    sys.exit(app.exec())
Ejemplo n.º 56
0
    def __init__(self, app):
        QtCore.QObject.__init__(self, app)
        print 'Gui:\t\t\t', QtGui.QApplication.instance().thread()
        QtGui.QFontDatabase.addApplicationFont("xicam/gui/zerothre.ttf")

        import plugins

        config.activate()

        self._pool = None
        # Load the gui from file
        self.app = app
        guiloader = QUiLoader()
        f = QtCore.QFile("xicam/gui/mainwindow.ui")
        f.open(QtCore.QFile.ReadOnly)
        self.ui = guiloader.load(f)
        f.close()

        # STYLE
        with open('xicam/gui/style.stylesheet', 'r') as f:
            style = f.read()
        app.setStyleSheet(qdarkstyle.load_stylesheet() + style)
        app.setAttribute(QtCore.Qt.AA_DontShowIconsInMenus, False)

        # INITIAL GLOBALS
        self.viewerprevioustab = -1
        self.timelineprevioustab = -1
        self.experiment = config.experiment()
        self.folderwatcher = watcher.newfilewatcher()
        self.plugins = []

        # ACTIONS
        # Wire up action buttons
        self.ui.findChild(QtGui.QAction,
                          'actionOpen').triggered.connect(self.dialogopen)
        self.ui.findChild(QtGui.QAction, 'actionSettings').triggered.connect(
            self.settingsopen)
        self.ui.findChild(QtGui.QAction, 'actionQuit').triggered.connect(
            QtGui.QApplication.instance().quit)

        self.ui.actionExport_Image.triggered.connect(self.exportimage)

        # Grab status bar
        msg.statusbar = self.ui.statusbar
        pb = QtGui.QProgressBar()
        pb.setSizePolicy(QtGui.QSizePolicy.Expanding,
                         QtGui.QSizePolicy.Ignored)
        msg.progressbar = pb
        pb.setAccessibleName('progressbar')
        msg.statusbar.addPermanentWidget(pb)
        pb.hide()
        msg.showMessage('Ready...')
        xglobals.statusbar = self.ui.statusbar  # TODO: Deprecate this by replacing all statusbar calls with msg module

        # PLUG-INS

        placeholders = [
            self.ui.viewmode, self.ui.sidemode, self.ui.bottommode,
            self.ui.toolbarmode, self.ui.leftmode
        ]

        plugins.initplugins(placeholders)

        plugins.plugins['MOTD'].instance.activate()

        plugins.base.fileexplorer.sigOpen.connect(self.openfiles)
        plugins.base.fileexplorer.sigFolderOpen.connect(self.openfolder)
        plugins.base.booltoolbar.actionTimeline.triggered.connect(
            plugins.base.filetree.handleOpenAction)

        pluginmode = plugins.widgets.pluginModeWidget(plugins.plugins)
        self.ui.modemenu.addWidget(pluginmode)

        self.ui.menubar.addMenu(plugins.buildactivatemenu(pluginmode))

        # TESTING
        ##
        # self.openimages(['../samples/AgB_00016.edf'])
        # self.openimages(['/Users/rp/Data/LaB6_Ant1_dc002p.mar3450'])

        # self.calibrate()
        # self.updatepreprocessing()
        ##
        testmenu = QtGui.QMenu('Testing')
        testmenu.addAction('Single frame').triggered.connect(self.singletest)
        testmenu.addAction('Image stack').triggered.connect(self.stacktest)
        testmenu.addAction('Timeline').triggered.connect(self.timelinetest)
        testmenu.addAction('Tilt').triggered.connect(self.tilttest)

        self.ui.menubar.addMenu(testmenu)

        # DASK WORKFLOW
        # TODO turn this into a class

        # convert the following into a class
        self.sessions = ["localhost", "Andromeda", "Daint", "NERSC/Edison"]
        self.session_machines = [
            "localhost", "andromeda.dhcp.lbl.gov", "148.187.1.7",
            "edison.nersc.gov"
        ]
        # self.session_address = ["localhost", socket.gethostbyname("andromeda.dhcp.lbl.gov"), "148.187.26.16", ""]
        self.session_address = [
            "localhost", "andromeda.dhcp.lbl.gov", "148.187.26.16", ""
        ]
        self.session_exec = [
            "", "/home/hari/runscript.sh", "/users/course79/runscript.sh",
            "/usr/common/graphics/visit/camera/runscript.sh"
        ]
        self.executors = [None, None, None, None]

        self.sessionmenu = QtGui.QMenu('Sessions')

        # comboBoxAction = ComboBoxAction("Active Session", self.sessionmenu);

        self.actionGroup = QtGui.QActionGroup(self.sessionmenu)
        for i in self.sessions:
            action = QtGui.QAction(i, self.sessionmenu, checkable=True)
            if i == "localhost":
                action.setChecked(True)
            action.triggered.connect(self.activesessionchanged)
            self.actionGroup.addAction(action)
            self.sessionmenu.addAction(action)

        # self.comboBoxAction.comboBox().activated.connect(self.activesessionchanged)
        # self.sessionmenu.addAction(comboBoxAction)
        self.ui.menubar.addMenu(self.sessionmenu)

        # self.daskLoop = client.dask_io_loop.DaskLoop()
        # try:
        #     # create a local active executor
        #     local_scheduler = client.dask_local_scheduler.LocalScheduler(self.daskLoop)
        #     local_scheduler.execute()
        #     self.executors[0] = local_scheduler
        #     self.sessionmenu.setTitle("Active Session (localhost)")
        #     client.dask_active_executor.active_executor = local_scheduler
        # except:
        #     msg.logMessage("Issues connecting to localhost",msg.ERROR)

        # START PYSIDE MAIN LOOP
        # Show UI and end app when it closes
        self.ui.installEventFilter(self)
Ejemplo n.º 57
0
    from IPython.lib.guisupport import get_app_qt4, start_event_loop_qt4
    app = get_app_qt4()
    start_event_loop_qt4(app)
except ImportError:
    app = QApplication.instance() or QApplication([])

app.setApplicationName("amoco-qt")
# set default styleSheet:
current_path = path.abspath(path.dirname(__file__))
filename = path.join(current_path, 'style.qss')
filename = conf.UI.qstylesheet or filename
if filename.startswith(":"):
    if filename[1:]=="qdarkstyle":
        try:
            import qdarkstyle
            app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyside2'))
        except:
            pass
else:
    with open(filename,'r') as f:
        _style = f.read()
        app.setStyleSheet(_style)


def builder(view):
    """
    Implements the main API that allows view instances to
    build their graphic object for display.
    """
    t = view.__class__.__name__
    try:
Ejemplo n.º 58
0
 def _setGuiTheme(self, theme='dark'):
     """Sets PatitoPro GUI visual style"""
     if theme != 'dark':
         pass
     else:
         self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
Ejemplo n.º 59
0
def _qt_get_stylesheet(theme):
    from ...fixes import _compare_version
    from ...utils import logger, warn, _validate_type, _check_qt_version
    _validate_type(theme, ('path-like',), 'theme')
    theme = str(theme)
    orig_theme = theme
    system_theme = None
    stylesheet = ''
    extra_msg = ''
    if theme == 'auto':
        theme = system_theme = _qt_detect_theme()
    if theme in ('dark', 'light'):
        if system_theme is None:
            system_theme = _qt_detect_theme()
        qt_version, api = _check_qt_version(return_api=True)
        # On macOS, we shouldn't need to set anything when the requested theme
        # matches that of the current OS state
        if sys.platform == 'darwin':
            extra_msg = f'when in {system_theme} mode on macOS'
        # But before 5.13, we need to patch some mistakes
        if sys.platform == 'darwin' and theme == system_theme:
            if theme == 'dark' and _compare_version(qt_version, '<', '5.13'):
                # Taken using "Digital Color Meter" on macOS 12.2.1 looking at
                # Meld, and also adapting (MIT-licensed)
                # https://github.com/ColinDuquesnoy/QDarkStyleSheet/blob/master/qdarkstyle/dark/style.qss  # noqa: E501
                # Something around rgb(51, 51, 51) worked as the bgcolor here,
                # but it's easy enough just to set it transparent and inherit
                # the bgcolor of the window (which is the same). We also take
                # the separator images from QDarkStyle (MIT).
                icons_path = _qt_init_icons()
                stylesheet = """\
QStatusBar {
  border: 1px solid rgb(76, 76, 75);
  background: transparent;
}
QStatusBar QLabel {
  background: transparent;
}
QToolBar {
  background-color: transparent;
  border-bottom: 1px solid rgb(99, 99, 99);
}
QToolBar::separator:horizontal {
  width: 16px;
  image: url("%(icons_path)s/[email protected]");
}
QToolBar::separator:vertical {
  height: 16px;
  image: url("%(icons_path)s/[email protected]");
}
QToolBar::handle:horizontal {
  width: 16px;
  image: url("%(icons_path)s/[email protected]");
}
QToolBar::handle:vertical {
  height: 16px;
  image: url("%(icons_path)s/[email protected]");
}
""" % dict(icons_path=icons_path)
        else:
            # Here we are on non-macOS (or on macOS but our sys theme does not
            # match the requested theme)
            if api in ('PySide6', 'PyQt6'):
                if orig_theme != 'auto' and not \
                        (theme == system_theme == 'light'):
                    warn(f'Setting theme={repr(theme)} is not yet supported '
                         f'for {api} in qdarkstyle, it will be ignored')
            else:
                try:
                    import qdarkstyle
                except ModuleNotFoundError:
                    logger.info(
                        f'To use {theme} mode{extra_msg}, "qdarkstyle" has to '
                        'be installed! You can install it with:\n'
                        'pip install qdarkstyle\n')
                else:
                    klass = getattr(getattr(qdarkstyle, theme).palette,
                                    f'{theme.capitalize()}Palette')
                    stylesheet = qdarkstyle.load_stylesheet(klass)
    else:
        try:
            file = open(theme, 'r')
        except IOError:
            warn('Requested theme file not found, will use light instead: '
                 f'{repr(theme)}')
        else:
            with file as fid:
                stylesheet = fid.read()

    return stylesheet
Ejemplo n.º 60
0
def gui(game):
    global i, board_widget, tableWidget, board, move_list, evaluation_list
    i = 0
    board = game.board()
    writefile(board)
    print("Loading... evaluation may take about 1-2 mins.")
    move_list, evaluation_list = generate_move_and_eval_list(game)

    app = QApplication(sys.argv)  #initialise the pyqt application
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    main_layout = QVBoxLayout()  #set main layout to have a Vertical layout
    upper_section = QHBoxLayout(
    )  #set upper section to have a Horizontal layout
    lower_section = QHBoxLayout()

    window = QWidget()  #initialise main window widget
    tableWidget = QTableWidget()  #initialise table widget
    tableWidget.setRowCount(len(move_list))  #set the no of rows for the table
    tableWidget.setColumnCount(2)  #set the no of columns for the table
    tableWidget.setHorizontalHeaderLabels(["Chess Moves", "Evaluation"
                                           ])  #set column name for the table
    tableWidget.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
    #header.setSectionResizeMode(0, QHeaderView.ResizeToContents)  #resize column to fit the content perfectly
    #header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
    set_table_content(
        move_list,
        evaluation_list)  #set table content using the move list generated
    tableWidget.resizeColumnsToContents()
    board_widget = QtSvg.QSvgWidget(
        'Images/Board.svg')  #initialise board widget
    board_widget.setFixedWidth(460)
    board_widget.setFixedHeight(460)
    upper_section.addWidget(
        board_widget)  #add the widgets to the upper section
    upper_section.addWidget(tableWidget)

    previous_button = QPushButton()  #create a push button for previous move
    previous_button.setToolTip("Previous move")
    previous_button.setIcon(QtGui.QIcon("Images/left-arrow.png"))
    previous_button.clicked.connect(
        previous_button_clicked
    )  #create a event handler for the previous button
    next_button = QPushButton()  #create a push button for next move
    next_button.setToolTip("Next move")
    next_button.setIcon(QtGui.QIcon("Images/right-arrow.png"))
    next_button.clicked.connect(
        next_button_clicked)  #create a event handler for the next button

    lower_section.addWidget(
        previous_button)  #add the previous button to the lower section
    lower_section.addWidget(
        next_button)  #add the next button to the lower section

    main_layout.addLayout(
        upper_section)  #add the upper section layout to the main_layout
    main_layout.addLayout(
        lower_section)  #add the lower section layout to the main_layout
    window.setLayout(main_layout)  #set the main layout for the main widget
    window.setWindowTitle("Chess Board")  #set the window title
    window.show()  #show main window widget
    sys.exit(app.exec_())