Example #1
0
    def load_ui(self):
        uic.loadUi(CONST.MAIN_UI_PATH, self)
        first_checked = False
        for title, keep in CONST.MAP_TYPES:
            btn = QRadioButton()
            btn.map_type = keep
            btn.setText(title)
            btn.setFont(CONST.MAP_TYPE_FONT)
            btn.clicked.connect(self.map_type_change)
            btn.in_layout = self.map_type_layout

            if first_checked is False:
                first_checked = True
                btn.setChecked(True)

            self.map_type_layout.addWidget(btn)

        self.index_on_radioButton.setChecked(True)

        self.findButton.clicked.connect(self.find_obj)
        self.resetFindButton.clicked.connect(self.reset_all_found)

        self.index_off_radioButton.clicked.connect(self.change_post_code)
        self.index_on_radioButton.clicked.connect(self.change_post_code)

        self.point_comboBox.currentIndexChanged.connect(self.change_address_text)

        self.update_map()
 def draw_network_overview(self):
     # delecte the current widget
     if self.scroll_network.widget():
         self.scroll_network.widget().deleteLater()
     # draw new layout
     vbox_network = QVBoxLayout()
     vbox_network.setAlignment(Qt.AlignCenter)
     layer_names = self.model.get_data(
         CNN_Vis_Demo_Model.data_idx_layer_names)
     layer_output_sizes = self.model.get_data(
         CNN_Vis_Demo_Model.data_idx_layer_output_sizes)
     # todo: change the style of layers
     for layer_name in layer_names:
         btn_layer = QRadioButton(layer_name)
         btn_layer.setFont(QFont('Helvetica', 11, QFont.Bold))
         btn_layer.toggled.connect(self.select_layer_action)
         vbox_network.addWidget(btn_layer)
         size = layer_output_sizes[layer_name]
         size_string = ''
         for value in size:
             size_string += str(value)
             size_string += '×'
         size_string = size_string[:len(size_string) - len('×')]
         lbl_arrow = QLabel(' ⬇️ ' + size_string)
         lbl_arrow.setFont(QFont("Helvetica", 8))
         vbox_network.addWidget(lbl_arrow)
     wrapper_vbox_network = QWidget()
     wrapper_vbox_network.setLayout(vbox_network)
     self.scroll_network.setWidget(wrapper_vbox_network)
     pass
def get_radiobutton(caption=""):
    """
    Returns default PyQt radiobutton.
    """
    rc = QRadioButton(caption)
    rc.setFont(DEFAULT_FONT)
    return rc
Example #4
0
    def init_ui(self):
        font = QFont()
        font.setPointSize(12)

        self.tableWidget = QTableWidget(self)
        self.tableWidget.setGeometry(QtCore.QRect(140, 0, 260, 300))
        self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableWidget.setColumnCount(2)
        self.tableWidget.setRowCount(0)

        self.buttonGroup = QButtonGroup(self)
        for n, text in enumerate(['Новичок', 'Эксперт', 'Бывалый']):
            rb = QRadioButton(self)
            rb.setGeometry(QtCore.QRect(30, 100 + 30 * n, 91, 17))
            rb.setText(text)
            rb.setFont(font)
            self.buttonGroup.addButton(rb)
            self.buttonGroup.setId(rb, n)

        self.buttonGroup.buttonClicked.connect(self.choose_table)

        self.tableWidget.setHorizontalHeaderLabels(["Имя", "Время"])
        self.tableWidget.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)

        self.game_stat = GameStat()
        self.buttonGroup.button(0).click()
Example #5
0
    def __init__(self):
        super().__init__()

        groupBox = QGroupBox(
            "Library to look up the Airport or Airline Code: ")
        groupBox.setFont(QtGui.QFont("MS Sans Serif", 10))
        vbox = QVBoxLayout()

        #label = QLabel("Library to look up the Airport or Airline Code: ")
        #label.setFont(QtGui.QFont("MS Sans Serif", 10))
        code = QLineEdit()
        #vbox.addWidget(label)
        vbox.addWidget(code)
        groupBox.setLayout(vbox)

        groupBox2 = QGroupBox("")
        vbox2 = QHBoxLayout()
        radiobtn1 = QRadioButton("Airport")
        radiobtn1.setFont(QtGui.QFont("MS Sans Serif", 10))
        radiobtn1.setIcon(QtGui.QIcon("airport.png"))
        radiobtn1.setChecked(True)
        vbox2.addWidget(radiobtn1)
        radiobtn2 = QRadioButton("Airline")
        radiobtn2.setFont(QtGui.QFont("MS Sans Serif", 10))
        radiobtn2.setIcon(QtGui.QIcon("airline.png"))
        vbox2.addWidget(radiobtn2)
        groupBox2.setLayout(vbox2)

        groupBox3 = QGroupBox("")
        vbox3 = QHBoxLayout()
        button = QPushButton("Search", self)
        button.setIcon(QtGui.QIcon("library.png"))
        button.setFont(QtGui.QFont("MS Sans Serif", 10))
        button.setIconSize(QtCore.QSize(25, 25))
        button.setToolTip(
            "<h4>Search the IATA code from the Aviation Library.<h4>")
        button2 = QPushButton("More", self)
        button2.setIcon(QtGui.QIcon("more info.png"))
        button2.setFont(QtGui.QFont("MS Sans Serif", 10))
        button2.setIconSize(QtCore.QSize(25, 25))
        button2.setToolTip(
            "<h4>This will obtain the more information of the airport or airline.<h4>"
        )
        vbox3.addWidget(button)
        vbox3.addWidget(button2)
        groupBox3.setLayout(vbox3)

        table = QTableWidget(self)  # Create a table
        table.setColumnCount(4)  # Set three columns
        table.setRowCount(1)
        table.setHorizontalHeaderLabels(["IATA", "ICAO", "Name", "Country"])
        table.resizeColumnsToContents()

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(groupBox)
        mainLayout.addWidget(groupBox2)
        mainLayout.addWidget(groupBox3)
        mainLayout.addWidget(table)
        self.setLayout(mainLayout)
 def radio_Button(self, content=None):
     r_button = QRadioButton(content, self)
     font = QFont('Microsoft YaHei UI', 20)
     font.setBold(True)
     font.setItalic(True)
     r_button.setFont(font)
     r_button.clicked.connect(lambda: self.btnstate(r_button))
     return r_button
Example #7
0
class Window(QDialog):
    def __init__(self):
        super().__init__()
        self.title = "PyQt5 Redio Button"
        self.left = 300
        self.top = 200
        self.width = 400
        self.height = 100
        self.iconName = "icon.png"
        self.InitWindow()

    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon(self.iconName))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.radioButton()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.label = QLabel()
        self.label.setFont(QtGui.QFont("Sanserif",13))
        vbox.addWidget(self.label)
        self.setLayout(vbox)
        self.show()


    def radioButton(self):
        self.groupBox = QGroupBox("What is your Favorite Sport?")
        self.groupBox.setFont(QtGui.QFont("Sanserif",13))
        hboxlayout = QHBoxLayout()

        self.radiobtn1 = QRadioButton("Football")
        self.radiobtn1.setIcon(QtGui.QIcon("football.png"))
        self.radiobtn1.setIconSize(QtCore.QSize(40,40))
        self.radiobtn1.toggled.connect(self.OnRadioBtn)
        hboxlayout.addWidget(self.radiobtn1)

        self.radiobtn2 = QRadioButton("Cricket")
        self.radiobtn2.setIcon(QtGui.QIcon("cricket.png"))
        self.radiobtn2.setIconSize(QtCore.QSize(40,40))
        self.radiobtn2.setFont(QtGui.QFont("Sanserif",13))
        self.radiobtn2.toggled.connect(self.OnRadioBtn)
        hboxlayout.addWidget(self.radiobtn2)

        self.radiobtn3 = QRadioButton("Tennis")
        self.radiobtn3.setIcon(QtGui.QIcon("tennis.png"))
        self.radiobtn3.setIconSize(QtCore.QSize(40,40))
        self.radiobtn3.setFont(QtGui.QFont("Sanserif",13))
        self.radiobtn3.toggled.connect(self.OnRadioBtn)
        hboxlayout.addWidget(self.radiobtn3)


        self.groupBox.setLayout(hboxlayout)

    def OnRadioBtn(self):
        radioBtn = self.sender()

        if radioBtn.isChecked():
            self.label.setText("You Have selected " + radioBtn.text())
Example #8
0
class Window(QDialog):
    def __init__(self):
        super().__init__()

        self.title = "PyQt Image"
        self.left = 500
        self.top = 200
        self.width = 500
        self.height = 500
        self.IconName = "Icon/python.png"

        self.InitWindow()

    def InitWindow(self):
        self.setWindowTitle("Radio Button!")
        self.setWindowIcon(QtGui.QIcon(self.IconName))
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.RadioButton()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)

        self.label = QLabel(self)
        vbox.addWidget(self.label)
        self.label.setFont(QtGui.QFont("Sanserif", 15))

        self.setLayout(vbox)
        self.show()

    def RadioButton(self):
        self.groupBox = QGroupBox("What is your name?")
        self.groupBox.setFont(QtGui.QFont("Sanserif", 10))

        hboxLayout = QHBoxLayout()
        self.radiobutton1 = QRadioButton("Mihir")
        self.radiobutton1.setChecked(True)
        self.radiobutton1.setIcon(QtGui.QIcon(self.IconName))
        self.radiobutton1.setIconSize(QtCore.QSize(40, 40))
        self.radiobutton1.setFont(QtGui.QFont("Sanserif", 10))
        self.radiobutton1.toggled.connect(self.OnRadioButton)

        self.radiobutton2 = QRadioButton("Not Mihir")
        self.radiobutton2.setChecked(False)
        self.radiobutton2.setIcon(QtGui.QIcon(self.IconName))
        self.radiobutton2.setIconSize(QtCore.QSize(40, 40))
        self.radiobutton2.setFont(QtGui.QFont("Sanserif", 10))
        self.radiobutton2.toggled.connect(self.OnRadioButton)

        hboxLayout.addWidget(self.radiobutton1)
        hboxLayout.addWidget(self.radiobutton2)
        self.groupBox.setLayout(hboxLayout)

    def OnRadioButton(self):
        radioButton = self.sender()

        if radioButton.isChecked():
            self.label.setText("You have selected " + radioButton.text())
Example #9
0
class Pattern(QWidget):
    def __init__(self):
        super(Pattern, self).__init__()
        self.setObjectName('Pattern')
        self.setStyleSheet(GetQssFile.readQss('../resource/qss/pattern.qss'))

        self.log = logging.getLogger('StarCraftII')

        # set widget of layout
        self.frame = QFrame(self)
        self.frame.setGeometry(QDesktopWidget().screenGeometry())
        self.main_layout = QHBoxLayout(self)
        self.human_machine = QRadioButton(strings.HUMAN_VS_MACHINE, self.frame)
        self.machine_machine = QRadioButton(strings.MACHINE_VS_MACHINE,
                                            self.frame)
        self.vs_group = QButtonGroup(self.frame)
        self.main_layout.addWidget(self.human_machine,
                                   alignment=Qt.AlignCenter)
        self.main_layout.addWidget(self.machine_machine,
                                   alignment=Qt.AlignCenter)
        self.main_layout.addStretch(1)
        self.setLayout(self.main_layout)

        # initialization
        self.initUI()

    def initUI(self):
        font = QFont()
        font.setWeight(50)
        font.setPixelSize(15)
        self.human_machine.setFont(font)
        self.machine_machine.setFont(font)
        self.vs_group.addButton(self.human_machine, 1)
        self.vs_group.addButton(self.machine_machine, 2)
        self.vs_group.buttonClicked.connect(self.radioClicked)

    # the slot function of radio group
    def radioClicked(self):
        sender = self.sender()
        if sender == self.vs_group:
            message = ""
            if self.vs_group.checkedId() == 1:
                message = "change pattern: human vs. machine"
                # print(message)
                self.log.info(message)
                globalInformation.set_value('pattern',
                                            strings.HUMAN_VS_MACHINE)
            elif self.vs_group.checkedId() == 2:
                message = "change pattern: machine vs. machine"
                # print(message)
                self.log.info(message)
                globalInformation.set_value('pattern',
                                            strings.MACHINE_VS_MACHINE)
            Signal.get_signal().emit_signal_str(message)
Example #10
0
 def load_stylesheets(self):
     self.prop_style = self.db.get_property(3).split('.')[0]
     self.style_now = self.prop_style
     layout = QGridLayout()
     styles = listdir(abspath('_gui/stylesheets/'))
     for i, style in enumerate(styles):
         name = style.split('.')[0]
         radiobutton = QRadioButton(f"{name}")
         radiobutton.setFont(self.font)
         layout.addWidget(radiobutton)
         if self.prop_style == name:
             radiobutton.setChecked(True)
         radiobutton.toggled.connect(self.switched_style)
         self.ui.tabWidget.widget(4).setLayout(layout)
Example #11
0
 def __init__(self, parent=None, row=0, col=0):
     super(TypeRadioButtons, self).__init__()
     parent.color = 0
     self.parent = parent
     self.bstr = self.parent.cell_types
     for b in range(len(self.bstr)):
         button = QRadioButton(self.bstr[b])
         button.setStyleSheet('color: rgb(190,190,190);')
         button.setFont(QtGui.QFont("Arial", 10))
         if b == 0:
             button.setChecked(True)
         self.addButton(button, b)
         button.toggled.connect(lambda: self.btnpress(parent))
         self.parent.l0.addWidget(button, row + b, col, 1, 2)
     self.setExclusive(True)
Example #12
0
    def __init__(self, parent, x, y, count, text):
        super().__init__(parent)

        self.move(x, y)
        self.radios = []

        for i in range(count):
            radio_button = QRadioButton(text[i], self)
            radio_button.move(0, (i * 22))

            radio_button.setFont(QFont("Segoe UI", 10))

            self.radios.append(radio_button)

        self.refresh()
Example #13
0
 def __init__(self, parent=None, row=0, col=0):
     super(RGBRadioButtons, self).__init__()
     parent.color = 0
     self.parent = parent
     self.bstr = ["image", "gradXY", "cellprob", "gradZ"]
     #self.buttons = QButtonGroup()
     self.dropdown = []
     for b in range(len(self.bstr)):
         button = QRadioButton(self.bstr[b])
         button.setStyleSheet('color: white;')
         button.setFont(QtGui.QFont("Arial", 10))
         if b == 0:
             button.setChecked(True)
         self.addButton(button, b)
         button.toggled.connect(lambda: self.btnpress(parent))
         self.parent.l0.addWidget(button, row + b, col, 1, 1)
     self.setExclusive(True)
Example #14
0
    def Radiobutton(self):
        self.groupbox = QGroupBox("Choose your language!")
        self.groupbox.setFont(QtGui.QFont("Sansrif", 13))

        hboxlayout = QVBoxLayout()

        radiobutton1 = QRadioButton("Python")
        radiobutton1.setIcon(QtGui.QIcon("python.jpg"))
        radiobutton1.setIconSize(QtCore.QSize(40, 40))
        radiobutton1.setFont(QtGui.QFont("Sansrif", 10))
        radiobutton1.setChecked(True)
        radiobutton1.toggled.connect(self.onselect)
        hboxlayout.addWidget(radiobutton1)

        radiobutton2 = QRadioButton("C#")
        radiobutton2.setIcon(QtGui.QIcon("csharp.png"))
        radiobutton2.setIconSize(QtCore.QSize(40, 40))
        radiobutton2.setFont(QtGui.QFont("Sansrif", 10))
        radiobutton2.toggled.connect(self.onselect)
        hboxlayout.addWidget(radiobutton2)

        radiobutton3 = QRadioButton("C++")
        radiobutton3.setIcon(QtGui.QIcon("cpp.png"))
        radiobutton3.setIconSize(QtCore.QSize(40, 40))
        radiobutton3.setFont(QtGui.QFont("Sansrif", 10))
        radiobutton3.toggled.connect(self.onselect)
        hboxlayout.addWidget(radiobutton3)

        self.groupbox.setLayout(hboxlayout)
Example #15
0
class Window(QDialog):

    def __init__(self):
        super().__init__()
        self.title = 'Radio Buttom'
        self.top = 200
        self.left = 400
        self.width = 400
        self.height = 200
        self.iconName = 'avatar.png'
        self.initWindow()

    def initWindow(self):
        self.setWindowIcon(QtGui.QIcon(self.iconName))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.CreateLayout()

        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.label = QLabel('你选择了牛奶', self)
        self.label.setFont(QtGui.QFont('Sanserif', 15))
        vbox.addWidget(self.label)
        self.setLayout(vbox)
        self.show()

    def CreateLayout(self):
        self.groupBox = QGroupBox("请选择一个。。。")
        self.groupBox.setFont(QtGui.QFont('Sanserif', 13))

        hboxLayout = QHBoxLayout()

        self.radiobutton1 = QRadioButton('牛奶')
        self.radiobutton1.setChecked(True)
        self.radiobutton1.setIcon(QtGui.QIcon('avatar.png'))
        self.radiobutton1.setIconSize(QtCore.QSize(25, 25))
        self.radiobutton1.setFont(QtGui.QFont('Sanserif', 13))
        self.radiobutton1.toggled.connect(self.onRadioBtn)
        hboxLayout.addWidget(self.radiobutton1)

        self.radiobtn2 = QRadioButton("蛋糕")
        self.radiobtn2.setIcon(QtGui.QIcon("avatar.png"))
        self.radiobtn2.setIconSize(QtCore.QSize(25, 25))
        self.radiobtn2.setFont(QtGui.QFont("Sanserif", 13))
        self.radiobtn2.toggled.connect(self.onRadioBtn)
        hboxLayout.addWidget(self.radiobtn2)

        self.radiobtn3 = QRadioButton("奶茶")
        self.radiobtn3.setIcon(QtGui.QIcon("avatar.png"))
        self.radiobtn3.setIconSize(QtCore.QSize(25, 25))
        self.radiobtn3.setFont(QtGui.QFont("Sanserif", 13))
        self.radiobtn3.toggled.connect(self.onRadioBtn)
        hboxLayout.addWidget(self.radiobtn3)
        self.groupBox.setLayout(hboxLayout)

    def onRadioBtn(self):
        randioBtn = self.sender()
        if randioBtn.isChecked():
            self.label.setText('你选择了' + randioBtn.text())
Example #16
0
class Window(QDialog):
    def __init__(self):
        super(Window, self).__init__()

        self.ui()

    def ui(self):
        self.setWindowTitle('Диалоговое окно,выполнения дествия при нажатии радио кнопки.')
        self.setGeometry(320,320,200,150)
        # Создаем горизонтальный контейнер.
        self.hbox = QHBoxLayout()

        # Создание радио кнопки.
        self.radio_btn = QRadioButton('Футбол')
        # Устанавливаем шрифт текста.
        self.radio_btn.setFont(QFont('ubuntu',15))
        self.radio_btn.setIcon(QIcon('user_blank.png'))
        self.radio_btn.setIconSize(QSize(40,40))
        self.radio_btn.toggled.connect(self.button_actions)
        # Упаковываем горизонтальный модуль.
        self.hbox.addWidget(self.radio_btn)
        # Создание радио кнопки.
        self.radio_btn_2 = QRadioButton('Баскетбол')
        # Устанавливаем шрифт текста.
        self.radio_btn_2.setFont(QFont('ubuntu', 15))
        self.radio_btn_2.setIcon(QIcon('basketball.png'))
        self.radio_btn_2.setIconSize(QSize(40, 40))
        self.radio_btn_2.toggled.connect(self.button_actions)
        # Упаковываем горизонтальный модуль.
        self.hbox.addWidget(self.radio_btn_2)
        # Создание радио кнопки.
        self.radio_btn_3 = QRadioButton('Воллебол')
        # Устанавливаем шрифт текста.
        self.radio_btn_3.setFont(QFont('ubuntu', 15))
        self.radio_btn_3.setIcon(QIcon('bbb.png'))
        self.radio_btn_3.setIconSize(QSize(40, 40))
        self.radio_btn_3.toggled.connect(self.button_actions)
        # Упаковываем горизонтальный модуль.
        self.hbox.addWidget(self.radio_btn_3)
        self.label = QLabel(self)
        self.label.setFont(QFont('ubuntu',20))
        # Создаем вертикальный модуль.
        self.vbox = QVBoxLayout()
        # Комплектовка вертикального модуля.
        self.vbox.addLayout(self.hbox)
        self.vbox.addWidget(self.label)

        # Отображаем виджеты на мониторе.
        self.setLayout(self.vbox)
        self.show()

    def button_actions(self):
        if self.radio_btn.isChecked():
            self.label.setText('Мой любимый вид спорта {0}'.format(self.radio_btn.text()))
        elif self.radio_btn_2.isChecked():
            self.label.setText('Мой любимый вид спорта {0}'.format(self.radio_btn_2.text()))
        elif self.radio_btn_3.isChecked():
            self.label.setText('Мой любимый вид спорта {0}'.format(self.radio_btn_3.text()))
Example #17
0
class Window(QDialog):
    def __init__(self):
        super().__init__()
        self.title = "Pyqt Window"
        self.top = 500
        self.left = 500
        self.width = 100
        self.height = 400
        self.iconName = "transistor.jpg"
        self.InitWindow()

    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon("transistor.jpg"))
        self.setWindowTitle(self.title)
        self.setGeometry(self.top, self.width, self.height, self.width)
        self.radioButton()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.label = QLabel("")
        self.label.setFont(QtGui.QFont("Sanserif", 15))
        vbox.addWidget(self.label)

        self.setLayout(vbox)

        self.show()

    def radioButton(self):
        self.groupBox = QGroupBox("What is your favorite tit ?")
        self.groupBox.setFont(QtGui.QFont("sanserif", 13))
        hboxlayout = QHBoxLayout()
        self.radiobtn1 = QRadioButton("P**n")
        self.radiobtn1.setChecked(True)
        self.radiobtn1.setIcon(QtGui.QIcon(self.iconName))
        self.radiobtn1.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn1.setFont(QtGui.QFont("Sanserif", 13))
        self.radiobtn1.toggled.connect(self.OnRadioBtn)
        hboxlayout.addWidget(self.radiobtn1)

        self.radiobtn2 = QRadioButton("Mango")
        self.radiobtn2.setIcon(QtGui.QIcon(self.iconName))
        self.radiobtn2.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn2.setFont(QtGui.QFont("Sanserif", 13))
        self.radiobtn2.toggled.connect(self.OnRadioBtn)
        hboxlayout.addWidget(self.radiobtn2)

        self.radiobtn3 = QRadioButton("Vodka")
        self.radiobtn3.setIcon(QtGui.QIcon(self.iconName))
        self.radiobtn3.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn3.setFont(QtGui.QFont("Sanserif", 13))
        self.radiobtn3.toggled.connect(self.OnRadioBtn)
        hboxlayout.addWidget(self.radiobtn3)

        self.groupBox.setLayout(hboxlayout)

    def OnRadioBtn(self):
        radioBtn = self.sender()
        if radioBtn.isChecked():
            self.label.setText("you have selected " + radioBtn.text())
Example #18
0
    def crt_radio_btn(self):
        groupbox = QGroupBox("What's ur sportsmanship??")
        groupbox.setFont(QFont("Sanserif", 15))

        hbox = QHBoxLayout()

        rbtn1 = QRadioButton("Soccer")
        rbtn1.setChecked(True)
        rbtn1.setIcon(QIcon("src\\shoe.png"))
        rbtn1.setIconSize(QSize(40, 40))
        rbtn1.setFont(QFont("Sanserif", 14))
        rbtn1.toggled.connect(self.select)

        rbtn2 = QRadioButton("Baseball")
        rbtn2.setIcon(QIcon("src\\ball.png"))
        rbtn2.setIconSize(QSize(40, 40))
        rbtn2.setFont(QFont("Sanserif", 14))
        rbtn2.toggled.connect(self.select)

        rbtn3 = QRadioButton("Football")
        rbtn3.setIcon(QIcon("src\\landscape.jpg"))
        rbtn3.setIconSize(QSize(40, 40))
        rbtn3.setFont(QFont("Sanserif", 14))
        rbtn3.toggled.connect(self.select)

        rbtn4 = QRadioButton("Basketball")
        rbtn4.setIcon(QIcon("src\\chessboard.png"))
        rbtn4.setIconSize(QSize(40, 40))
        rbtn4.setFont(QFont("Sanserif", 14))
        rbtn4.toggled.connect(self.select)

        hbox.addWidget(rbtn1)
        hbox.addWidget(rbtn2)
        hbox.addWidget(rbtn3)
        hbox.addWidget(rbtn4)
        groupbox.setLayout(hbox)
        # Group everything in the group box

        vbox = QVBoxLayout()
        vbox.addWidget(groupbox)
        vbox.addWidget(self.label)
        # Group the group box in the vbox

        self.setLayout(vbox)
Example #19
0
class Window(QDialog):
    def __init__(self):
        super().__init__()
        self.title = "PyQt5 Adding Image To Label"
        self.icon = "icon.png"
        self.top = 200
        self.left = 500
        self.width = 400
        self.height = 300
        self.init_window()

    def init_window(self):
        self.setWindowTitle(self.title)
        self.setWindowIcon(QIcon(self.icon))
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.create_layout()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.label = QLabel(self)
        self.label.setFont(QFont('Sanserif', 15))
        vbox.addWidget(self.label)
        self.setLayout(vbox)
        self.show()

    def create_layout(self):
        self.groupBox = QGroupBox(
            'What Is Your Favorite Programming Language?')
        self.groupBox.setFont(QFont('Sanserif', 13))
        hboxlayout = QHBoxLayout()
        self.radiobtn1 = QRadioButton('Python')
        self.radiobtn1.setFont(QFont('Sanserif', 13))
        self.radiobtn1.toggled.connect(self.onRadioBtn)
        hboxlayout.addWidget(self.radiobtn1)
        self.radiobtn2 = QRadioButton('Java')
        self.radiobtn2.setFont(QFont('Sanserif', 13))
        self.radiobtn2.toggled.connect(self.onRadioBtn)
        hboxlayout.addWidget(self.radiobtn2)
        self.radiobtn3 = QRadioButton('Golang')
        self.radiobtn3.setFont(QFont('Sanserif', 13))
        self.radiobtn3.toggled.connect(self.onRadioBtn)
        hboxlayout.addWidget(self.radiobtn3)
        self.groupBox.setLayout(hboxlayout)

    def onRadioBtn(self):
        radioBtn = self.sender()
        if radioBtn.isChecked():
            self.label.setText('You have selected {}'.format(radioBtn.text()))
Example #20
0
File: UI.py Project: FreeHe/FreeSC
class Vit(QFrame):
    def __init__(self, acc, parent, mp4):
        super(Vit, self).__init__()
        self.parent = parent
        self.acc = acc
        self.mp4 = mp4
        self.image = ""
        self.setFont(QFont("黑体"))
        self.setFixedSize(750, 120)
        self.setProperty("name", "vit")
        self.setStyleSheet("""
            Vit {
                background-color: #181818;
                padding: 0;
            }
            Lb {
                background-color: #181818;
            }
            QComboBox {
                background-color: #101010;
            }
            QComboBox QAbstractItemView {
                background-color: #181818;
                color: #fff;
                selection-color: #cccccc;
            }
            QLabel,QTextEdit {
                background-color: #101010;
                border: 0 solid #fff;
                color: #fff;
            }
            QLineEdit[name="cd"] {
                color: #aaa;
            }
            QLineEdit {
                background-color: #181818;
                border: 0 solid #fff;
                color: #fff;
            }
            QTextEdit[name="cte"] {
                font-size: 15px;
                background-color: #181818;
            }
            QRadioButton {
                font-size: 15px;
                color: #606060;
            }
        """)
        self.vpic = Lb()
        self.tgs = ["游戏", "搞笑", "原创", "电影", "电视剧", "数码", "体育", "音乐"]
        self.vpic.setFixedSize(160, 120)
        self.vpic.s.connect(self.change_im)
        self.lay = QHBoxLayout()
        self.lay.setContentsMargins(0, 0, 0, 0)
        self.contents = QWidget()
        self.contents.setFixedSize(400, 100)
        self.contents.setProperty("name", "cnt")
        self.contents_lay = QVBoxLayout()
        self.contents_lay.setContentsMargins(0, 0, 0, 0)
        title = self.mp4.split(os.path.dirname(self.mp4))[-1][1:-4]
        self.contents_title = QTextEdit()
        self.contents_title.setFixedSize(400, 40)
        self.contents_title.setProperty("name", "cte")
        self.contents_title.setPlaceholderText("标题 : 不超过30字")
        self.contents_title.setText(title[:30])
        self.contents_desc = QLineEdit()
        self.contents_desc.setFixedSize(400, 20)
        self.contents_desc.setPlaceholderText("一句话推荐 : 简介")
        self.contents_desc.setProperty("name", "cd")
        self.contents_desc.setText(title)
        self.contents_title.setFont(QFont("黑体"))
        self.contents_desc.setFont(QFont("黑体"))
        self.contents_sel = QWidget()
        self.contents_sel.setFixedSize(400, 40)
        self.contents_sel_lay = QHBoxLayout()
        self.contents_sel_lay.setContentsMargins(0, 0, 0, 0)
        self.contents_sel_col = QComboBox()
        self.contents_sel_col.setFont(QFont("黑体"))
        self.col = Le()
        self.col.setReadOnly(True)
        self.col.setAlignment(Qt.AlignLeft)
        self.col.s.connect(self.contents_sel_col.showPopup)
        self.contents_sel_col.setLineEdit(self.col)
        self.its = self.parent.cols.split(';') if self.parent.cols else []
        self.its = [[k.split("><")[0], k.split("><")[1]] for k in self.its
                    if k.split("><")[2] == "已发布"]
        self.contents_sel_col.addItems(["单个视频", *[t[0] for t in self.its]])
        self.contents_sel_col.setFixedSize(150, 25)
        self.contents_sel_col.currentTextChanged.connect(self.dis_cls)
        self.contents_sel_cls = QComboBox()
        self.contents_sel_cls.setFont(QFont("黑体"))
        self.cls = Le()
        self.cls.setReadOnly(True)
        self.cls.setAlignment(Qt.AlignLeft)
        self.cls.s.connect(self.contents_sel_cls.showPopup)
        self.contents_sel_cls.setLineEdit(self.cls)
        self.contents_sel_cls.setFixedSize(100, 25)
        self.contents_sel_cls.addItems(self.tgs)
        self.original = QRadioButton('原创')
        self.original.setChecked(True)
        self.original.setFont(QFont("黑体"))
        self.contents_sel_lay.addWidget(self.contents_sel_col)
        self.contents_sel_lay.addWidget(self.contents_sel_cls)
        self.contents_sel_lay.addStretch()
        self.contents_sel_lay.addWidget(self.original)
        self.contents_sel_lay.addSpacing(10)
        self.contents_sel.setLayout(self.contents_sel_lay)
        self.contents_lay.addWidget(self.contents_title)
        self.contents_lay.addWidget(self.contents_desc)
        self.contents_lay.addWidget(self.contents_sel)
        self.contents.setLayout(self.contents_lay)
        self.tags = QTextEdit()
        self.tags.setFixedSize(150, 100)
        self.tags.setPlaceholderText("标签 : 以空格和换行分隔")
        self.tags.setFont(QFont('黑体'))
        self.d = Bl("D")
        self.d.setFixedSize(30, 120)
        self.d.setStyleSheet("Bl {background-color: #101010;}")
        self.lay.addWidget(self.vpic)
        self.lay.addWidget(self.contents)
        self.lay.addWidget(self.tags)
        self.lay.addStretch()
        self.lay.addWidget(self.d)
        self.setLayout(self.lay)
        self.d.s.connect(self.delete)
        self.get_img()

    def dis_cls(self):
        if self.contents_sel_col.currentText() != "单个视频":
            for ind, i in enumerate(self.its):
                if i[0] == self.contents_sel_col.currentText(
                ) and i[1] in self.tgs:
                    self.contents_sel_cls.setCurrentText(i[1])
                    self.contents_sel_cls.setEnabled(False)
        else:
            self.contents_sel_cls.setEnabled(True)
        QApplication.processEvents()

    def delete(self):
        self.parent.lay.removeWidget(self)
        self.setParent(None)
        del self.parent.vits[self.mp4]

    def get_img(self):
        try:
            f = cv.VideoCapture(self.mp4)
            ret, frame = f.read()
            n = 0
            while ret and n != 20:
                ret, frame = f.read()
                n += 1
            if not os.path.isdir(f"./tmp/{self.acc}"):
                os.mkdir(f"./tmp/{self.acc}")
            im = cv.resize(frame, (1920, 1080), interpolation=cv.INTER_CUBIC)
            cv.imencode(".png", im)[1].tofile(
                f"./tmp/{self.acc}/{self.contents_title.toPlainText()}.png")
            f.release()
            self.vpic.setPixmap(
                QPixmap(
                    f"./tmp/{self.acc}/{self.contents_title.toPlainText()}.png"
                ).scaled(160, 120))
            self.image = f"./tmp/{self.acc}/{self.contents_title.toPlainText()}.png"
        except:
            traceback.print_exc()

    def change_im(self):
        try:
            im, _ = QFileDialog.getOpenFileName(self, "选择封面", "./",
                                                "*.png;*.jpg")
            if im.endswith('png') or im.endswith('jpg'):
                ic = cv.imread(im)
                if ic.shape[0] > 720 and ic.shape[1] > 1080:
                    self.image = im
                    self.vpic.setPixmap(QPixmap(self.image).scaled(160, 120))
        except:
            traceback.print_exc()
Example #21
0
class FormWidget(QWidget):

    def __init__(self, parent):
        super(FormWidget, self).__init__(parent)
        self.layout = QVBoxLayout(self)
        self.progressBar = QProgressBar()

        self.SN = QLabel('Serial Number: ')
        self.SN.setFont(QtGui.QFont('Times New Roman', 11))
        self.SN_num = QLineEdit(self)
        self.SN_num.textChanged.connect(self.text_SN)
        self.SN_num.setFont(QtGui.QFont('Times New Roman', 11))
        self.SN_num_label = QLabel(self)

        self.type = QLabel('Choose Type:')
        self.type.setFont(QtGui.QFont('Times New Roman', 11))
        self.cisco = QRadioButton('Cisco')
        self.cisco.setFont(QtGui.QFont('Times New Roman', 11))
        self.brocade = QRadioButton('Brocade')
        self.brocade.setFont(QtGui.QFont('Times New Roman', 11))

        self.h_box1 = QHBoxLayout(self)
        self.h_box1.addWidget(self.type)
        self.h_box1.addWidget(self.cisco)
        self.h_box1.addWidget(self.brocade)
        self.h_box1.addStretch()
        self.h_box1.setAlignment(Qt.AlignHCenter)

        self.current = QLabel('Target Code: ')
        self.current.setFont(QtGui.QFont('Times New Roman', 11))
        self.comboBox = QComboBox()
        self.comboBox.setFont(QtGui.QFont('Times New Roman', 11))
        self.brocade.toggled.connect(self.onClicked)
        self.cisco.toggled.connect(self.onClicked)
        self.comboBox.activated.connect(self.handleActivated)

        self.comboBox2 = QComboBox()
        self.comboBox2.setFont(QtGui.QFont('Times New Roman', 11))
        self.comboBox2.activated.connect(self.handleActivated2)

        self.h_box2 = QHBoxLayout()
        self.h_box2.addWidget(self.current)
        self.h_box2.addWidget(self.comboBox)
        self.h_box2.addWidget(self.comboBox2)
        self.h_box2.addStretch()

        self.h_box0 = QHBoxLayout()
        self.h_box0.addWidget(self.SN)
        self.h_box0.addWidget(self.SN_num)
        self.h_box0.addWidget(self.SN_num_label)
        self.h_box0.addStretch()

        self.ip = QLabel('IP address')
        self.ip.setFont(QtGui.QFont('Times New Roman', 11))
        self.ip_inp = QLineEdit(self)
        self.ip_inp.setFont(QtGui.QFont('Times New Roman', 11))

        self.h_box3 = QHBoxLayout()
        self.h_box3.addWidget(self.ip)
        self.h_box3.addWidget(self.ip_inp)
        self.h_box3.addStretch()

        self.username = QLabel('Username')
        self.username.setFont(QtGui.QFont('Times New Roman', 11))
        self.username_inp = QLineEdit(self)
        self.username_inp.setFont(QtGui.QFont('Times New Roman', 11))

        self.h_box4 = QHBoxLayout()
        self.h_box4.addWidget(self.username)
        self.h_box4.addWidget(self.username_inp)
        self.h_box4.addStretch()

        self.password = QLabel('Password')
        self.password.setFont(QtGui.QFont('Times New Roman', 11))
        self.password_inp = QLineEdit(self)
        self.password_inp.setFont(QtGui.QFont('Times New Roman', 11))

        self.h_box5 = QHBoxLayout()
        self.h_box5.addWidget(self.password)
        self.h_box5.addWidget(self.password_inp)
        self.h_box5.addStretch()

        self.submit_btn = QPushButton('Submit')
        self.submit_btn.setFixedWidth(120)
        self.submit_btn.clicked.connect(self.connection)

        self.browse_btn = QPushButton('Browse')
        self.browse_btn.setFixedWidth(120)
        self.browse_btn.clicked.connect(self.browse_connection)

        self.layout.addLayout(self.h_box0)
        self.layout.addLayout(self.h_box1)
        self.layout.addLayout(self.h_box2)
        self.layout.addLayout(self.h_box3)
        self.layout.addLayout(self.h_box4)
        self.layout.addLayout(self.h_box5)
        self.layout.addWidget(self.submit_btn)
        #self.layout.addWidget(self.browse_btn)
        self.layout.addWidget(self.progressBar)

        self.layout.addStretch()

        self.layout.setAlignment(Qt.AlignHCenter)
        self.setLayout(self.layout)
        self.show()

    def onClicked(self):
        if self.brocade.isChecked():
            self.comboBox.clear()
            self.comboBox.addItem('6.4.x')
            self.comboBox.addItem('7.0.x')
            self.comboBox.addItem('7.1.x')
            self.comboBox.addItem('7.2.x')
            self.comboBox.addItem('7.3.x')
            self.comboBox.addItem('7.4.x')
            self.comboBox.addItem('8.0.x')
            self.comboBox.addItem('8.1.x')
            self.comboBox.addItem('8.2.x')

        elif self.cisco.isChecked():
            self.comboBox.clear()
            self.comboBox.addItem('5.0x')
            self.comboBox.addItem('5.2x')
            self.comboBox.addItem('6.2x')
            self.comboBox.addItem('7.3x')
            self.comboBox.addItem('8.1x')
            self.comboBox.addItem('8.2x')
            self.comboBox.addItem('8.3x')

    def handleActivated(self, index):
        print(self.comboBox.itemText(index))
        if '6.4.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('6.4.3g')

        if '7.0.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('EOPS')

        if '7.1.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('7.1.0c')
            self.comboBox2.addItem('7.4.1e')
            self.comboBox2.addItem('7.4.2')
            self.comboBox2.addItem('7.4.2a')
            self.comboBox2.addItem('7.4.2b')
            self.comboBox2.addItem('7.4.2c')
            self.comboBox2.addItem('7.4.2d')

        if '7.2.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('7.2.1d')

        if '7.3.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('7.3.0b')
            self.comboBox2.addItem('7.3.1c')
            self.comboBox2.addItem('7.3.1e')
            self.comboBox2.addItem('7.3.2b')

        if '7.4.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('7.4.1d')
            self.comboBox2.addItem('7.4.1e')
            self.comboBox2.addItem('7.4.2')
            self.comboBox2.addItem('7.4.2a')
            self.comboBox2.addItem('7.4.2b')
            self.comboBox2.addItem('7.4.2c')
            self.comboBox2.addItem('7.4.2d')

        if '8.0.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.0.1b')
            self.comboBox2.addItem('8.0.2b')
            self.comboBox2.addItem('8.0.2c')
            self.comboBox2.addItem('8.0.2d')
            self.comboBox2.addItem('8.0.2f')

        if '8.1.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.1.0a')
            self.comboBox2.addItem('8.1.0c')
            self.comboBox2.addItem('8.1.1a')
            self.comboBox2.addItem('8.1.2a')
            self.comboBox2.addItem('8.1.2b')
            self.comboBox2.addItem('8.1.2d')
            self.comboBox2.addItem('8.1.2f')

        if '5.0x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('5.0(8a)')

        if '5.2x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('5.2(2)')
            self.comboBox2.addItem('5.2(8b)')
            self.comboBox2.addItem('5.2(8c)')
            self.comboBox2.addItem('5.2(8d)')
            self.comboBox2.addItem('5.2(8e)')
            self.comboBox2.addItem('5.2(8f)')
            self.comboBox2.addItem('5.2(8h)')
            self.comboBox2.addItem('5.2(8i)')

        if '6.2x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('6.2(1)')
            self.comboBox2.addItem('6.2(3)')
            self.comboBox2.addItem('6.2(5)')
            self.comboBox2.addItem('6.2(5a)')
            self.comboBox2.addItem('6.2(7)')
            self.comboBox2.addItem('6.2(9)')
            self.comboBox2.addItem('6.2(9a)')
            self.comboBox2.addItem('6.2(11)')
            self.comboBox2.addItem('6.2(11b)')
            self.comboBox2.addItem('6.2(11c)')
            self.comboBox2.addItem('6.2(11e)')
            self.comboBox2.addItem('6.2(13)')
            self.comboBox2.addItem('6.2(13a)')
            self.comboBox2.addItem('6.2(17)')
            self.comboBox2.addItem('6.2(19)')
            self.comboBox2.addItem('6.2(21)')
            self.comboBox2.addItem('6.2(23)')
            self.comboBox2.addItem('6.2(25)')

        if '8.1.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.1(1)')
            self.comboBox2.addItem('8.1(1a)')
            self.comboBox2.addItem('8.1(1b)')

        if '8.2.x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.2.0a')
            self.comboBox2.addItem('8.2.0b')
            self.comboBox2.addItem('8.2.1a')

        if '7.3x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('7.3(0)D1(1)')
            self.comboBox2.addItem('7.3(0)DY(1)')
            self.comboBox2.addItem('7.3(1)D1(1)')
            self.comboBox2.addItem('7.3(1)DY(1)')

        if '8.1x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.1(1)')
            self.comboBox2.addItem('8.1(1a)')
            self.comboBox2.addItem('8.1(1b)')

        if '8.2x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.2(1)')
            self.comboBox2.addItem('8.2(2)')

        if '8.3x' in self.comboBox.itemText(index):
            self.comboBox2.clear()
            self.comboBox2.addItem('8.3(1)')

    def handleActivated2(self, index):
        print(self.comboBox2.itemText(index))
        self.target = self.comboBox2.itemText(index)
        return self.target

    def text_SN(self):
        self.SN_num_label.setText('SN number => ' + self.SN_num.text())

    def browse_connection(self):
        self.fileName = QFileDialog.getSaveFileName(self, "QFileDialog.getSaveFileName()",  "", "Text Files (*.txt)")
        self.file = open(os.path.join(r'' + self.fileName[0]), "w")
        print("done")

    def connection(self, index):
        self.fileName = QFileDialog.getSaveFileName(self, "QFileDialog.getSaveFileName()",  "", "Text Files (*.txt)")
        self.basepath = os.path.join(r'' + self.fileName[0])
        #self.file = open(self.basepath, "w")
        con_thread = MyThread()
        print("MyThread")
        #progress_thread = progressThread()
        #progress_thread.start(self)
        print("started")
        #self.progress_thread.progress_update(value)
        #print("connected")
        print(self.basepath)
        tmp = self.basepath
        tmp2 = self.ip_inp.text()
        tmp3 = self.username_inp.text()
        tmp4 = self.password_inp.text()
        con_thread.pass_parameters(tmp, tmp2, tmp3, tmp4)
        print("mythread started")
        #self.txt = (CLI.connection(self.ip_inp.text(), self.username_inp.text(), self.password_inp.text()))

        """for x in range(len(self.txt)):
            self.file.write(self.txt[x])
        self.file.close()
        print("wrote")
        if self.brocade.isChecked():
            Brocade.main(self.SN_num.text(), self.target, (os.path.dirname(self.basepath)), self.basepath)
            print(self.basepath)
        elif self.cisco.isChecked():
            Cisco.main(self.SN_num.text(), self.target, (os.path.dirname(self.basepath)), self.basepath)
            print(self.basepath)
            """
    def onCountChanged(self, value):
        self.progressBar.setValue(value)
class RegisterForm(QDialog):
    def __init__(self, model):
        super(RegisterForm, self).__init__()
        self.m = model
        self.initUI()

    def initUI(self):
        self.setWindowTitle("Register form")
        self.setMaximumSize(500, 820)
        self.setMinimumSize(500, 820)
        self.setGeometry(590, 0, 500, 820)
        self.setStyleSheet("background-color: grey")

        self.yourInformationLabel = QLabel("Your information", self)
        self.yourInformationLabel.move(70, 20)
        self.yourInformationLabel.setStyleSheet("color:white")
        self.yourInformationLabel.setFont(
            QtGui.QFont("Times", 35, QtGui.QFont.Bold))

        self.NameLabel = QLabel("First name", self)
        self.NameLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.NameLabel.move(20, 100)
        self.NameLabel.setStyleSheet("color: white")
        self.NameEntry = QLineEdit(self)
        self.NameEntry.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.NameEntry.move(250, 105)
        self.NameEntry.setStyleSheet("background-color:white")

        self.ageLabel = QLabel("Date of birth", self)
        self.ageLabel.move(20, 175)
        self.ageLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.ageLabel.setStyleSheet("color: white")
        self.ageButton = QPushButton("Select date", self)
        self.ageButton.setGeometry(250, 180, 205, 25)
        self.ageButton.setStyleSheet("background-color:white")
        self.ageButton.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.ageButton.clicked.connect(self.calendar)

        self.genderLabel = QLabel("Gender", self)
        self.genderLabel.move(20, 250)
        self.genderLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.genderLabel.setStyleSheet("color: white")
        self.gender = QRadioButton('Male', self)
        self.gender.setChecked(True)
        self.gender.gender = "Male"
        self.gender.setStyleSheet("color: white")
        self.gender.move(200, 255)
        self.gender.setFont(QtGui.QFont("Times", 20, QtGui.QFont.Bold))
        self.gender = QRadioButton('Female', self)
        self.gender.gender = "Female"
        self.gender.setStyleSheet("color: white")
        self.gender.move(300, 255)
        self.gender.setFont(QtGui.QFont("Times", 20, QtGui.QFont.Bold))

        self.locationLabel = QLabel("Location", self)
        self.locationLabel.move(20, 325)
        self.locationLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.locationLabel.setStyleSheet("color: white")
        self.locationEntry = QLineEdit(self)
        self.locationEntry.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.locationEntry.move(250, 330)
        self.locationEntry.setStyleSheet("background-color:white")

        self.phoneLabel = QLabel("Phone", self)
        self.phoneLabel.move(20, 400)
        self.phoneLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.phoneLabel.setStyleSheet("color: white")
        self.phoneEntry = QLineEdit(self)
        self.phoneEntry.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.phoneEntry.move(250, 405)
        self.phoneEntry.setStyleSheet("background-color:white")

        self.weighLabel = QLabel("Weigh", self)
        self.weighLabel.move(20, 475)
        self.weighLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.weighLabel.setStyleSheet("color: white")
        self.weighEntry = QComboBox(self)
        self.weighEntry.setGeometry(QtCore.QRect(250, 480, 100, 30))
        self.weighEntry.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.weighEntry.addItems(self.m.getAllweighes())

        self.bloodLabel = QLabel("Blood type", self)
        self.bloodLabel.move(20, 550)
        self.bloodLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.bloodLabel.setStyleSheet("color: white")
        self.bloodEntry = QComboBox(self)
        self.bloodEntry.setGeometry(QtCore.QRect(250, 555, 100, 30))
        self.bloodEntry.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.bloodEntry.addItems(self.m.getAllbloodtypes())

        self.passwordLabel = QLabel("Password", self)
        self.passwordLabel.move(20, 625)
        self.passwordLabel.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.passwordLabel.setStyleSheet("color: white")
        self.passwordEntry = QLineEdit(self)
        self.passwordEntry.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
        self.passwordEntry.setEchoMode(QLineEdit.Password)
        self.passwordEntry.move(250, 630)
        self.passwordEntry.setStyleSheet("background-color:white")

        self.cancelButton = QPushButton("Cancel", self)
        self.cancelButton.resize(150, 50)
        self.cancelButton.move(60, 700)
        self.cancelButton.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.cancelButton.setStyleSheet(
            'QPushButton:hover { background-color: rgb(51, 51, 255);text-decoration: underline;} QPushButton:!hover { background-color: rgb(0, 102, 255); color:white;}'
        )
        self.cancelButton.clicked.connect(self.close)

        self.submitButton = QPushButton("Submit", self)
        self.submitButton.resize(150, 50)
        self.submitButton.move(255, 700)
        self.submitButton.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.submitButton.setStyleSheet(
            'QPushButton:hover { background-color: rgb(51, 51, 255);text-decoration: underline;} QPushButton:!hover { background-color: rgb(0, 102, 255); color:white;}'
        )
        self.submitButton.clicked.connect(self.submit)

        self.changeButton = QPushButton("Change", self)
        self.changeButton.resize(150, 50)
        self.changeButton.move(255, 700)
        self.changeButton.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Bold))
        self.changeButton.setStyleSheet(
            'QPushButton:hover { background-color: rgb(51, 51, 255);text-decoration: underline;} QPushButton:!hover { background-color: rgb(0, 102, 255); color:white;}'
        )
        self.changeButton.setVisible(False)

    def submit(self):
        if self.NameEntry.text() == "" or self.ageButton.text(
        ) == "Select date" or self.locationEntry.text(
        ) == "" or self.weighEntry.currentText(
        ) == "Select" or self.bloodEntry.currentText(
        ) == "Select" or self.passwordEntry.text(
        ) == "" or self.phoneEntry.text() == "":
            w = WarningW()
            w.move(640, 400)
            w.exec_()
        else:
            name = self.NameEntry.text()
            age = self.ageButton.text()
            gender = self.gender.gender
            location = self.locationEntry.text()
            weigh = self.weighEntry.currentText()
            blood = self.bloodEntry.currentIndex()
            phone = self.phoneEntry.text()
            password = self.passwordEntry.text()
            self.cl = Client(name, age, gender, location, phone, weigh, blood,
                             password)
            conn = sqlite3.connect(conn_str)
            req1 = conn.execute(
                "select count(Clients.id) from Clients where Clients.phone = '"
                + str(self.cl.getPhone()) + "'")
            count1 = 0
            for item in req1:
                count1 = item[0]
            if count1 != 0:
                w = WarningW()
                w.label.setText("You have already registered")
                w.label.move(20, 35)
                w.move(500, 400)
                w.resize(400, 100)
                w.okButton.move(150, 70)
                w.exec_()
            else:
                conn.execute(
                    "insert into Clients (Name, birthdate, gender, location, phone, weigh, blood, password) values('"
                    + str(self.cl.getName()) + "', '" + str(self.cl.getAge()) +
                    "', '" + str(self.cl.getGender()) + "', '" +
                    str(self.cl.getLocation()) + "', '" +
                    str(self.cl.getPhone()) + "', '" +
                    str(self.cl.getWeigh()) + "', '" +
                    str(self.cl.getBlood()) + "', '" +
                    str(self.cl.getPassword()) + "')")
                conn.commit()
                self.close()

    def calendar(self):
        w = Calendar()
        w.exec_()
        self.ageButton.setText(w.s)
Example #23
0
class Window(QDialog):
    def __init__(self):
        super().__init__()

        self.title = "PyQt5 - Radio Button"
        self.left = 300
        self.top = 400
        self.width = 400
        self.height = 300
        self.iconName = "_imagens/mouse.ico"

        self.InitWindow()

    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon(self.iconName))
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.setWindowTitle(self.title)

        self.radioButton()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)

        self.label = QLabel(self)
        self.label.setFont(QtGui.QFont("Sanserif", 15))
        vbox.addWidget(self.label)

        self.setLayout(vbox)

        self.show()

    def radioButton(self):
        self.groupBox = QGroupBox("Escolha o seu sexo")
        self.groupBox.setFont(QtGui.QFont("Sanserif", 13))

        hboxLayout = QHBoxLayout()

        self.radioMale = QRadioButton("Masculino")
        self.radioMale.setChecked(True)
        self.radioMale.setIcon(QtGui.QIcon("_imagens/male.jpg"))
        self.radioMale.setIconSize(QtCore.QSize(30, 30))
        self.radioMale.setFont(QtGui.QFont("Sanserif", 13))
        self.radioMale.toggled.connect(self.OnRadioBtn)

        self.radioFemale = QRadioButton("Feminino")
        self.radioFemale.setIcon(QtGui.QIcon("_imagens/female.ico"))
        self.radioFemale.setIconSize(QtCore.QSize(30, 30))
        self.radioFemale.setFont(QtGui.QFont("Sanserif", 13))
        self.radioFemale.toggled.connect(self.OnRadioBtn)

        self.radioNone = QRadioButton("Prefiro não informar")
        self.radioNone.setIcon(QtGui.QIcon("_imagens/none.png"))
        self.radioNone.setIconSize(QtCore.QSize(30, 30))
        self.radioNone.setFont(QtGui.QFont("Sanserif", 13))
        self.radioNone.toggled.connect(self.OnRadioBtn)

        hboxLayout.addWidget(self.radioMale)
        hboxLayout.addWidget(self.radioFemale)
        hboxLayout.addWidget(self.radioNone)

        self.groupBox.setLayout(hboxLayout)

    def OnRadioBtn(self):
        radioBtn = self.sender()

        if radioBtn.isChecked():
            self.label.setText("Selecionado: " + radioBtn.text())
Example #24
0
class DownMusic(QMainWindow):
    def __init__(self):
        super().__init__()
        self.StartGui()
        self.bt3.setEnabled(False)

    def update(self, result):
        # 更新文字内容
        if result == 'Clear now':
            self.text.clear()
        elif result == 'have finished':
            self.text.append('歌单下载完成')
            self.bt1.setEnabled(True)
        elif result == 'finished':
            self.bt1.setEnabled(True)
        else:
            self.text.append(result)

    def StartDown(self):
        # 开始下载
        if self.platform == '':
            self.text.clear()
            self.text.append('请选择平台')
        else:
            if (self.input1.text() == ''):
                pass
            else:
                url = self.input1.text()
                path = self.input2.text()
                platform = self.platform
                self.result = Downthread(url, path, platform)
                self.result.signal.connect(self.update)
                self.result.start()
                self.bt1.setEnabled(False)
                self.bt3.setEnabled(True)

    def Stop(self):
        # 停止下载
        self.result.status = False
        self.bt1.setEnabled(True)

    def SelectPath(self):
        # 选择路径
        path = QFileDialog.getExistingDirectory(self, '选取文件夹', './')
        self.input2.setText(path)

    def select_platform(self):
        # 选择平台
        if self.qr1.isChecked():
            self.platform = 'wangyi'
        elif self.qr2.isChecked():
            self.platform = 'kuwo'
        elif self.qr3.isChecked():
            self.platform = 'qqmusic'

    def StartGui(self):
        # 启动界面
        def screencenter():
            # 屏幕居中
            desktop = QApplication.desktop()
            screenrect = desktop.screenGeometry()
            scr_w = screenrect.width()
            scr_h = screenrect.height()
            cen_w = (scr_w - 974) / 2
            cen_h = (scr_h - 730) / 2
            return cen_w, cen_h

        def AboutUs():
            # 关于
            MsgBox = QMessageBox(
                QMessageBox.NoIcon, '关于我们',
                '这只是一个用来方便下载的工具\n感谢\nCharles提供的酷我音乐\n\npowered by Nobilta \nVersion:3.0'
            )
            MsgBox.exec()

        def Help():
            # 帮助
            Msgbox = QMessageBox(
                QMessageBox.NoIcon, '帮助',
                '复制一个单曲(歌单),粘贴到工具中,选择平台,点击下载,默认路径为D:\\MusicDownload(-歌单名)\n如遇下载失败,建议尝试其他平台 '
            )
            Msgbox.exec()

        self.platform = ''
        w, h = screencenter()
        # 背景图片
        palette = QtGui.QPalette()
        palette.setBrush(QPalette.Background, QBrush(QPixmap("bg.jpg")))

        # 文字标签
        self.lb1 = QLabel("请输入单曲(歌单)链接:", self)
        self.lb1.resize(350, 25)
        self.lb1.move(18, 32)
        self.lb1.setStyleSheet('color:#696969')
        self.lb1.setFont(QFont("微软雅黑", 15))

        # 输入框
        self.input1 = QLineEdit(self)
        self.input1.resize(700, 20)
        self.input1.move(18, 85)
        self.input1.setPlaceholderText("请输入链接")
        self.input1.setFont(QFont("Arial", 14))
        self.input1.setStyleSheet(
            "background:transparent;border-width:0;border-style:outset;color:#696969;font-style:italic"
        )

        self.lb2 = QLabel(
            "————————————————————————————————————————————————————————————————————",
            self)
        self.lb2.resize(700, 15)
        self.lb2.move(18, 108)
        self.lb2.setFont(QFont("微软雅黑", 11))
        self.lb2.setStyleSheet("color:#696969")

        # 下载按钮
        self.bt1 = QPushButton("下载", self)
        self.bt1.resize(60, 30)
        self.bt1.move(740, 90)
        self.bt1.setFont(QFont("微软雅黑", 9))
        self.bt1.setStyleSheet(
            "background:#7ccee3;color:white;border-radius:15px")
        self.bt1.clicked.connect(self.StartDown)

        # 停止按钮
        self.bt3 = QPushButton("停止", self)
        self.bt3.resize(60, 30)
        self.bt3.move(820, 90)
        self.bt3.setFont(QFont("微软雅黑", 9))
        self.bt3.setStyleSheet(
            "background:#FD9892;color:white;border-radius:15px")
        self.bt3.clicked.connect(self.Stop)

        # 选择按钮
        self.qr1 = QRadioButton('网易云音乐', self)
        self.qr1.resize(120, 30)
        self.qr1.move(20, 125)
        self.qr1.setFont(QFont('微软雅黑', 11))
        self.qr1.setStyleSheet('color:blue')
        self.qr1.clicked.connect(self.select_platform)
        self.qr2 = QRadioButton('酷我音乐', self)
        self.qr2.resize(120, 30)
        self.qr2.move(150, 125)
        self.qr2.setFont(QFont('微软雅黑', 11))
        self.qr2.setStyleSheet('color:blue')
        self.qr2.clicked.connect(self.select_platform)
        self.qr3 = QRadioButton("QQ音乐", self)
        self.qr3.resize(120, 30)
        self.qr3.move(270, 125)
        self.qr3.setFont(QFont('微软雅黑', 11))
        self.qr3.setStyleSheet('color:blue')
        self.qr3.clicked.connect(self.select_platform)
        # 显示框
        self.text = QTextBrowser(self)
        self.text.resize(800, 430)
        self.text.move(87, 170)
        self.text.setFont(QFont("微软雅黑", 13))
        self.text.setStyleSheet(
            "background:transparent;color:#696969;border-color:#696969")

        # 设置路径
        self.input2 = QLineEdit(self)
        self.input2.resize(615, 25)
        self.input2.move(185, 623)
        self.input2.setFont(QFont("Arial", 12))
        self.input2.setStyleSheet(
            "background:transparent;color:#696969;border-width:0;border-style:outset"
        )
        self.lb3 = QLabel("选择路径:", self)
        self.lb3.resize(100, 30)
        self.lb3.move(80, 620)
        self.lb3.setFont(QFont("微软雅黑", 14))
        self.lb3.setStyleSheet("color:#696969")
        self.lb4 = QLabel(
            "————————————————————————————————————————————————————————————————————",
            self)
        self.lb4.resize(615, 35)
        self.lb4.move(185, 630)
        self.lb4.setStyleSheet("color:#696969")
        self.lb4.setFont(QFont("微软雅黑", 13))

        # 选择路径按钮
        self.bt2 = QPushButton("选择", self)
        self.bt2.resize(60, 30)
        self.bt2.move(830, 623)
        self.bt2.setFont(QFont("微软雅黑", 9))
        self.bt2.setStyleSheet(
            "background:#7ccee3;color:white;border-radius:15px")
        self.bt2.clicked.connect(self.SelectPath)

        # 关于/帮助按钮
        self.bt4 = QPushButton('关于', self)
        self.bt4.resize(50, 20)
        self.bt4.move(450, 680)
        self.bt4.setFont(QFont('微软雅黑', 9))
        self.bt4.setStyleSheet(
            'background:transparent;color:blue;border-width:0')
        self.bt4.clicked.connect(AboutUs)
        self.bt5 = QPushButton('帮助', self)
        self.bt5.resize(50, 20)
        self.bt5.move(500, 680)
        self.bt5.setFont(QFont('微软雅黑', 9))
        self.bt5.setStyleSheet(
            'background:transparent;color:blue;border-width:0')
        self.bt5.clicked.connect(Help)

        # 初始化
        self.setPalette(palette)
        self.setGeometry(w, h, 974, 730)
        self.setFixedSize(974, 730)
        self.setWindowTitle('MusicDownloader V3.0')
        self.setWindowIcon(QIcon('ico.jpg'))
        self.setAutoFillBackground(True)
        self.text.setText("准备就绪")
        self.show()
        os.remove('bg.jpg')
        os.remove('ico.jpg')
        self.result = None
Example #25
0
class MyInfoGui(QWidget):
    closeSignal = pyqtSignal()  # 界面关闭的时候发出的信号
    setMyInfoSignal = pyqtSignal(dict)  # 修改个人信息请求信号

    def __init__(self, my_info=UserInfo(0), parent=None):
        super().__init__(parent)

        self.myInfo = my_info  # 自己的用户信息

        # 界面基本设置
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setAttribute(Qt.WA_QuitOnClose, False)

        # 设置标题
        self.setWindowTitle(self.tr("个人信息"))
        self.setFixedSize(743, 579)

        self.initUI()  # UI设置

        # 移动到屏幕中央
        self.resize(self.sizeHint())
        rect = self.frameGeometry()
        rect.moveCenter(QApplication.desktop().availableGeometry().center())
        self.move(rect.topLeft())

    def initUI(self):
        font = QFont("微软雅黑", 16, 20)

        # 控件
        self.lab=QLabel('背景图片',self)
        self.lab.setGeometry(0,0,1024,768)
        pixmap =QPixmap('image/background/register.jpg')
        self.lab.setPixmap(pixmap)

        nicknameLabel = QLabel(self)
        nicknameLabel.setGeometry(QRect(40, 20, 81, 31))
        nicknameLabel.setFont(font)
        nicknameLabel.setText(self.tr("昵称:"))

        self.nameLineEdit = QLineEdit(self)
        self.nameLineEdit.setValidator(
            QRegExpValidator(QRegExp(r"\S+"), self.nameLineEdit))
        self.nameLineEdit.setGeometry(QRect(120, 20, 220, 30))
        self.nameLineEdit.setFont(font)
        self.nameLineEdit.setText(self.myInfo.nick_name)
        self.nameLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        phoneLabel = QLabel(self)
        phoneLabel.setGeometry(QRect(20, 70, 81, 31))
        phoneLabel.setFont(font)
        phoneLabel.setText(self.tr("手机号:"))

        self.phoneLineEdit = QLineEdit(self)
        self.phoneLineEdit.setValidator(
            QRegExpValidator(QRegExp(r"[0-9]{7,11}"), self.phoneLineEdit))
        self.phoneLineEdit.setGeometry(QRect(120, 70, 220, 30))
        self.phoneLineEdit.setFont(font)
        self.phoneLineEdit.setText(self.myInfo.phone)
        self.phoneLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        mailLabel = QLabel(self)
        mailLabel.setGeometry(QRect(40, 120, 63, 22))
        mailLabel.setFont(font)
        mailLabel.setText(self.tr("邮箱:"))

        self.mailLineEdit = QLineEdit(self)
        self.mailLineEdit.setValidator(
            QRegExpValidator(QRegExp(r"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"), self.mailLineEdit))
        self.mailLineEdit.setGeometry(QRect(120, 120, 220, 30))
        self.mailLineEdit.setFont(font)
        self.mailLineEdit.setText(self.myInfo.mail)
        self.mailLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")


        signLabel = QLabel(self)
        signLabel.setGeometry(QRect(385, 10, 111, 51))
        signLabel.setFont(font)
        signLabel.setText(self.tr("个性签名:"))

        self.signTextEdit = QTextEdit(self)
        self.signTextEdit.setGeometry(QRect(390, 70, 321, 381))
        self.signTextEdit.setFont(font)
        self.signTextEdit.setText(self.myInfo.signature)
        self.signTextEdit.setStyleSheet("border:4px groove gray;border-radius:10px;padding:0px 0px")

        genderLabel = QLabel(self)
        genderLabel.setGeometry(QRect(40, 170, 63, 22))
        genderLabel.setFont(font)
        genderLabel.setText(self.tr("性别:"))

        self.manradioButton = QRadioButton(self)
        self.manradioButton.setGeometry(QRect(130, 170, 51, 28))
        # self.manradioButton.setCheckable(True)
        # self.manradioButton.setChecked(True)
        self.manradioButton.setFont(font)
        self.manradioButton.setText("男")

        self.femaleradioButton = QRadioButton(self)
        self.femaleradioButton.setGeometry(QRect(200, 170, 51, 28))
        self.femaleradioButton.setFont(font)
        self.femaleradioButton.setText("女")

        self.sradioButton = QRadioButton(self)
        self.sradioButton.setGeometry(QRect(270, 170, 70, 28))
        self.sradioButton.setFont(font)
        self.sradioButton.setText("保密")

        gender_id = self.myInfo.gender
        if gender_id == 1:
            self.manradioButton.setChecked(True)
        elif gender_id == 2:
            self.femaleradioButton.setChecked(True)
        elif gender_id == 3:
            self.sradioButton.setChecked(True)

        ageLabel = QLabel(self)
        ageLabel.setGeometry(QRect(40, 220, 63, 22))
        ageLabel.setFont(font)
        ageLabel.setText(self.tr("年龄:"))

        self.ageLineEdit = QLineEdit(self)
        self.ageLineEdit.setValidator(QRegExpValidator(QRegExp(r"\S+"), self.ageLineEdit))
        self.ageLineEdit.setGeometry(QRect(120, 220, 220, 30))
        self.ageLineEdit.setFont(font)
        self.ageLineEdit.setReadOnly(True)
        self.ageLineEdit.setText(str(self.myInfo.age))
        self.ageLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        birthLabel = QLabel(self)
        birthLabel.setGeometry(QRect(40, 260, 61, 41))
        birthLabel.setFont(font)
        birthLabel.setText(self.tr("生日:"))

        self.birthLineEdit = QLineEdit(self)
        self.birthLineEdit.setValidator(QRegExpValidator(QRegExp(r"^\d{4}-\d{1,2}-\d{1,2}"), self.birthLineEdit))
        self.birthLineEdit.setGeometry(QRect(120, 270, 220, 30))
        self.birthLineEdit.setFont(font)
        self.birthLineEdit.setText(self.myInfo.birthday)
        self.birthLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        vocationLabel = QLabel(self)
        vocationLabel.setGeometry(QRect(40, 320, 63, 22))
        vocationLabel.setFont(font)
        vocationLabel.setText(self.tr("职业:"))

        self.vocationLineEdit = QLineEdit(self)
        self.vocationLineEdit.setValidator(QRegExpValidator(QRegExp(r"\S+"), self.vocationLineEdit))
        self.vocationLineEdit.setGeometry(QRect(120, 320, 220, 30))
        self.vocationLineEdit.setFont(font)
        self.vocationLineEdit.setText(self.myInfo.vocation)
        self.vocationLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        cityLabel = QLabel(self)
        cityLabel.setGeometry(QRect(40, 370, 63, 22))
        cityLabel.setFont(font)
        cityLabel.setText(self.tr("城市:"))

        self.cityLineEdit = QLineEdit(self)
        self.cityLineEdit.setValidator(QRegExpValidator(QRegExp(r"\S+"), self.cityLineEdit))
        self.cityLineEdit.setGeometry(QRect(120, 370, 220, 30))
        self.cityLineEdit.setFont(font)
        self.cityLineEdit.setText("北京")
        self.cityLineEdit.setReadOnly(True)
        self.cityLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        timeLabel = QLabel(self)
        timeLabel.setGeometry(QRect(40, 420, 100, 22))
        timeLabel.setFont(font)
        timeLabel.setText(self.tr("注册时间:"))

        self.timeLineEdit = QLineEdit(self)
        self.timeLineEdit.setGeometry(QRect(160, 420, 180, 30))
        self.timeLineEdit.setFont(font)
        self.timeLineEdit.setReadOnly(True)
        self.timeLineEdit.setText(self.myInfo.register_time)
        self.timeLineEdit.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

        setButton = QPushButton(self)
        setButton.setText(self.tr("保存"))
        setButton.setGeometry(QRect(300, 500, 140, 40))
        setButton.setFont(font)
        setButton.clicked.connect(self.setButtonClicked)
        setButton.setStyleSheet("border:2px groove gray;border-radius:10px;padding:2px 4px")

    # 关闭界面的时候
    def closeEvent(self, QCloseEvent):
        self.closeSignal.emit()
        return super().closeEvent(QCloseEvent)

    # 单击保存按钮
    def setButtonClicked(self):
        my_info_dict = dict()
        my_info_dict['nick_name'] = self.nameLineEdit.text()
        my_info_dict['signature'] = self.signTextEdit.toPlainText()
        if self.manradioButton.isChecked():
            my_info_dict['gender_id'] = 1
        elif self.femaleradioButton.isChecked():
            my_info_dict['gender_id'] = 2
        elif self.sradioButton.isChecked():
            my_info_dict['gender_id'] = 3
        else:
            my_info_dict['gender_id'] = 3
        my_info_dict['birthday'] = self.birthLineEdit.text()
        my_info_dict['age'] = int(self.ageLineEdit.text())
        my_info_dict['telephone'] = self.phoneLineEdit.text()
        my_info_dict['email'] = self.mailLineEdit.text()
        my_info_dict['vocation'] = self.vocationLineEdit.text()
        self.setMyInfoSignal.emit(my_info_dict)

    # 返回修改是否成功
    def updateMyInfoStatusSlot(self, status):
        if status == '0':
            QMessageBox.information(self, self.tr("成功"), self.tr("保存成功!"))
            self.close()
        else:
            QMessageBox.critical(self, self.tr("失败"), self.tr("保存失败!请检查信息是否有误!"))
class MainWindow(QDialog):
    def __init__(self):
        super().__init__()

        #setting the main window in the class constructor
        self.title = "Memory Allocator"
        self.left = 500
        self.top = 200
        self.width = 350
        self.height = 250
        self.iconName = "E:/Marwan/projects/memory-allocator/ram.png"

        self.setWindowTitle(self.title)
        self.setWindowIcon(QtGui.QIcon(self.iconName))
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.createLayout()

        self.show()

    def createLayout(self):
        # vbox & grid to resize the window
        vbox = QVBoxLayout()
        grid = QGridLayout()

        maingroupbox = QGroupBox("Info")
        maingroupbox.setFont(QtGui.QFont("Sanserif", 14))

        # first group box for memory size
        groupbox1 = QGroupBox("Memory Size")
        groupbox1.setFont(QtGui.QFont("Sanserif", 14))
        groupbox1.setMinimumHeight(175)

        hbox1 = QHBoxLayout()

        # label used for user friendly purposes
        self.label1 = QLabel("Size of Memory : ")
        self.label1.setFont(QtGui.QFont("Sanserif", 12))
        hbox1.addWidget(self.label1)

        # line edit to take memory size from user
        self.lineEdit1 = QLineEdit(self)
        self.lineEdit1.setFont(QtGui.QFont("Sanserif", 12))
        self.lineEdit1.setMaximumWidth(100)
        hbox1.addWidget(self.lineEdit1)

        groupbox1.setLayout(hbox1)

        grid.addWidget(groupbox1, 0, 0)

        # 2nd group box for allocation type
        groupbox2 = QGroupBox("Memory Size")
        groupbox2.setFont(QtGui.QFont("Sanserif", 14))
        groupbox2.setMinimumHeight(175)

        hbox2 = QHBoxLayout()

        self.radiobtn1 = QRadioButton("First fit")
        self.radiobtn1.setFont((QtGui.QFont("Sanserif", 12)))
        hbox2.addWidget(self.radiobtn1)

        self.radiobtn2 = QRadioButton("Best fit")
        self.radiobtn2.setFont((QtGui.QFont("Sanserif", 12)))
        hbox2.addWidget(self.radiobtn2)

        groupbox2.setLayout(hbox2)

        grid.addWidget(groupbox2, 0, 1)

        # third group box for no of processes
        groupbox3 = QGroupBox("Processes")
        groupbox3.setFont(QtGui.QFont("Sanserif", 14))
        groupbox3.setMinimumHeight(175)

        hbox3 = QHBoxLayout()

        # label used for user friendly purposes
        self.label3 = QLabel("No. of processes :")
        self.label3.setFont(QtGui.QFont("Sanserif", 12))
        hbox3.addWidget(self.label3)

        # spin box to determine no of processes
        self.spinBox3 = QSpinBox()
        self.spinBox3.setFont(QtGui.QFont("Sanserif", 10))
        self.spinBox3.setMaximumWidth(100)
        hbox3.addWidget(self.spinBox3)

        groupbox3.setLayout(hbox3)

        grid.addWidget(groupbox3, 1, 0)

        # fourth group box for no of holes
        groupbox4 = QGroupBox("Holes")
        groupbox4.setFont(QtGui.QFont("Sanserif", 14))
        groupbox4.setMinimumHeight(175)

        hbox4 = QHBoxLayout()

        # label used for user friendly purposes
        self.label4 = QLabel("No. of holes :")
        self.label4.setFont(QtGui.QFont("Sanserif", 12))
        hbox4.addWidget(self.label4)

        # spin box to determine no of holes
        self.spinBox4 = QSpinBox()
        self.spinBox4.setFont(QtGui.QFont("Sanserif", 10))
        self.spinBox4.setMaximumWidth(100)
        hbox4.addWidget(self.spinBox4)

        groupbox4.setLayout(hbox4)

        grid.addWidget(groupbox4, 1, 1)

        # a push button to switch to 2nd menu
        self.button = QPushButton("Next", self)
        self.button.setFont(QtGui.QFont("Sanserif", 12))
        self.button.setToolTip("Proceed to next step")
        self.button.setMaximumWidth(300)
        self.button.setMinimumWidth(150)
        self.button.clicked.connect(self.onButtonPressed)

        maingroupbox.setLayout(grid)

        vbox.addWidget(maingroupbox)
        vbox.addWidget(self.button, 0, QtCore.Qt.AlignCenter)

        self.setLayout(vbox)

    # function that calls 2nd window to take more info about holes and processes
    # when the button is pressed
    # and fetches inputs
    def onButtonPressed(self):
        self.memorySize = self.lineEdit1.text()
        if self.radiobtn1.isChecked():
            self.allocatingType = "FF"
        elif self.radiobtn2.isChecked():
            self.allocatingType = "BF"
        self.noOfProcesses = self.spinBox3.value()
        self.noOfHoles = self.spinBox4.value()

        self.hide()
        self.secondwindow = SecondWindow(self.memorySize, self.allocatingType,
                                         self.noOfProcesses, self.noOfHoles)
Example #27
0
class SimulateTrader(QDialog):
    def __init__(self, **kwargs):
        super(SimulateTrader, self).__init__()
        self.host = kwargs.get("host", "0.0.0.0")
        self.port = kwargs.get("port", 0)
        self.user = kwargs.get("user", "user")
        self.passwd = kwargs.get("passwd", "123456")
        self.db_clearx = "clearx"
        self.db_financial = "financial"
        self.charset = "utf8"
        self.tb_security_info = "security_info"
        self.tb_pre_quote_stk = "pre_quote_stk"
        self.tb_account_trade = "account_trade"

        self.security = {}
        self.quote_data = {}
        self.stock_list = []
        self.trans_id = 0
        self.account_id = "test_account"

        self.dbm_clearx = dbm_mysql.DBM_MySQL(
            host=self.host,
            port=self.port,
            user=self.user,
            passwd=self.passwd,
            db=self.db_clearx,
            charset=self.charset)  # db_clearx
        self.dbm_financial = dbm_mysql.DBM_MySQL(
            host=self.host,
            port=self.port,
            user=self.user,
            passwd=self.passwd,
            db=self.db_financial,
            charset=self.charset)  # db_financial

        if self.dbm_clearx.Connect() == True and self.dbm_financial.Connect(
        ) == True:
            print("数据库连接成功。")
            self.GetSecurityInfo()
        else:
            print("数据库连接失败!")

        self.InitUserInterface()

        self.MakeSimulateTrade()  #

    def __del__(self):
        pass

    def InitUserInterface(self):
        self.color_red = QPalette()
        self.color_red.setColor(QPalette.WindowText, Qt.red)
        self.color_green = QPalette()
        self.color_green.setColor(QPalette.WindowText, QColor(0, 128, 0))
        self.color_black = QPalette()
        self.color_black.setColor(QPalette.WindowText, Qt.black)

        self.list_exchange = [
            define.DEF_EXCHANGE_STOCK_SH, define.DEF_EXCHANGE_STOCK_SZ
        ]
        self.list_entr_type = [
            define.DEF_PRICE_TYPE_STOCK_LIMIT,
            define.DEF_PRICE_TYPE_STOCK_MARKET
        ]

        self.setWindowTitle("模拟交易面板")
        self.resize(244, 201)
        self.setFont(QFont("SimSun", 9))

        self.label_exchange = QLabel("交易市场")
        self.label_exchange.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.label_symbol = QLabel("证券代码")
        self.label_symbol.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.label_name = QLabel("证券名称")
        self.label_name.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.label_entr_type = QLabel("委托方式")
        self.label_entr_type.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.label_price = QLabel("委托价格")
        self.label_price.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.label_volume = QLabel("委托数量")
        self.label_volume.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)

        self.label_price_unit = QLabel("元")
        self.label_price_unit.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.label_volume_unit = QLabel("股")
        self.label_volume_unit.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)

        self.combo_box_exchange = QComboBox()
        self.combo_box_exchange.addItems(self.list_exchange)
        self.line_edit_symbol = QLineEdit("")
        self.line_edit_symbol.setStyleSheet("color:red")  # 初始红色
        self.line_edit_symbol.setFont(QFont("SimSun", 9))
        self.line_edit_name = QLineEdit("")
        self.line_edit_name.setReadOnly(True)
        self.line_edit_name.setFont(QFont("SimSun", 9))
        self.line_edit_name.setStyleSheet(
            "background-color:rgb(240,240,240);color:red")  # 初始红色
        self.line_edit_name.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.combo_box_entr_type = QComboBox()
        self.combo_box_entr_type.addItems(self.list_entr_type)
        self.spin_box_price = QDoubleSpinBox()
        self.spin_box_price.setDecimals(4)
        self.spin_box_price.setMinimum(0)
        self.spin_box_price.setMaximum(100000)
        self.spin_box_price.setStyleSheet("color:red")  # 初始红色
        self.spin_box_price.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.spin_box_volume = QSpinBox()
        self.spin_box_volume.setMinimum(0)
        self.spin_box_volume.setMaximum(1000000)
        self.spin_box_volume.setSingleStep(100)
        self.spin_box_volume.setStyleSheet("color:red")  # 初始红色
        self.spin_box_volume.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        self.grid_layout_essential = QGridLayout()
        self.grid_layout_essential.setContentsMargins(-1, -1, -1, -1)
        self.grid_layout_essential.addWidget(self.label_exchange, 0, 0, 1, 1)
        self.grid_layout_essential.addWidget(self.label_symbol, 1, 0, 1, 1)
        self.grid_layout_essential.addWidget(self.label_name, 2, 0, 1, 1)
        self.grid_layout_essential.addWidget(self.label_entr_type, 3, 0, 1, 1)
        self.grid_layout_essential.addWidget(self.label_price, 4, 0, 1, 1)
        self.grid_layout_essential.addWidget(self.label_volume, 5, 0, 1, 1)
        self.grid_layout_essential.addWidget(self.combo_box_exchange, 0, 1, 1,
                                             1)
        self.grid_layout_essential.addWidget(self.line_edit_symbol, 1, 1, 1, 1)
        self.grid_layout_essential.addWidget(self.line_edit_name, 2, 1, 1, 1)
        self.grid_layout_essential.addWidget(self.combo_box_entr_type, 3, 1, 1,
                                             1)
        self.grid_layout_essential.addWidget(self.spin_box_price, 4, 1, 1, 1)
        self.grid_layout_essential.addWidget(self.spin_box_volume, 5, 1, 1, 1)
        self.grid_layout_essential.addWidget(self.label_price_unit, 4, 2, 1, 1)
        self.grid_layout_essential.addWidget(self.label_volume_unit, 5, 2, 1,
                                             1)

        self.radio_button_buy = QRadioButton("买 入")
        self.radio_button_buy.setStyleSheet("color:red")
        self.radio_button_buy.setFont(QFont("SimSun", 9))
        self.radio_button_buy.setChecked(True)
        self.radio_button_buy.setFixedWidth(70)
        self.radio_button_sell = QRadioButton("卖 出")
        self.radio_button_sell.setStyleSheet("color:green")
        self.radio_button_sell.setFont(QFont("SimSun", 9))
        self.radio_button_sell.setFixedWidth(70)
        self.button_place_order = QPushButton("下 单")
        self.button_place_order.setFont(QFont("SimSun", 9))
        self.button_place_order.setStyleSheet("font:bold;color:red")  # 初始红色
        self.button_place_order.setFixedWidth(70)

        self.h_box_layout_order_buttons = QHBoxLayout()
        self.h_box_layout_order_buttons.setContentsMargins(-1, -1, -1, -1)
        self.h_box_layout_order_buttons.addStretch(1)
        self.h_box_layout_order_buttons.addWidget(self.radio_button_buy)
        self.h_box_layout_order_buttons.addStretch(1)
        self.h_box_layout_order_buttons.addWidget(self.radio_button_sell)
        self.h_box_layout_order_buttons.addStretch(1)
        self.h_box_layout_order_buttons.addWidget(self.button_place_order)
        self.h_box_layout_order_buttons.addStretch(1)

        self.v_box_layout_order = QVBoxLayout()
        self.v_box_layout_order.setContentsMargins(-1, -1, -1, -1)
        self.v_box_layout_order.addLayout(self.grid_layout_essential)
        self.v_box_layout_order.addLayout(self.h_box_layout_order_buttons)

        self.setLayout(self.v_box_layout_order)

        self.button_place_order.clicked.connect(self.OnButtonPlaceOrder)

    def MakeSimulateTrade(self):
        stock_count = len(self.stock_list)
        if stock_count > 0:
            min_index = 0
            max_index = len(self.stock_list)
            random.seed()
            stock_index = random.randint(min_index, max_index)
            stock = self.stock_list[stock_index]
            print(stock.ToString())
            self.line_edit_symbol.setText(stock.code)
            self.line_edit_name.setText(stock.name)
            if stock.market == "SH":
                self.combo_box_exchange.setCurrentIndex(0)
            elif stock.market == "SZ":
                self.combo_box_exchange.setCurrentIndex(1)
            self.spin_box_price.setValue(stock.close)
            volume = random.randint(1, 99) * 100
            self.spin_box_volume.setValue(volume)
            self.combo_box_entr_type.setCurrentIndex(0)
            exch_side = random.randint(1, 2)
            if exch_side == 1:
                self.radio_button_buy.setChecked(True)
                self.radio_button_sell.setChecked(False)
            elif exch_side == 2:
                self.radio_button_buy.setChecked(False)
                self.radio_button_sell.setChecked(True)
            self.OnChangeBuySell(exch_side)
        else:
            print("证券列表为空!")

    def OnChangeBuySell(self, exch_side):
        if exch_side == 1:  # buy
            self.line_edit_symbol.setStyleSheet("color:red")
            self.line_edit_name.setStyleSheet(
                "background-color:rgb(240,240,240);color:red")
            self.spin_box_price.setStyleSheet("color:red")
            self.spin_box_volume.setStyleSheet("color:red")
            self.button_place_order.setStyleSheet("font:bold;color:red")
        if exch_side == 2:  # sell
            self.line_edit_symbol.setStyleSheet("color:green")
            self.line_edit_name.setStyleSheet(
                "background-color:rgb(240,240,240);color:green")
            self.spin_box_price.setStyleSheet("color:green")
            self.spin_box_volume.setStyleSheet("color:green")
            self.button_place_order.setStyleSheet("font:bold;color:green")

    def OnButtonPlaceOrder(self):
        code = self.line_edit_symbol.text()
        if code != "":
            market = "SH"
            if self.combo_box_exchange.currentIndex() == 1:
                market = "SZ"
            name = self.line_edit_name.text()
            exch_side = 1
            if self.radio_button_sell.isChecked():
                exch_side = 2
            volume = self.spin_box_volume.value()
            close = self.spin_box_price.value()
            print("委托:", market, code, name, exch_side, volume, close)
            if self.dbm_clearx.Connect() == True:
                self.trans_id += 1
                dbm = self.dbm_clearx
                sql = "INSERT INTO %s (trade_time, account_id, trans_id, market, symbol, name, direction, amount, price) VALUES ('%s', '%s', '%d', '%s', '%s', '%s', %d, %d, %f)" \
                      % (self.tb_account_trade, datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), self.account_id, self.trans_id, market, code, name, exch_side, volume, close)
                if dbm.ExecuteSql(sql) == True:
                    print("增加交易记录成功。")
                else:
                    print("增加交易记录失败!")
            else:
                print("数据库尚未连接!")
        else:
            print("模拟交易信息为空!")

        self.MakeSimulateTrade()  #

    def GetSecurityInfo(self):
        self.security = {}
        self.quote_data = {}
        self.stock_list = []

        dbm = self.dbm_financial
        sql = "SELECT inners, company, market, code, name, category, sector, is_st, list_state, list_date " + \
              "FROM %s WHERE category > 0 AND category < 5 AND list_state = 1 ORDER BY market ASC, code ASC" % self.tb_security_info
        result = dbm.QueryAllSql(sql)
        if result != None:
            rows = list(result)
            if len(rows) > 0:
                for (inners, company, market, code, name, category, sector,
                     is_st, list_state, list_date) in rows:
                    self.security[market + code] = Security(
                        inners=inners,
                        company=company,
                        market=market,
                        code=code,
                        name=name,
                        category=category,
                        sector=sector,
                        is_st=is_st,
                        list_state=list_state,
                        list_date=list_date)
                #for key, value in self.security.items():
                #    print(key, value.ToString())
            else:
                print("证券信息数据为空!")
        else:
            print("获取证券信息数据失败!")
        sql = "SELECT inners, market, code, name, category, open, high, low, close, pre_close, volume, turnover, trade_count, quote_date, quote_time " + \
              "FROM %s ORDER BY market ASC, code ASC" % self.tb_pre_quote_stk
        result = dbm.QueryAllSql(sql)
        if result != None:
            rows = list(result)
            if len(rows) > 0:
                for (inners, market, code, name, category, open, high, low,
                     close, pre_close, volume, turnover, trade_count,
                     quote_date, quote_time) in rows:
                    self.quote_data[market + code] = QuoteData(
                        inners=inners,
                        market=market,
                        code=code,
                        name=name,
                        category=category,
                        open=open,
                        high=high,
                        low=low,
                        close=close,
                        pre_close=pre_close,
                        volume=volume,
                        turnover=turnover,
                        trade_count=trade_count,
                        quote_date=quote_date,
                        quote_time=quote_time)
                #for key, value in self.quote_data.items():
                #    print(key, value.ToString())
            else:
                print("昨日行情数据为空!")
        else:
            print("获取昨日行情数据失败!")
        for key, value in self.security.items():
            if key in self.quote_data.keys():
                quote = self.quote_data[key]
                self.stock_list.append(
                    StockInfo(market=value.market,
                              code=value.code,
                              name=value.name,
                              close=quote.close))
Example #28
0
class MainWindow(QDialog):
    def __init__(self):
        super().__init__()

        self.title = "Fleet Study Automation Tool Home"
        self.left = 300
        self.top = 400
        self.width = 1000
        self.height = 350
        self.iconName = "images/corcentric_logo.jpg"

        # call init function
        self.InitWindow()

    def InitWindow(self):
        self.setWindowTitle(self.title)
        self.setWindowIcon(QtGui.QIcon(self.iconName))

        self.setGeometry(self.left, self.top, self.width, self.height)

        self.radioButton()

        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)

        # add start button
        self.button1 = QPushButton("Start Study")
        self.button1.setFont(QtGui.QFont("Calibri", 12))
        self.button1.clicked.connect(self.onStartStudy)

        vbox.addWidget(self.button1)

        self.label = QLabel(self)
        self.label.setFont(QtGui.QFont("Calibri", 12))
        vbox.addWidget(self.label)

        # add layout
        self.setLayout(vbox)
        self.show()

    def radioButton(self):
        self.groupBox = QGroupBox("Select a Fleet Study Category")
        self.groupBox.setFont(QtGui.QFont("Calibri", 16))

        hboxLayout = QHBoxLayout()

        # Create radio buttons
        # Create Utilization button
        self.radiobtn1 = QRadioButton("Utilization")
        # makes radio option the default checked
        # self.radiobtn1.setChecked(True)
        self.radiobtn1.setIcon(QtGui.QIcon("images/utilization_icon.png"))
        self.radiobtn1.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn1.setFont(QtGui.QFont("Calibri", 14))

        #connect radio button to method
        self.radiobtn1.toggled.connect(self.onRadioBtn)
        # add radio button to layout
        hboxLayout.addWidget(self.radiobtn1)

        # Create fuel economy button
        self.radiobtn2 = QRadioButton("Fuel Economy")
        self.radiobtn2.setIcon(QtGui.QIcon("images/fuel_icon.jpg"))
        # makes radio option the default checked
        # self.radiobtn2.setChecked(True)
        self.radiobtn2.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn2.setFont(QtGui.QFont("Calibri", 14))

        #connect radio button to method
        self.radiobtn2.toggled.connect(self.onRadioBtn)
        # add radio button to layout
        hboxLayout.addWidget(self.radiobtn2)

        # Create Maintenance and Repair Radio Button

        self.radiobtn3 = QRadioButton("Maintenance and Repair")
        # makes radio option the default checked
        # self.radiobtn3.setChecked(True)
        self.radiobtn3.setIcon(QtGui.QIcon("images/maintenance_icon.jpg"))
        self.radiobtn3.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn3.setFont(QtGui.QFont("Calibri", 14))

        #connect radio button to method
        self.radiobtn3.toggled.connect(self.onRadioBtn)
        # add radio button to layout
        hboxLayout.addWidget(self.radiobtn3)

        # Create RunCost radio button
        self.radiobtn4 = QRadioButton("Run Cost")
        # makes radio option the default checked
        # self.radiobtn4.setChecked(True)
        self.radiobtn4.setIcon(QtGui.QIcon("images/runcost_icon.png"))
        self.radiobtn4.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn4.setFont(QtGui.QFont("Calibri", 14))

        #connect radio button to method
        self.radiobtn4.toggled.connect(self.onRadioBtn)
        # add radio button to layout
        hboxLayout.addWidget(self.radiobtn4)

        # Create Special Projects Button
        self.radiobtn5 = QRadioButton("Special Projects")
        # makes radio option the default checked
        # self.radiobtn5.setChecked(True)
        self.radiobtn5.setIcon(QtGui.QIcon("images/special_projects_icon.png"))
        self.radiobtn5.setIconSize(QtCore.QSize(40, 40))
        self.radiobtn5.setFont(QtGui.QFont("Calibri", 14))

        #connect radio button to method
        self.radiobtn5.toggled.connect(self.onRadioBtn)
        # add radio button to layout
        hboxLayout.addWidget(self.radiobtn5)

        # add groupbox to layout
        self.groupBox.setLayout(hboxLayout)

    def onRadioBtn(self):
        radioBtn = self.sender()

        if radioBtn.isChecked():
            self.label.setText(radioBtn.text())

    # slot
    @pyqtSlot()
    def onStartStudy(self):
        if (self.label.text() == "Utilization"):
            self.label.setText("Start + Utilization button pressed")
            self.util_window = QtWidgets.QMainWindow()
            self.ui = HomeUtilizationUIClass()
            self.ui.setupUi(self.util_window)
            self.util_window.show()

        elif (self.label.text() == "Fuel Economy"):
            self.label.setText("Start + Fuel Economy button pressed")

        elif (self.label.text() == "Maintenance and Repair"):
            self.label.setText("Start + Maintenance and Repair button pressed")

        elif (self.label.text() == "Run Cost"):
            self.label.setText("Start + Run Cost button pressed")

        elif (self.label.text() == "Special Projects"):
            self.label.setText("Start + Special Projects button pressed")
            self.special_window = QtWidgets.QMainWindow()
            self.ui = SpecialProjectsClass()
            self.ui.setupUi(self.special_window)
            self.special_window.show()

        else:
            self.label.setText("Please make a selection to start study")
class Window(QWidget):
    def __init__(self):
        super().__init__()

        self.showMaximized()
        self.setWindowTitle('Barbequer')
        self.setWindowIcon(QIcon('BBQ.png'))
        self.init()

    def init(self):

        self.size_policy = (QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.font = QFont()
        self.font.setPointSize(16)

        self.temp_display_label = QLabel(self)
        self.temp_display_label.setText('Current Temperature:')
        self.temp_display_label.setSizePolicy(self.size_policy[0],
                                              self.size_policy[1])
        self.temp_display_label.setFont(self.font)
        #        self.temp_display_label.setAlignment(Qt.AlignRight)

        self.temp_display = QLCDNumber(self)
        self.temp_display.setSizePolicy(self.size_policy[0],
                                        self.size_policy[1])
        self.temp_display.setFont(self.font)

        self.temp_set_label = QLabel(self)
        self.temp_set_label.setText('Set Temperature:')
        self.temp_set_label.setSizePolicy(self.size_policy[0],
                                          self.size_policy[1])
        self.temp_set_label.setFont(self.font)
        #        self.temp_set_label.setAlignment(Qt.AlignRight)

        self.temp_set = QLCDNumber(self)
        self.temp_set.setSizePolicy(self.size_policy[0], self.size_policy[1])
        self.temp_set.setFont(self.font)

        self.temp_dial = QDial(self)
        self.temp_dial.setSizePolicy(self.size_policy[0], self.size_policy[1])
        self.temp_dial.setProperty('value', 0)
        self.temp_dial.setSliderPosition(0)
        self.temp_dial.setNotchesVisible(True)
        self.temp_dial.setMaximum(600)
        self.temp_dial.setToolTip('Set Desired Temperature in Fahrenheit')
        self.temp_dial.valueChanged.connect(self.update_temperature)

        self.exhasut_fan = QRadioButton('&Enable Exhaust Fan')
        self.exhasut_fan.setSizePolicy(self.size_policy[0],
                                       self.size_policy[1])
        self.exhasut_fan.setFont(self.font)
        self.exhasut_fan.setToolTip('Enable exhaust fan')

        self.intake_fan = QRadioButton('&Enable Intake Fan')
        self.intake_fan.setSizePolicy(self.size_policy[0], self.size_policy[1])
        self.intake_fan.setFont(self.font)
        self.intake_fan.setToolTip('Enable intake fan')

        self.start_button = QPushButton('Start', self)
        self.start_button.setSizePolicy(self.size_policy[0],
                                        self.size_policy[1])
        self.start_button.setFont(self.font)
        self.start_button.setToolTip('Start Maintaining Temperature')
        self.start_button.clicked.connect(self.maintain_temperature)

        self.timer_button = QPushButton('Timer', self)
        self.timer_button.setSizePolicy(self.size_policy[0],
                                        self.size_policy[1])
        self.timer_button.setFont(self.font)
        self.timer_button.setToolTip('Cook Time')

        qp = QPainter()
        qp.begin(self)
        qp.setPen(QPen(QColor(255, 80, 0), 3))
        qp.setBrush(QColor(255, 80, 0))
        qp.drawEllipse(QPoint(50, 60), 30, 30)
        qp.end()

        #add the grid layout to the interface
        self.layout = QGridLayout(self)
        self.layout.addWidget(self.temp_dial, 0, 0, 2, 2)
        self.layout.addWidget(self.temp_set_label, 2, 0)
        self.layout.addWidget(self.temp_set, 2, 1, 1, 2)
        self.layout.addWidget(self.temp_display_label, 3, 0)
        self.layout.addWidget(self.temp_display, 3, 1)
        self.layout.addWidget(self.exhasut_fan, 4, 0)
        self.layout.addWidget(self.intake_fan, 4, 1)
        self.layout.addWidget(self.start_button, 5, 0)
        self.layout.addWidget(self.timer_button, 5, 1)


#        self.layout.addWidget(qp,6,1)

    def update_temperature(self):
        self.temp_set.display(str(self.temp_dial.sliderPosition()))
        try:
            self.start_button.setEnabled(True)
            self.Temp.stop()
        except:
            '''do nothing here'''

    def maintain_temperature(self):
        self.Temp = temp_operation(self)
        self.start_button.setDisabled(True)
        self.Temp.isRunning = False
        time.sleep(1)
        if self.Temp.isRunning == False:
            self.Temp.isRunning = True
            self.Temp.set_temp = self.temp_dial.sliderPosition()
            self.Temp.display_update.connect(self.temp_display.display)
            self.Temp.start()
            print(self.Temp.isRunning)
Example #30
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(685, 443)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(20, 20, 400, 400))
        self.label.setText("")
        self.label.setObjectName("label")
        self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit.setGeometry(QtCore.QRect(560, 50, 91, 21))
        self.lineEdit.setObjectName("lineEdit")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(520, 50, 31, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(520, 90, 21, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_2.setGeometry(QtCore.QRect(560, 90, 91, 21))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_3.setGeometry(QtCore.QRect(560, 130, 91, 21))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(520, 130, 31, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(520, 170, 131, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.pushButton.setFont(font)
        self.pushButton.setObjectName("pushButton")
        self.radiobutton = QRadioButton(self.centralwidget)
        self.radiobutton.setChecked(True)
        self.radiobutton.setFont(font)

        self.radiobutton_2 = QRadioButton(self.centralwidget)
        self.radiobutton_2.setChecked(True)
        self.radiobutton_2.setFont(font)
        self.radiobutton_2.setGeometry(QtCore.QRect(90, 5, 140, 15))

        self.radiobutton_3 = QRadioButton(self.centralwidget)
        self.radiobutton_3.setChecked(True)
        self.radiobutton_3.setFont(font)
        self.radiobutton_3.setGeometry(QtCore.QRect(160, 5, 210, 16))

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 685, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_2.setText(_translate("MainWindow", "lon"))
        self.label_3.setText(_translate("MainWindow", "lat"))
        self.label_4.setText(_translate("MainWindow", "spn"))
        self.pushButton.setText(_translate("MainWindow", "Загрузить"))
        self.radiobutton.setText(_translate("MainWindow", "Спутник"))
        self.radiobutton_2.setText(_translate("MainWindow", "Схема"))
        self.radiobutton_3.setText(_translate("MainWindow", "Гибрид"))