Example #1
0
 def load_ui_widget(self, ui_filename, parent=None):
     loader = uic()
     file = QFile(ui_filename)
     file.open(QFile.ReadOnly)
     self.ui = loader.load(file, parent)
     file.close()
     return self.ui
Example #2
0
    def __init__(self, parent=None):
        super(DragWidget, self).__init__(parent)

        dictionaryFile = QFile(':/dictionary/words.txt')
        dictionaryFile.open(QIODevice.ReadOnly)

        x = 5
        y = 5

        for word in QTextStream(dictionaryFile).readAll().split():
            wordLabel = DragLabel(word, self)
            wordLabel.move(x, y)
            wordLabel.show()
            x += wordLabel.width() + 2
            if x >= 195:
                x = 5
                y += wordLabel.height() + 2

        newPalette = self.palette()
        newPalette.setColor(QPalette.Window, Qt.white)
        self.setPalette(newPalette)

        self.setAcceptDrops(True)
        self.setMinimumSize(400, max(200, y))
        self.setWindowTitle("Draggable Text")
Example #3
0
 def load_ui_widget(self, ui_filename, parent=None):
     loader = uic()
     file = QFile(ui_filename)
     file.open(QFile.ReadOnly)
     loader.registerCustomWidget(MouthView)
     loader.registerCustomWidget(WaveformView)
     self.ui = loader.load(file, parent)
     file.close()
     return self.ui
Example #4
0
    def testBug909(self):
        fileName = QFile(adjust_filename('bug_909.ui', __file__))
        loader = QUiLoader()
        main_win = loader.load(fileName)
        self.assertEqual(sys.getrefcount(main_win), 2)
        fileName.close()

        tw = QTabWidget(main_win)
        main_win.setCentralWidget(tw)
        main_win.show()
class TestQFileSignalBlocking(unittest.TestCase):
    '''Test case for blocking the signal QIODevice.aboutToClose()'''

    def setUp(self):
        #Set up the needed resources - A temp file and a QFile
        self.called = False
        handle, self.filename = mkstemp()
        os.close(handle)

        self.qfile = QFile(self.filename)

    def tearDown(self):
        #Release acquired resources
        os.remove(self.filename)
        del self.qfile

    def callback(self):
        #Default callback
        self.called = True

    def testAboutToCloseBlocking(self):
        #QIODevice.aboutToClose() blocking

        QObject.connect(self.qfile, SIGNAL('aboutToClose()'), self.callback)

        self.assert_(self.qfile.open(QFile.ReadOnly))
        self.qfile.close()
        self.assert_(self.called)

        self.called = False
        self.qfile.blockSignals(True)

        self.assert_(self.qfile.open(QFile.ReadOnly))
        self.qfile.close()
        self.assert_(not self.called)
Example #6
0
    def saveFile(self, fileName):
        file = QFile(fileName)

        if not file.open(QFile.WriteOnly | QFile.Text):
            QMessageBox.warning(self, "MDI",
                    "Cannot write file %s:\n%s." % (fileName, file.errorString()))
            return False

        outstr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        outstr << self.toPlainText()
        QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)
        return True
    def setUp(self):
        #Set up the needed resources - A temp file and a QFile
        self.called = False
        handle, self.filename = mkstemp()
        os.close(handle)

        self.qfile = QFile(self.filename)
Example #8
0
    def loadFile(self, fileName):
        file = QFile(fileName)
        if not file.open(QFile.ReadOnly | QFile.Text):
            QMessageBox.warning(self, "MDI",
                    "Cannot read file %s:\n%s." % (fileName, file.errorString()))
            return False

        instr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.setPlainText(instr.readAll())
        QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)

        self.document().contentsChanged.connect(self.documentWasModified)

        return True
Example #9
0
 def testBasic(self):
     '''QFile.getChar'''
     obj = QFile(self.filename)
     obj.open(QIODevice.ReadOnly)
     self.assertEqual(obj.getChar(), (True, 'a'))
     self.assertFalse(obj.getChar()[0])
     obj.close()
Example #10
0
 def restoreLayout(self):
     if os.path.isfile(get_config_path("layout.dat")):
         try:
             f=open(get_config_path("layout.dat"), 'rb')
             geometry, state=pickle.load(f)
             self.restoreGeometry(geometry)
             self.restoreState(state)
         except Exception as e:
             print("Exception on restoreLayout, {}".format(e))
     else:
         try:
             f=QFile(':/default_layout.dat')
             f.open(QIODevice.ReadOnly)
             geometry, state=pickle.loads(f.readAll())
             self.restoreGeometry(geometry)
             self.restoreState(state)
         except Exception as e:
             print("Exception on restoreLayout, {}".format(e))
Example #11
0
    def setupUi(self, Form):
        path = f"{os.path.dirname(__file__)}/new_gui.ui"
        ui_file = QFile(path)
        ui_file.open(QFile.ReadOnly)

        loader = QUiLoader()
        self._window = loader.load(ui_file)

        # Need to fix this courses list view
        self._window.coursesView = CoursesListView(self._window.courses_tab)
        self._window.courses_layout.addWidget(self._window.coursesView)
        self._window.coursesView.setObjectName("coursesView")
        self._window.coursesView2.deleteLater()

        self.icon = QIcon(":/icons/uglytheme/polibeepsync.svg")

        self.retranslateUi(self._window)
        self._window.tabWidget.setCurrentIndex(0)
        QMetaObject.connectSlotsByName(self._window)
Example #12
0
 def load_ui(self):
     loader = QUiLoader()
     ui_file = QFile(
         os.path.join(os.path.dirname(__file__), "widget.ui"))
     ui_file.open(QFile.ReadOnly)
     loader.load(ui_file, self)
     ui_file.close()
    def __init__(self):
        super(GenericParamWindow, self).__init__()

        # Create objects
        self.error_dialog = QMessageBox()
        self.sound_profile = SoundProfileWidget()

        # Load UI
        loader = QUiLoader()
        path = os.path.join(os.path.dirname(__file__), "GenericParamForm.ui")
        ui_file = QFile(path)
        ui_file.open(QFile.ReadOnly)
        self.ui = loader.load(ui_file, self)
        ui_file.close()
        self.ui.input_file_line_edit.setText("")
        self.ui.output_file_line_edit.setText("")

        # Connect buttons
        self.ui.next_button.clicked.connect(self.on_next_button_clicked)
        self.ui.browse_input_file_button.clicked.connect(
            self.on_browse_input_file_button_clicked)
        self.ui.browse_output_file_button.clicked.connect(
            self.on_browse_output_file_button_clicked)
        self.ui.sound_profile_push_button.clicked.connect(
            self.on_sound_profile_button_clicked)
Example #14
0
    def __init__(self, ui_file, parent=None):
        self.remaining_time = 10

        super(Form, self).__init__(parent)
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)

        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        self.btn_clear = self.window.findChild(QPushButton, "btn_clear")
        self.btn_skip = self.window.findChild(QPushButton, "btn_skip")
        self.btn_undo = self.window.findChild(QPushButton, "btn_undo")

        self.label_timer = self.window.findChild(QLabel, "label_timer")
        self.log = self.window.findChild(QPlainTextEdit, "log")
        self.picture_holder = self.window.findChild(QLabel, "picture_holder")
        self.gen_line = QLine()

        self.timer = QTimer(self)
        #self.timer.timeout.connect(self.stop_game)
        self.timer.start(1000)
        #QTimer.singleShot(1000, self.redraw_label_timer)
        QObject.connect(self.timer, SIGNAL('timeout()'),
                        self.redraw_label_timer)

        self.window.show()
Example #15
0
def load_ui_file(path: str):
    """
    Loads the main ".ui"-file from the "ui"-folder and returns the QMainWindow from it.
    Also initializes an instance of the "ui"-class.

    Arguments:
        path : the path to the ui file which should be loaded

    Returns:
        QWindow: The loaded Window

    """

    ui_file = QFile(path)

    if not ui_file.open(QIODevice.ReadOnly):
        print("Cannot open {}: {}".format(path, ui_file.errorString()))
        sys.exit(-1)

    loader = QUiLoader()
    window = loader.load(ui_file)
    ui_file.close()

    if not window:
        print(loader.errorString())
        sys.exit(-1)

    return window
Example #16
0
 def load_ui(self):
     loader = QUiLoader()
     path = os.fspath(Path(__file__).resolve().parent / "form.ui")
     ui_file = QFile(path)
     ui_file.open(QFile.ReadOnly)
     self.ui_window = loader.load(ui_file, self)
     ui_file.close()
Example #17
0
    def __init__(self, ):
        ui_file = QFile("resources/ui/splashscreen.ui")
        ui_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        if not self.window:
            print(loader.errorString())
            sys.exit(-1)

        self.window.setWindowFlag(QtCore.Qt.FramelessWindowHint)
        self.window.setAttribute(QtCore.Qt.WA_TranslucentBackground)

        ## DROP SHADOW EFFECT
        self.window.shadow = QGraphicsDropShadowEffect(self.window)
        self.window.shadow.setBlurRadius(30)
        self.window.shadow.setXOffset(0)
        self.window.shadow.setYOffset(0)
        self.window.shadow.setColor(QColor(0, 0, 0, 90))
        self.window.dropShadowFrame.setGraphicsEffect(self.window.shadow)
        self.counter = 0

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.progress)
    def __init__(self):
        super(MainWindow, self).__init__()

        ui_file = QFile("scrollwindow.ui")
        ui_file.open(QFile.ReadOnly)
        loader = MyQUiLoader(self)
        loader.registerCustomWidget(QCustomPlot)
        self.ui = loader.load(ui_file)
        ui_file.close()

        self.setupPlot()

        #self.ui.plot.setInteractions(QCP.iRangeDrag | QCP.iRangeZoom | QCP.iSelectAxes | QCP.iSelectLegend | QCP.iSelectPlottables)
        # configure scroll bars:
        # Since scroll bars only support integer values, we'll set a high default range of -500..500 and
        # divide scroll bar position values by 100 to provide a scroll range -5..5 in floating point
        # axis coordinates. if you want to dynamically grow the range accessible with the scroll bar,
        # just increase the the minimum/maximum values of the scroll bars as needed.
        self.ui.horizontalScrollBar.setRange(-500, 500);
        self.ui.verticalScrollBar.setRange(-500, 500);
  
        # create connection between axes and scroll bars:
        self.ui.horizontalScrollBar.valueChanged.connect(self.horzScrollBarChanged)
        self.ui.verticalScrollBar.valueChanged.connect(self.vertScrollBarChanged)
        self.ui.plot.xAxis.rangeChanged.connect(self.xAxisChanged)
        self.ui.plot.yAxis.rangeChanged.connect(self.yAxisChanged)
        
        # initialize axis range (and scroll bar positions via signals we just connected):
        self.ui.plot.xAxis.setRange(0, 6,  Qt.AlignCenter)
        self.ui.plot.yAxis.setRange(0, 10, Qt.AlignCenter)
Example #19
0
    def __init__(self):
        QWidget.__init__(self)

        designer_file = QFile("iothook.ui")
        designer_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        loader.registerCustomWidget(MplWidget)
        self.ui = loader.load(designer_file, self)
        designer_file.close()

        self.setWindowTitle("IOTHOOK")

        self.field_1_list = []
        self.field_2_list = []
        self.field_3_list = []
        self.field_4_list = []
        self.field_5_list = []
        self.field_6_list = []
        self.field_7_list = []
        self.field_8_list = []

        self.lineEdit = self.ui.findChild(QLineEdit, 'lineEdit')
        self.pushButton = self.ui.findChild(QPushButton, 'pushButton')

        self.pushButton.clicked.connect(self.result)

        grid_layout = QGridLayout()
        grid_layout.addWidget(self.ui)
        self.setLayout(grid_layout)
Example #20
0
 def load_ui(self, ui_file, parent=None):
     ui_file = QFile(ui_file)
     ui_file.open(QFile.ReadOnly)
     loader = QUiLoader()
     # self.window = loader.load(ui_file)
     self.ui = loader.load(ui_file, parent)
     ui_file.close()
Example #21
0
    def __ConfigureSysIniFile(self):
        iniFile = QFile("info.ini")

        if iniFile.exists():
            self.__infoSettings = QSettings("info.ini", QSettings.IniFormat)

            self.__appIDLineEdit.setText(
                self.__infoSettings.value("info/appid"))
            self.__keyLineEdit.setText(self.__infoSettings.value("info/key"))

        else:
            if iniFile.open(QFile.ReadWrite):
                self.__infoSettings = QSettings("info.ini",
                                                QSettings.IniFormat)

                self.__infoSettings.beginGroup("info")

                self.__infoSettings.setValue("appid", "00000000000000000")
                self.__infoSettings.setValue("key", "00000000000000000")
                self.__infoSettings.endGroup()

                iniFile.close()

                self.__appIDLineEdit.setText("00000000000000000")
                self.__keyLineEdit.setText("00000000000000000")
Example #22
0
    def __init__(self, ui_file, parent=None):
        super(Form, self).__init__(parent)

        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)
 
        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()
 
        self.leOldFile = self.window.findChild(QLineEdit, 'leOldFile')
        self.leNewFile = self.window.findChild(QLineEdit, 'leNewFile')

        self.lwMsg = self.window.findChild(QListWidget, 'listWidget')
 
        pbOldFile = self.window.findChild(QPushButton, 'pbOldFile')
        pbOldFile.clicked.connect(self.pbOldFile_handler)

        pbNewFile = self.window.findChild(QPushButton, 'pbNewFile')
        pbNewFile.clicked.connect(self.pbNewFile_handler)

        pbExit = self.window.findChild(QPushButton, 'pbExit')
        pbExit.clicked.connect(self.pbExit_handler)

        pbRun = self.window.findChild(QPushButton, 'pbRun')
        pbRun.clicked.connect(self.pbRun_handler)

        self.window.show()
Example #23
0
    def __init__(self, parent=None):
        super().__init__(parent)
        path = os.path.join('mygui', 'main.ui')
        file = QFile(path)
        file.open(QFile.ReadOnly)
        loader = QtUiTools.QUiLoader()
        self.window = loader.load(file, self)
        file.close()
        #return self.window
        #self.window = uic.loadUi(path, self)
        self.polzovatel = ''

        #создаём сокет
        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        #подключаемся к нужному адресу
        self.s.connect(('localhost', 8888))

        #назначим подксказки
        self.window.btn_login.setToolTip('Кнопка для заполнения списка.')
        self.window.textEdit.setToolTip('Окно для <b>выбранных</b> друзей.')

        #назначим действия для объектов
        self.window.btn_login.clicked.connect(self.login)
        self.window.contactView.clicked.connect(self.set_text)
        self.window.select_exit.toggled.connect(
            QCoreApplication.instance().quit)
        self.window.btn_add_friend.clicked.connect(self.add_friend)
Example #24
0
 def __init__(self, ui_file, devMode, parent=None):
     super(MainWindow, self).__init__()
     self.uiFileName = ui_file  # use this if there are multiple UI files
     if devMode == "development":  # use ui file directly made by QDesigner
         uiFile = QFile(ui_file)
         uiFile.open(QFile.ReadOnly)  # read in UI for the form
         loader = QUiLoader()
         self.window = loader.load(uiFile)
         uiFile.close()
     else:  #deployment - use .py version of ui file, with slightly different setup
         self.ui = Ui_MainWindow()
         self.ui.setupUi(self)
     self.getParts()  # identify form objects
     self.connectParts()  # connect buttons to operations
     self.convs = Converters(
     )  # load converters for main conversion categories
     self.yc = YearConverters(
     )  # load converters for japanese years, zodiac years
     self.mess = Mess()  # instructions and messages in local language
     self.validFloat = QDoubleValidator()
     self.validYear = QIntValidator()
     self.validYear.setRange(1, 9999)  # used for years
     self.btnConvert.hide()
     self.widgetSetup("start")  # initial conditions for form
     if devMode == "development": self.window.show()
     else: self.show()
Example #25
0
    def initUI(self):
        app = QApplication(sys.argv)

        ui_file = QFile("UI/ui_mainwindow.ui")
        ui_file.open(QFile.ReadOnly)

        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        self.window.usernameEdit.textEdited.connect(self.enable_add_player)
        self.window.usernameEdit.returnPressed.connect(self.add_player)

        self.window.addPlayerButton.clicked.connect(self.add_player)

        self.window.putTeam1Button.clicked.connect(self.add_player_team1)
        self.window.putTeam2Button.clicked.connect(self.add_player_team2)

        self.window.removePlayerTeam1Button.clicked.connect(self.remove_player_team1)
        self.window.removePlayerTeam2Button.clicked.connect(self.remove_player_team2)

        self.window.teamAddButton.clicked.connect(self.add_points)

        # Other Stuff
        self.start_time = time.time()

        self.window.show()
        sys.exit(app.exec_())
Example #26
0
    def __init__(self, ui_file):
        super(FormPessoa, self).__init__()
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)

        loader = QUiLoader()
        self.window = loader.load(ui_file)
        self.window.setFixedSize(self.window.width(), self.window.height());
        ui_file.close()

        self.txtcpf = self.window.findChild(QLineEdit, 'txtCpf')
        self.txtcpf.textChanged.connect(self.cpf_handler)
        self.txtcpfmsg = self.window.findChild(QLabel, 'lblCpfMsg')

        self.txtnome = self.window.findChild(QLineEdit, 'txtNome')
        self.txtnome.textChanged.connect(self.nome_handler)
        self.txtnomemsg = self.window.findChild(QLabel, 'lblNomeMsg')

        self.txtendereco = self.window.findChild(QLineEdit, 'txtEndereco')
        self.txtendereco.textChanged.connect(self.endereco_handler)
        self.txtenderecomsg = self.window.findChild(QLabel, 'lblEnderecoMsg')

        self.txtcomplemento = self.window.findChild(QLineEdit, 'txtComplemento')
        self.txtcomplemento.textChanged.connect(self.complemento_handler)
        self.txtcomplementomsg = self.window.findChild(QLabel, 'lblComplementoMsg')

        self.txtcidade = self.window.findChild(QLineEdit, 'txtCidade')
        self.txtcidade.textChanged.connect(self.cidade_handler)
        self.txtcidademsg = self.window.findChild(QLabel, 'lblCidadeMsg')

        self.txtbairro = self.window.findChild(QLineEdit, 'txtBairro')
        self.txtbairro.textChanged.connect(self.bairro_handler)
        self.txtbairromsg = self.window.findChild(QLabel, 'lblBairroMsg')

        self.cmbestado = self.window.findChild(QComboBox, 'cmbEstado')
        self.cmbestado.currentIndexChanged.connect(self.cmbestado_handler)
        self.txtestadomsg = self.window.findChild(QLabel, 'lblEstadoMsg')

        self.txtestadonome = self.window.findChild(QLineEdit, 'txtEstadoNome')

        self.txtcep = self.window.findChild(QLineEdit, 'txtCep')
        self.txtcep.textChanged.connect(self.cep_handler)
        self.txtcepmsg = self.window.findChild(QLabel, 'lblCepMsg')

        self.btnsalvar = self.window.findChild(QPushButton, 'btnSalvar')
        self.btnsalvar.clicked.connect(self.salvar_handler)

        self.btncancelar = self.window.findChild(QPushButton, 'btnCancelar')
        self.btncancelar.clicked.connect(self.cancelar_handler)

        self.setMessageInvisible()

        ec = EstadoController()
        json_data = ec.getEstados()
        json_list = json.loads(json_data)
        for sigla in json_list:
            nome = json_list[sigla]
            estado = Estado(sigla, nome)
            self.cmbestado.addItem(estado.descricao, userData=estado)
        self.window.show()
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        base_dir = os.path.dirname(os.path.realpath(__file__))
        dir = os.path.join(base_dir, 'forms', 'acs_control_widget.ui')
        file = QFile(dir)
        file.open(QFile.ReadOnly)
        loader = QUiLoader()
        self.widget = loader.load(file, self)
        file.close()

        self.setMinimumSize(300, 180)
        self.setMaximumSize(16777215, 180)

        self.controller = ACSController()

        self.widget.pbOpen.clicked.connect(self.onOpenPortClicked)
        self.widget.pbMotorOn.clicked.connect(self.onMotorOnClicked)
        self.widget.pbMotorOff.clicked.connect(self.onMotorOffClicked)
        self.widget.pbStopMotor.clicked.connect(self.onMotorStopClicked)
        self.widget.pbPA.clicked.connect(self.onSetTargetAngleClicked)
        self.widget.pbSP.clicked.connect(self.onSetSpeedClicked)

        self.widget.leFeedback.setText('DISPLAY OF FEEDBACK INFO')
        self.widget.lePort.setText('/dev/ttyUSB0')
Example #28
0
 def load_ui_widget(self, ui_filename, parent=None):
     loader = uic()
     file = QFile(ui_filename)
     file.open(QFile.ReadOnly)
     self.ui = loader.load(file, parent)
     file.close()
     return self.ui
    def initUI(self):
        loader = QUiLoader()

        splitPath = os.path.realpath(__file__).split("\\")
        uiPath = "/".join(splitPath[:-1]) + "/selection_history.ui"

        file = QFile(uiPath)
        file.open(QFile.ReadOnly)
        self.ui = loader.load(file)
        file.close()

        #Init ui
        self.ui.closeEvent = self.closeEvent
        self.ui.setParent(maya_main_window())
        self.ui.setWindowFlags(QtCore.Qt.Window)
        self.ui.show()
        self.setCentralWidget(self.ui)

        #Init signals
        self.ui.selection_history_list.currentItemChanged.connect(
            self.on_item_changed)
        self.ui.selection_history_list.itemDoubleClicked.connect(
            self.on_item_double_clicked)
        self.ui.saved_selections_list.currentItemChanged.connect(
            self.on_item_changed_saved)
        self.ui.saved_selections_list.itemDoubleClicked.connect(
            self.on_item_double_clicked_saved)
        self.ui.export_button.clicked.connect(self.on_export)
        self.ui.import_button.clicked.connect(self.on_import)
        self.ui.save_button.clicked.connect(self.on_save)
        self.ui.clear_history_button.clicked.connect(self.on_clear)
        self.ui.clear_saved_button.clicked.connect(self.on_clear_saved)
Example #30
0
    def __init__(self, ui_file, parent=None):
        super(Form, self).__init__(parent)
        # Open ui file.
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)

        # Load ui file into the current form
        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        # Connect events
        solveBtn = self.window.findChild(QPushButton, 'solveBtn')
        solveBtn.clicked.connect(self.ok_handler)

        resetBtn = self.window.findChild(QPushButton, 'resetBtn')
        resetBtn.clicked.connect(self.reset_handler)

        # Find board objects
        self.topLeft = self.window.findChild(QTableWidget, 'topLeft')
        self.topMiddle = self.window.findChild(QTableWidget, 'topMiddle')
        self.topRight = self.window.findChild(QTableWidget, 'topRight')
        self.middleLeft = self.window.findChild(QTableWidget, 'middleLeft')
        self.middleMiddle = self.window.findChild(QTableWidget, 'middleMiddle')
        self.middleRight = self.window.findChild(QTableWidget, 'middleRight')
        self.bottomLeft = self.window.findChild(QTableWidget, 'bottomLeft')
        self.bottomMiddle = self.window.findChild(QTableWidget, 'bottomMiddle')
        self.bottomRight = self.window.findChild(QTableWidget, 'bottomRight')

        # Start prolog engine
        self.prolog = Prolog()
        self.prolog.consult("solver.pl")

        self.window.show()
Example #31
0
    def __init__(self, parent=None):
        super(GameFinishedDialog, self).__init__(parent=parent)
        ui_file = QFile('ui\SessionStat.ui')
        ui_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        self.finish_dialog = loader.load(ui_file)
        ui_file.close()

        self.stat_holders = []
        lb_time: QLabel = self.finish_dialog.findChild(QLabel, 'lb_time')
        self.stat_holders.append(lb_time)
        lb_pure: QLabel = self.finish_dialog.findChild(QLabel, 'lb_pure')
        self.stat_holders.append(lb_pure)
        lb_unclear: QLabel = self.finish_dialog.findChild(QLabel, 'lb_unclear')
        self.stat_holders.append(lb_unclear)
        lb_resets: QLabel = self.finish_dialog.findChild(QLabel, 'lb_resets')
        self.stat_holders.append(lb_resets)
        lb_skips: QLabel = self.finish_dialog.findChild(QLabel, 'lb_skips')
        self.stat_holders.append(lb_skips)

        self.button_box: QDialogButtonBox = self.finish_dialog.findChild(
            QDialogButtonBox, 'button_box')
        self.button_box.clicked.connect(
            lambda button: self.handle_button(button))

        self.finish_dialog.installEventFilter(self)
Example #32
0
    def load_ui(self):
        loader = QUiLoader()
        path = os.path.join(os.path.dirname(__file__), "form.ui")
        ui_file = QFile(path)
        ui_file.open(QFile.ReadOnly)
        self.ui = loader.load(ui_file, self)
        ui_file.close()

        #        self.chartView = QtCharts.QChartView()
        #        self.chartView.setMinimumWidth(450)
        #        self.graphicsView = self.ui.findChild(QGraphicsView, "graphicsView")

        # graphics
        self.tab_summary = self.ui.findChild(QWidget, "tab_summary")

        #        QtDataVisualization.QAbstract3DGraph

        self.scatter3d = QtDataVisualization.Q3DScatter()
        self.container = QWidget.createWindowContainer(self.scatter3d)
        self.container.setMinimumWidth(450)

        self.scatterProxy = QtDataVisualization.QScatterDataProxy()
        self.scatterSeries = QtDataVisualization.QScatter3DSeries(
            self.scatterProxy)

        self.scatter3d.axisX().setTitle("x")
        self.scatter3d.axisY().setTitle("y")
        self.scatter3d.axisZ().setTitle("z")

        self.scatter3d.addSeries(self.scatterSeries)

        self.find_widgets()
Example #33
0
    def __init__(self):
        QWidget.__init__(self)

        #Read UI file
        designer_file = QFile("UI.ui")
        designer_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        loader.registerCustomWidget(MplWidget)
        self.ui = loader.load(designer_file, self)
        designer_file.close()
        #end of reading from UI file

        #plot btn listener
        self.ui.plotbtn.clicked.connect(self.update_graph)
        #exit btn listener
        self.ui.exitbtn.clicked.connect(self.exitapp)
        #set title
        self.setWindowTitle("Plotter")
        #set window icon "plotter.png"
        self.setIcon()
        #intializing grilayout and setting it
        grid_layout = QGridLayout()
        grid_layout.addWidget(self.ui)
        self.setLayout(grid_layout)
        self.valid = True
Example #34
0
    def __init__(self, ui_file = 'MainWindow.ui', parent=None):

        self._num_buttons = 15
        self._num_rows = 4
        self._num_cols = 4

        #call class parent (QObject) constructor
        super(MainWindow, self).__init__(parent)

        #load the UI file into Python
        #ui_file was a string, now it's a proper QT object
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        self.window = loader.load(ui_file)

        #always remember to close files
        ui_file.close()

        #add event listeners for UI events
        self.addEventListeners()

        #randomize button placement
        self.initializeGame()

        #show window to the user
        self.window.show()
Example #35
0
 def testBug721(self):
     obj = QFile(self.filename)
     obj.open(QIODevice.ReadOnly)
     memory = obj.map(0, 1)
     self.assertEqual(len(memory), 1)
     self.assertEqual(memory[0], py3k.b('a'))
     obj.unmap(memory)
Example #36
0
 def __init__(self, parent):
     super(AboutDialog, self).__init__(parent)
     ui_file = QFile("ui/about.ui")
     ui_file.open(QFile.ReadOnly)
     self.dialog = QUiLoader().load(ui_file)
     ui_file.close()
     self.dialog.show()
Example #37
0
    def __init__(self):
        # 从文件中加载UI定义
        file = QFile('ui/my.ui')
        file.open(QFile.ReadOnly)
        file.close()

        # 从 UI 定义中动态 创建一个相应的窗口对象
        # 注意:里面的控件对象也成为窗口对象的属性了
        # 比如 self.ui.button , self.ui.textEdit
        self.ui = QUiLoader().load(file)

        self.ui.setWindowTitle('Excel<--->DBC工具')
        # 设置窗口图标
        # self.ui.setWindowIcon(QIcon('./ico/logo.png'))

        # pushButton这个名字和qt设计上的名字要一致
        # 把 pushButton 被 点击(clicked)的信号(signal)连接(connect)到了 handleCalc 这样的一个槽(slot)上
        # 选择文件
        self.ui.pushButton.clicked.connect(self.openfile)

        # 点击转换
        self.ui.pushButton_1.clicked.connect(self.convert)
        self.ui.pushButton_1.setEnabled(False)  # 禁用转换按钮

        self.filepath = []  # 所有文件的绝对路径
        self.path_name = []  # os分割出来的路径和文件名
        self.path = ''  # 路径
        self.file = ''  # 文件名
        self.name = ''  # 无后缀名字
        self.extension = ''  # 后缀
        self.filename = ''  # 传入excel2dbc作为文件名
Example #38
0
 def load_ui(self):
     loader = QUiLoader()
     ui_file = QFile(os.path.join(os.path.dirname(__file__), "form.ui"))
     ui_file.open(QFile.ReadOnly)
     self.ui = loader.load(ui_file)
     ui_file.close()
     self.ui.show()
Example #39
0
    def __init__(self, ui_file, parent=None):

        #reference to our music player
        self.music_player = QMediaPlayer()
        self.music_player.setVolume(100)

        #call parent QObject constructor
        super(MainWindow, self).__init__(parent)

        #load the UI file into Python
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        self.window = loader.load(ui_file)

        ui_file.close()

        volume_slider = self.window.findChild(QSlider, 'volume_slider')
        volume_slider.valueChanged.connect(self.volumeChanged)

        open_action = self.window.findChild(QAction, 'action_open')
        open_action.triggered.connect(self.open_action_triggered)

        quit_action = self.window.findChild(QAction, 'action_quit')
        quit_action.triggered.connect(self.quit_action_triggered)

        play_button = self.window.findChild(QPushButton, 'play_button')
        play_button.clicked.connect(self.play_button_clicked)

        pause_button = self.window.findChild(QPushButton, 'pause_button')
        pause_button.clicked.connect(self.pause_button_clicked)

        #show window to user
        self.window.show()
Example #40
0
 def load_ui(self):
     loader = QUiLoader()
     path = os.path.join(os.path.dirname(__file__), "ejemplo.ui")
     ui_file = QFile(path)
     ui_file.open(QFile.ReadOnly)
     loader.load(ui_file, self)
     ui_file.close()
Example #41
0
    def setup_ui(self):
        loader = QUiLoader()
        file = QFile('./media/main_window.ui')
        file.open(QFile.ReadOnly)
        self._window = loader.load(file)
        file.close()

        self.set_title()
        self.set_buttons()

        # Setup combobox
        self._window.transportation_combo.addItem('HSR', 'HighSpeedRail')
        self._window.transportation_combo.addItem('Taxi', 'Uber,Taxi')
        self._window.transportation_combo.addItem('Drive', 'Car')
        self._window.transportation_combo.addItem('Scooter', 'Motorcycle')

        # Setup RadioButton / CheckBox
        self._window.yes_radio.setChecked(False)
        self._window.no_radio.setChecked(True)
        vegetarian_group = QButtonGroup(self._window)
        vegetarian_group.setExclusive(True)
        vegetarian_group.addButton(self._window.yes_radio)
        vegetarian_group.addButton(self._window.no_radio)

        self._window.absolutly_check.setChecked(True)
        self._window.maybe_check.setChecked(False)
        self._window.sorry_check.setChecked(False)
        participate_group = QButtonGroup(self._window)
        participate_group.setExclusive(True)
        participate_group.addButton(self._window.absolutly_check)
        participate_group.addButton(self._window.maybe_check)
        participate_group.addButton(self._window.sorry_check)

        # Setup SpinBox
        self._window.members_spin.setRange(1, 10)
Example #42
0
    def __init__(self):
        # 从文件中加载定义的ui
        qfile_stats = QFile("ui/rz_end_test.ui")
        qfile_stats.open(QFile.ReadOnly)
        qfile_stats.close()

        # 从定义的Ui动态的创建相应的窗口对象
        # 注意: 控件的返回值是一个窗体的对象
        # 例如 self.ui.button  self.ui.textEdit
        self.ui = QUiLoader().load(qfile_stats)

        # 图标显示区域
        self.fig = plt.Figure()
        self.canvas = FC(self.fig)
        # self.ui.show_lable.to(self.ui)
        layout = QVBoxLayout(self.ui.show_lable)
        layout.addWidget(self.canvas)
        layout.setContentsMargins(0, 0, 0, 0)

        # 腾讯网数据显示按钮绑定事件
        self.ui.province.clicked.connect(self.tencent_province_data)
        self.ui.data_all.clicked.connect(self.tencent_all_data)
        self.ui.city.clicked.connect(self.tencent_city)

        # 微博数据显示按钮绑定事件
        self.ui.weibo_cloud.clicked.connect(self.weibo_cloud)
        self.ui.data_emotion.clicked.connect(self.weibo_emotion)
        self.ui.word_rank.clicked.connect(self.weibo_keyword)

        # 中国社会组织公共服务平台
        self.ui.tfidf.clicked.connect(self.news_tfidf)
        self.ui.news_cloud.clicked.connect(self.news_wordcloud)
        self.ui.LDA.clicked.connect(self.news_lda)
Example #43
0
    def testPhrase(self):
        #Test loading of quote.txt resource
        f = open(adjust_filename('quoteEnUS.txt', __file__), "r")
        orig = f.read()
        f.close()

        f = QFile(':/quote.txt')
        f.open(QIODevice.ReadOnly) #|QIODevice.Text)
        print("Error:", f.errorString())
        copy = f.readAll()
        f.close()
        self.assertEqual(orig, copy)
Example #44
0
    def testImage(self):
        #Test loading of sample.png resource
        f = open(adjust_filename('sample.png', __file__), "rb")
        orig = f.read()
        f.close()

        f = QFile(':/sample.png')
        f.open(QIODevice.ReadOnly)
        copy = f.readAll()
        f.close()
        self.assertEqual(len(orig), len(copy))
        self.assertEqual(orig, copy)
Example #45
0
 def testHuge(self):
     handle = QFile(":manychars.txt")
     handle.open(QFile.ReadOnly)
     original = open(os.path.join(self.testdir, "manychars.txt"), "r")
     self.assertEqual(handle.readLine(), original.readline())
 def testCallingInstanceMethod(self):
     '''Call instance method.'''
     f1 = QFile(self.non_existing_filename)
     self.assertFalse(f1.exists())
     f2 = QFile(self.existing_filename)
     self.assert_(f2.exists())
 def testCallingStaticMethodWithClass(self):
     '''Call static method using class.'''
     self.assert_(QFile.exists(self.existing_filename))
     self.assertFalse(QFile.exists(self.non_existing_filename))
Example #48
0
# directly_loading_QML
import sys
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QFile

if __name__ == '__main__':
	app = QApplication(sys.argv)

	ui_file=QFile('./mainwindow.ui')
	ui_file.open(QFile.ReadOnly)
	loader = QUiLoader()
	window = loader.load(ui_file)
	ui_file.close()

	window.show()

	sys.exit(app.exec_())
 def testCallingStaticMethodWithInstance(self):
     '''Call static method using instance of class.'''
     f = QFile(self.non_existing_filename)
     self.assert_(f.exists(self.existing_filename))
     self.assertFalse(f.exists(self.non_existing_filename))
Example #50
0
 def testAlias(self):
     handle = QFile(":jack")
     handle.open(QFile.ReadOnly)
     original = open(os.path.join(self.testdir, "shining.txt"), "r")
     self.assertEqual(handle.readLine(), original.readline())
Example #51
0
 def testSimple(self):
     handle = QFile(":words.txt")
     handle.open(QFile.ReadOnly)
     original = open(os.path.join(self.testdir, "words.txt"), "r")
     self.assertEqual(handle.readLine(), original.readline())