def initUI(self): self.setWindowTitle("Process Bud") self.showMaximized() self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") self.centralwidget.setGeometry(QtCore.QRect(100, 10, 1000, 1000)) self.horizontalLayout_1 = QHBoxLayout(self) self.scrollArea = QScrollArea(self) self.scrollAreaWidgetContents = QWidget() self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 380, 280)) self.horizontalLayout_2 = QHBoxLayout(self.scrollAreaWidgetContents) self.gridLayout = QGridLayout() self.gridLayout.setSpacing(20) self.horizontalLayout_2.addLayout(self.gridLayout) self.verticalLayout_1 = QVBoxLayout() self.horizontalLayout_3 = QHBoxLayout() self.verticalLayout_1.addLayout(self.horizontalLayout_3) self.listWidget = QtWidgets.QListWidget(self.centralwidget) self.listWidget.setMinimumWidth(950) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.wnd = NodeEditorWnd() self.verticalLayout_1.addWidget(self.wnd) ''' Controls for Basic Operations ''' self.basictool_button = QToolButton(self.centralwidget) self.basictool_button.setText(" Basic Controls") self.basictool_button.setFixedWidth(150) self.basictool_button.setFixedHeight(30) self.basictool_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.click_button = QPushButton("Click") self.wait_button = QPushButton("Wait") self.type_button = QPushButton("Type") self.read_button = QPushButton("Read") self.url_button = QPushButton("Visit Url") ''' Controls for Email Operations ''' self.emailtool_button = QToolButton(self.centralwidget) self.emailtool_button.setText("Email") self.emailtool_button.setFixedWidth(150) self.emailtool_button.setFixedHeight(30) self.open_imap_session_button = QPushButton("Open session") self.fetch_email_button = QPushButton("Fetch Email") self.close_imap_session_button = QPushButton("Close session") self.send_email_button = QPushButton("Send Email") ''' # Controls for Application/Windows Operations # ''' # self.applicationtool_button = QToolButton(self.centralwidget) # self.applicationtool_button.setText("Application/Windows") # self.applicationtool_button.setFixedWidth(150) # self.applicationtool_button.setFixedHeight(30) # self.open_application_button = QPushButton("Open Application") # self.close_application_button = QPushButton("Close Application") # self.focus_application_button = QPushButton("Focus Application") # # ''' # Controls for Keyboard Operations # ''' # self.keyboardtool_button = QToolButton(self.centralwidget) # self.keyboardtool_button.setText("Keyboard Controls") # self.keyboardtool_button.setFixedWidth(150) # self.keyboardtool_button.setFixedHeight(30) # self.key_button = QPushButton("Send Hotkeys") self.run_application_button = QPushButton("Run Application") self.run_application_button.setFixedWidth(150) self.run_application_button.setFixedHeight(30) self.run_application_button.setGeometry(QtCore.QRect(450, 50, 75, 31)) self.run_application_button.clicked.connect(self.runappWindow) self.stop_application_button = QPushButton("STOP") self.stop_application_button.setFixedWidth(150) self.stop_application_button.setFixedHeight(30) self.stop_application_button.setGeometry(QtCore.QRect(550, 50, 75, 31)) self.clear_button = QPushButton("CLEAR") self.clear_button.setFixedWidth(150) self.clear_button.setFixedHeight(30) self.clear_button.setGeometry(QtCore.QRect(650, 50, 75, 31)) self.about_button = QPushButton("ABOUT") self.about_button.setFixedWidth(150) self.about_button.setFixedHeight(30) self.about_button.setGeometry(QtCore.QRect(750, 50, 75, 31)) ''' Addition of Widget to corresponding Layouts ''' self.horizontalLayout_1.addWidget(self.scrollArea) self.horizontalLayout_1.addLayout(self.verticalLayout_1) self.horizontalLayout_3.addWidget(self.run_application_button) self.horizontalLayout_3.addWidget(self.stop_application_button) self.horizontalLayout_3.addWidget(self.clear_button) self.horizontalLayout_3.addWidget(self.about_button) self.horizontalLayout_3.addStretch() self.gridLayout.addWidget(self.basictool_button) self.gridLayout.addWidget(self.click_button) self.gridLayout.addWidget(self.wait_button) self.gridLayout.addWidget(self.type_button) self.gridLayout.addWidget(self.read_button) self.gridLayout.addWidget(self.url_button) self.gridLayout.addWidget(self.emailtool_button) self.gridLayout.addWidget(self.open_imap_session_button) self.gridLayout.addWidget(self.fetch_email_button) self.gridLayout.addWidget(self.close_imap_session_button) self.gridLayout.addWidget(self.send_email_button) # self.gridLayout.addWidget(self.applicationtool_button) # self.gridLayout.addWidget(self.open_application_button) # self.gridLayout.addWidget(self.close_application_button) # self.gridLayout.addWidget(self.focus_application_button) # self.gridLayout.addWidget(self.keyboardtool_button) # self.gridLayout.addWidget(self.key_button) self.click_button.clicked.connect(self.open_click_window) self.wait_button.clicked.connect(self.open_wait_window) self.type_button.clicked.connect(self.open_type_window) self.read_button.clicked.connect(self.read_text_window) self.url_button.clicked.connect(self.open_url_window) self.open_imap_session_button.clicked.connect(self.openimapWindow) self.close_imap_session_button.clicked.connect(self.closeimapWindow) self.send_email_button.clicked.connect(self.sendemailWindow) self.fetch_email_button.clicked.connect(self.fetchemailWindow) self.stop_application_button.clicked.connect(self.stopapp) self.clear_button.clicked.connect(self.clearscript) self.about_button.clicked.connect(self.aboutTool) self.setGeometry(10, 10, 1320, 700)
def __init__(self, parent=None): self.parent = parent self.window_type = "t" self.allow_closing = False super().__init__() self.setWindowTitle("Map-Spectrum Table") self.current_focused_table = None # マップエリア self.map_layout = my_w.ClickableLayout(parent=self) map_inside_widget = QWidget() map_inside_widget.setLayout(self.map_layout) map_inside_widget.setObjectName("map_inside_widget") map_inside_widget.setStyleSheet("QWidget#map_inside_widget{background-color: white}") map_scroll_area = QScrollArea() map_scroll_area.setWidgetResizable(True) map_scroll_area.setWidget(map_inside_widget) map_area_layout = QVBoxLayout() map_area_layout.setContentsMargins(0,0,0,0) map_area_layout.setSpacing(0) map_area_layout.addWidget(gf.QRichLabel("Added Hyperspectral Data", font=gf.boldFont)) map_area_layout.addWidget(map_scroll_area) # スペクトルエリア self.spectrum_layout = my_w.ClickableLayout(parent=self) spectrum_inside_widget = QWidget() spectrum_inside_widget.setLayout(self.spectrum_layout) spectrum_inside_widget.setObjectName("spectrum_inside_widget") spectrum_inside_widget.setStyleSheet("QWidget#spectrum_inside_widget{background-color: white}") spectrum_scroll_area = QScrollArea() spectrum_scroll_area.setWidgetResizable(True) spectrum_scroll_area.setWidget(spectrum_inside_widget) spectrum_area_layout = QVBoxLayout() spectrum_area_layout.setContentsMargins(0,0,0,0) spectrum_area_layout.setSpacing(0) spectrum_area_layout.addWidget(gf.QRichLabel("Added Spectrum Data", font=gf.boldFont)) spectrum_area_layout.addWidget(spectrum_scroll_area) # マップボタンエリア self.btn_m_remove = QPushButton("remove") self.btn_m_remove.setFixedWidth(100) self.btn_m_remove.setEnabled(False) self.btn_m_hide_show = QPushButton("hide/show") self.btn_m_hide_show.setFixedWidth(100) self.btn_m_hide_show.setEnabled(False) btnLayout_m = QHBoxLayout() btnLayout_m.setContentsMargins(0,0,0,0) btnLayout_m.addStretch(1) btnLayout_m.addWidget(self.btn_m_remove) btnLayout_m.addWidget(self.btn_m_hide_show) self.btn_name_list_m = ["remove", "hide_show"] # スペクトルボタンエリア self.btn_s_export = QPushButton("export") self.btn_s_export.setFixedWidth(100) self.btn_s_export.setEnabled(False) self.btn_s_remove = QPushButton("remove") self.btn_s_remove.setFixedWidth(100) self.btn_s_remove.setEnabled(False) self.btn_s_hide_show = QPushButton("hide/show") self.btn_s_hide_show.setFixedWidth(100) self.btn_s_hide_show.setEnabled(False) btnLayout_s = QHBoxLayout() btnLayout_s.setContentsMargins(0,0,0,0) btnLayout_s.addStretch(1) btnLayout_s.addWidget(self.btn_s_export) btnLayout_s.addWidget(self.btn_s_remove) btnLayout_s.addWidget(self.btn_s_hide_show) self.btn_name_list_s = ["export", "remove", "hide_show"] # レイアウト self.layout = QVBoxLayout() self.layout.addLayout(map_area_layout) self.layout.addLayout(btnLayout_m) self.layout.addLayout(spectrum_area_layout) self.layout.addLayout(btnLayout_s) # その他 self.setFocusPolicy(Qt.StrongFocus) self.setLayout(self.layout) # イベントコネクト self.btn_s_export.clicked.connect(self.btn_export_clicked_s) self.btn_s_remove.clicked.connect(self.btn_remove_clicked_s) self.btn_s_hide_show.clicked.connect(self.btn_hide_show_clicked_s) self.btn_m_remove.clicked.connect(self.btn_remove_clicked_m) self.btn_m_hide_show.clicked.connect(self.btn_hide_show_clicked_m) self.setFocusPolicy(Qt.StrongFocus)
def __init__(self, parent=None): super(ResultHandler, self).__init__() self.setWindowTitle('Dash results') self.control_label = QLabel() self.rendered_label = QLabel() self.diff_label = QLabel() self.mask_label = QLabel() self.new_mask_label = QLabel() self.scrollArea = QScrollArea() self.widget = QWidget() self.test_name_label = QLabel() grid = QGridLayout() grid.addWidget(self.test_name_label, 0, 0) grid.addWidget(QLabel('Control'), 1, 0) grid.addWidget(QLabel('Rendered'), 1, 1) grid.addWidget(QLabel('Difference'), 1, 2) grid.addWidget(self.control_label, 2, 0) grid.addWidget(self.rendered_label, 2, 1) grid.addWidget(self.diff_label, 2, 2) grid.addWidget(QLabel('Current Mask'), 3, 0) grid.addWidget(QLabel('New Mask'), 3, 1) grid.addWidget(self.mask_label, 4, 0) grid.addWidget(self.new_mask_label, 4, 1) self.widget.setLayout(grid) self.scrollArea.setWidget(self.widget) v_layout = QVBoxLayout() v_layout.addWidget(self.scrollArea, 1) next_image_button = QPushButton() next_image_button.setText('Skip') next_image_button.pressed.connect(self.load_next) self.overload_spin = QDoubleSpinBox() self.overload_spin.setMinimum(1) self.overload_spin.setMaximum(255) self.overload_spin.setValue(1) self.overload_spin.valueChanged.connect( lambda: save_mask_button.setEnabled(False)) preview_mask_button = QPushButton() preview_mask_button.setText('Preview New Mask') preview_mask_button.pressed.connect(self.preview_mask) preview_mask_button.pressed.connect( lambda: save_mask_button.setEnabled(True)) save_mask_button = QPushButton() save_mask_button.setText('Save New Mask') save_mask_button.pressed.connect(self.save_mask) button_layout = QHBoxLayout() button_layout.addWidget(next_image_button) button_layout.addWidget(QLabel('Mask diff multiplier:')) button_layout.addWidget(self.overload_spin) button_layout.addWidget(preview_mask_button) button_layout.addWidget(save_mask_button) button_layout.addStretch() v_layout.addLayout(button_layout) self.setLayout(v_layout)
def initUI(self): #start geometrie self.width = 1200 self.height = 800 self.desktop = QApplication.desktop() self.desktop_size = QRect() self.desktop_size = self.desktop.screenGeometry() self.logger = logging.getLogger() self.logger.setLevel(self.log_level) self.log_date = datetime.datetime.now() log_date_str = self.log_date.strftime('%Y_%m_%d') month = self.log_date.strftime('%b') year = self.log_date.strftime('%Y') home_dict = str(Path.home()) file_path = '{}/Pythonic_{}/{}/log_{}.txt'.format(home_dict, year, month, log_date_str) self.ensure_file_path(file_path) file_handler = logging.FileHandler(file_path) file_handler.setLevel(self.log_level) file_handler.setFormatter(self.formatter) self.logger.addHandler(file_handler) # init language ! self.translator = QTranslator(self.app) #self.translator.load('translations/spanish_es') self.translator.load('translations/english_en.qm') self.app.installTranslator(self.translator) #QC.installTranslator(self.translator) logging.debug('Translation: {}'.format(QC.translate('', 'Save'))) # setup the default language here #self.changeTranslator('german_de.qm') self.x_position = self.desktop_size.width() / 2 - self.width / 2 self.y_position = self.desktop_size.height() / 2 - self.height / 2 self.setAcceptDrops(True) self.layout_v = QVBoxLayout() # main_layout contains the workingarea and the toolbox self.main_layout = QVBoxLayout() self.main_layout.setSpacing(0) self.main_layout.setContentsMargins(0, 0, 0, 0) self.bottom_border_layout = QHBoxLayout() self.bottom_border_layout.setSpacing(0) self.setContentsMargins(0, 0, 0, 0) # create class objects #self.exceptwindow = ExceptWindow(self) self.wrk_area_arr = [] self.wrk_tabs_arr = [] self.grd_ops_arr = [] self.working_tabs = QTabWidget() self.working_tabs.setMinimumSize(300, 300) for i in range(5): self.wrk_area_arr.append(WorkingArea()) self.wrk_tabs_arr.append(QScrollArea()) self.wrk_tabs_arr[i].setWidget(self.wrk_area_arr[i]) self.wrk_tabs_arr[i].setWidgetResizable(True) #self.working_tabs.addTab(self.wrk_area_arr[i], QC.translate('', 'Grid {}'.format(i))) self.working_tabs.addTab(self.wrk_tabs_arr[i], QC.translate('', 'Grid {}'.format(i + 1))) self.grd_ops_arr.append(GridOperator(self.wrk_area_arr[i].grid)) # init reference for the current grid which is in focus self.focus_grid = self.wrk_area_arr[0] self.wrk_tab_index = 0 #self.working_area = WorkingArea() self.storagebar = StorageBar(self) self.menubar = MenuBar() self.toolbox_tab = QTabWidget() self.toolbox_tab.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) self.topMenuBar = topMenuBar() self.settings = Settings() self.infoWindow = InfoWindow() #self.gridoperator = GridOperator(self) self.toolbox_basics = BasicTools(self) self.toolbox_binance = BinanceTools(self) self.toolbox_connectivity = ConnectivityTools(self) # add Tabs to the toolbox self.toolbox_tab.addTab(self.toolbox_basics, QC.translate('', 'Basic')) self.toolbox_tab.addTab(self.toolbox_binance, QC.translate('', 'Binance')) self.toolbox_tab.addTab(self.toolbox_connectivity, QC.translate('', 'Connectivity')) # signals and slots #self.menubar.save_file.connect(self.working_area.saveGrid) #self.menubar.load_file.connect(self.working_area.loadGrid) self.menubar.set_info_text.connect(self.setInfoText) self.menubar.start_debug.connect(self.startDebug) self.menubar.start_exec.connect(self.startExec) #self.menubar.clear_grid.connect(self.working_area.setupDefault) #self.menubar.stop_exec.connect(self.gridoperator.stop_execution) #self.menubar.kill_proc.connect(self.gridoperator.kill_proc) #self.menubar.kill_proc.connect(self.working_area.allStop) #self.gridoperator.update_logger.connect(self.update_logfile) self.topMenuBar.switch_language.connect(self.changeTranslator) self.topMenuBar.close_signal.connect(self.closeEvent) self.topMenuBar.open_action.triggered.connect(self.menubar.openFileNameDialog) self.topMenuBar.save_action.triggered.connect(self.menubar.simpleSave) self.topMenuBar.save_as_action.triggered.connect(self.menubar.saveFileDialog) self.topMenuBar.new_action.triggered.connect(self.menubar.saveQuestion) self.topMenuBar.settings_action.triggered.connect(self.settings.show) self.topMenuBar.info_action.triggered.connect(self.showInfo) self.working_tabs.currentChanged.connect(self.wrkIndexChanged) #self.toolbox_binance.reg_tool.connect(self.working_area.regType) #self.toolbox_connectivity.reg_tool.connect(self.working_area.regType) #self.toolbox_basics.reg_tool.connect(self.working_area.regType) #self.storagebar.forward_config.connect(self.working_area.receiveConfig) #self.working_area.finish_dropbox.connect(self.storagebar.finishDropBox) self.menubar.stop_exec.connect(self.stopExecution) self.menubar.kill_proc.connect(self.killProcesses) self.menubar.load_file.connect(self.loadGrid) self.menubar.save_file.connect(self.saveGrid) self.menubar.clear_grid.connect(self.setupDefault) for i in range(5): self.toolbox_binance.reg_tool.connect(self.wrk_area_arr[i].regType) self.toolbox_connectivity.reg_tool.connect(self.wrk_area_arr[i].regType) self.toolbox_basics.reg_tool.connect(self.wrk_area_arr[i].regType) # hier auch noch anpassen self.storagebar.forward_config.connect(self.wrk_area_arr[i].receiveConfig) self.wrk_area_arr[i].finish_dropbox.connect(self.storagebar.finishDropBox) self.grd_ops_arr[i].update_logger.connect(self.update_logfile) self.grd_ops_arr[i].switch_grid.connect(self.receiveTarget) self.wrk_area_arr[i].query_grid_config_wrk.connect(self.queryGridConfiguration) # register tools self.toolbox_binance.register_tools() self.toolbox_basics.register_tools() self.toolbox_connectivity.register_tools() self.image_folder = QDir('images') if not self.image_folder.exists(): logging.error('Image foulder not found') sys.exit(0) self.scrollArea = QScrollArea() #self.scrollArea.setWidget(self.working_area) self.scrollArea.setWidget(self.working_tabs) self.scrollArea.setWidgetResizable(True) self.scrollArea.setMinimumSize(300, 300) self.scroll_dropBox = QScrollArea() self.scroll_dropBox.setWidget(self.storagebar) self.scroll_dropBox.setWidgetResizable(True) self.scroll_dropBox.setMaximumWidth(270) self.bottom_area = QWidget() self.bottom_area_layout = QHBoxLayout(self.bottom_area) self.bottom_area_layout.addWidget(self.scrollArea) self.bottom_area_layout.addWidget(self.scroll_dropBox) self.layout_v.addWidget(self.topMenuBar) self.layout_v.addWidget(self.menubar) self.layout_v.addWidget(self.toolbox_tab) self.layout_v.addWidget(self.bottom_area) self.main_widget = QWidget() self.main_widget.setLayout(self.layout_v) # add main widget to main layout self.main_layout.addWidget(self.main_widget, 0) self.main_layout.setSpacing(0) # resize button self.sizeGrip = QSizeGrip(self.main_widget) # bottom info text self.infoText = QLabel() self.infoText.setText('') # define the bottom border line self.bottom_border_layout.addWidget(self.infoText) self.bottom_border_layout.setSpacing(0) # left, top, right, bottom self.bottom_border_layout.setContentsMargins(5, 0, 5, 5) self.bottom_border_layout.addWidget(self.sizeGrip, 0, Qt.AlignRight) self.bottom_border = QWidget() self.bottom_border.setLayout(self.bottom_border_layout) self.main_layout.addWidget(self.bottom_border) self.setLayout(self.main_layout) self.setGeometry(self.x_position, self.y_position, self.width, self.height)
def drawLive(self): self.groupbox9 = QGroupBox("Adding Process") self.groupbox9.setFont(QtGui.QFont("sanserif", 15)) self.grid = QVBoxLayout() self.grid.setSpacing(-10) if self.firstfit.isChecked(): for i in self.proccess: if i.finished == 0: lists = i.organizeProcess(self.SortedHoles, self.SortedDrawingList, self.failedProcess) self.SortedHoles = lists[0] self.SortedDrawingList = sorted( lists[1], key=itemgetter('startaddress'), reverse=False) if lists[2] == 1: self.failedProcess.append(i) noofHoles = len(self.SortedHoles) while noofHoles > 0: for i in range(len(self.SortedDrawingList)): if self.SortedDrawingList[i]['hole'] == 1: self.SortedDrawingList.pop(i) noofHoles = noofHoles - 1 break for i in self.SortedHoles: self.SortedDrawingList = sorted(i.organizeHole( self.SortedDrawingList), key=itemgetter('startaddress'), reverse=False) while len(self.failedProcess) > 0: buttonReply = QMessageBox.question( self, "System", self.failedProcess[0].name + " hasn't found a place in memory", QMessageBox.Ok) list = self.failedProcess[0].removeProcess( self.SortedDrawingList) self.SortedDrawingList = list[0] self.SortedHoles = list[1] self.failedProcess.pop(0) elif self.bestfit.isChecked(): smallestHoles = sorted(self.SortedHoles, key=lambda x: x.size, reverse=False) for i in self.proccess: if i.finished == 0: lists = i.organizeProcess(smallestHoles, self.SortedDrawingList, self.failedProcess) smallestHoles = sorted(lists[0], key=lambda x: x.size, reverse=False) self.SortedDrawingList = sorted( lists[1], key=itemgetter('startaddress'), reverse=False) if lists[2] == 1: self.failedProcess.append(i) noofHoles = len(smallestHoles) while noofHoles > 0: for i in range(len(self.SortedDrawingList)): if self.SortedDrawingList[i]['hole'] == 1: self.SortedDrawingList.pop(i) noofHoles = noofHoles - 1 break for i in smallestHoles: self.SortedDrawingList = sorted(i.organizeHole( self.SortedDrawingList), key=itemgetter('startaddress'), reverse=False) while len(self.failedProcess) > 0: buttonReply = QMessageBox.question( self, "System", self.failedProcess[0].name + " hasn't found a place in memory", QMessageBox.Ok) list = self.failedProcess[0].removeProcess( self.SortedDrawingList) self.SortedDrawingList = list[0] self.SortedHoles = list[1] self.failedProcess.pop(0) else: largestHoles = sorted(self.SortedHoles, key=lambda x: x.size, reverse=True) for i in self.proccess: if i.finished == 0: lists = i.organizeProcess(largestHoles, self.SortedDrawingList, self.failedProcess) largestHoles = sorted(lists[0], key=lambda x: x.size, reverse=True) self.SortedDrawingList = sorted( lists[1], key=itemgetter('startaddress'), reverse=False) if lists[2] == 1: self.failedProcess.append(i) noofHoles = len(largestHoles) while noofHoles > 0: for i in range(len(self.SortedDrawingList)): if self.SortedDrawingList[i]['hole'] == 1: self.SortedDrawingList.pop(i) noofHoles = noofHoles - 1 break for i in largestHoles: self.SortedDrawingList = sorted(i.organizeHole( self.SortedDrawingList), key=itemgetter('startaddress'), reverse=False) while len(self.failedProcess) > 0: buttonReply = QMessageBox.question( self, "System", self.failedProcess[0].name + " hasn't found a place in memory", QMessageBox.Ok) list = self.failedProcess[0].removeProcess( self.SortedDrawingList) self.SortedDrawingList = list[0] self.SortedHoles = list[1] self.failedProcess.pop(0) self.Draww() self.scroll2.hide() self.count2 = self.count2 + 1 if self.count > 0: self.scroll3.hide() if self.count2 != 1: self.scroll4.hide() self.groupbox9.setLayout(self.grid) self.scroll4 = QScrollArea(self) self.scroll4.setWidget(self.groupbox9) self.scroll4.setWidgetResizable(True) self.scroll4.setFixedWidth(400) self.scroll4.setFixedHeight(700) self.hbox.addWidget(self.scroll4)
def __handle_image(self): self.frames[0]["image_selector"] = QDialog() self.objects[0]["image_selector"] = {} self.frames[0]["image_selector"].setWindowTitle("Image selector") self.layouts[0]["image_selector"] = QVBoxLayout() self.objects[0]["image_selector"]["tabs"] = QTabWidget() self.frames[0]["image_selector_select"] = QFrame() self.frames[0]["image_selector_add"] = QFrame() self.__initialize_image_selector_add() self.objects[0]["image_selector"]["tabs"].addTab( self.frames[0]["image_selector_select"], "Select") self.objects[0]["image_selector"]["tabs"].addTab( self.frames[0]["image_selector_add"], "Add new") self.layouts[0]["image_selector"].addWidget( self.objects[0]["image_selector"]["tabs"]) columns = (self.__active_width-800) // 250 self.layouts[0]["image_selector_select"] = QVBoxLayout() self.objects[0]["image_selector"]["title_label"] = QLabel( '<h1>All images</h1>') self.layouts[0]["image_selector_select"].addWidget( self.objects[0]["image_selector"]["title_label"]) images = self.image_service.get("author", self.user[0]) imgs_in_row = 0 current_row = 1 self.objects[0]["image_selector"]["img_grid"] = {} self.layouts[0]["image_selector_grid"] = {} self.frames[0]["image_selector_grid"] = QFrame() self.layouts[0]["image_selector_select_grid"] = QGridLayout() self.frames[0]["image_selector_grid"].setLayout( self.layouts[0]["image_selector_select_grid"]) for image in images: self.layouts[0]["image_selector_grid"][image.id] = QVBoxLayout() self.objects[0]["image_selector"]["img_grid"][image.id] = {} self.objects[0]["image_selector"]["img_grid"][image.id]["image_label"] = QLabel( ) self.objects[0]["image_selector"]["img_grid"][image.id]["name_label"] = QLabel( 'Name: '+image.name) self.objects[0]["image_selector"]["img_grid"][image.id]["name_edit"] = QLineEdit( ) self.objects[0]["image_selector"]["img_grid"][image.id]["width_label"] = QLabel( 'Width: '+str(image.width)) self.objects[0]["image_selector"]["img_grid"][image.id]["width_edit"] = QLineEdit( ) self.objects[0]["image_selector"]["img_grid"][image.id]["save_button"] = QPushButton( 'Save') self.objects[0]["image_selector"]["img_grid"][image.id]["select_button"] = QPushButton( 'Select') self.objects[0]["image_selector"]["img_grid"][image.id]["edit_button"] = QPushButton( 'Edit') self.objects[0]["image_selector"]["img_grid"][image.id]["remove_button"] = QPushButton( 'Remove') self.objects[0]["image_selector"]["img_grid"][image.id]["image_label"].setText( '<img src="data:image/'+image.filetype+';base64,' + image.image+'" width="250" alt="" />' ) self.objects[0]["image_selector"]["img_grid"][image.id]["name_edit"].setText( image.name) self.objects[0]["image_selector"]["img_grid"][image.id]["width_edit"].setText( str(image.width)) self.objects[0]["image_selector"]["img_grid"][image.id]["select_button"].clicked.connect( partial(self.__add_image, image.id)) self.objects[0]["image_selector"]["img_grid"][image.id]["edit_button"].clicked.connect( partial(self.__handle_edit_image, image.id)) self.objects[0]["image_selector"]["img_grid"][image.id]["remove_button"].clicked.connect( partial(self.__handle_remove_image, image.id)) self.objects[0]["image_selector"]["img_grid"][image.id]["save_button"].clicked.connect( partial(self.__handle_save_edit_image, image.id)) self.objects[0]["image_selector"]["img_grid"][image.id]["width_edit"].setValidator( QIntValidator(0, 7680, self)) self.layouts[0]["image_selector_grid"][image.id].addStretch() self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["image_label"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["name_label"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["name_edit"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["width_label"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["width_edit"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["save_button"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["remove_button"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["edit_button"]) self.layouts[0]["image_selector_grid"][image.id].addWidget( self.objects[0]["image_selector"]["img_grid"][image.id]["select_button"]) self.objects[0]["image_selector"]["img_grid"][image.id]["name_edit"].hide() self.objects[0]["image_selector"]["img_grid"][image.id]["width_edit"].hide() self.objects[0]["image_selector"]["img_grid"][image.id]["save_button"].hide() self.layouts[0]["image_selector_select_grid"].addLayout( self.layouts[0]["image_selector_grid"][image.id], current_row, imgs_in_row) imgs_in_row += 1 if imgs_in_row == columns: imgs_in_row = 0 current_row += 1 self.layouts[0]["image_selector_toolbar"] = QHBoxLayout() self.objects[0]["image_selector"]["close_button"] = QPushButton( 'Close') self.objects[0]["image_selector"]["close_button"].clicked.connect( self.__close_image_selector) self.layouts[0]["image_selector_toolbar"].addWidget( self.objects[0]["image_selector"]["close_button"]) self.objects[0]["image_selector"]["content_scroll"] = QScrollArea() self.objects[0]["image_selector"]["content_scroll"].setWidget( self.frames[0]["image_selector_grid"]) self.objects[0]["image_selector"]["content_scroll"].ensureWidgetVisible( self.frames[0]["image_selector_grid"]) self.objects[0]["image_selector"]["content_scroll"].ensureVisible( 0, 0, 0, 0) self.objects[0]["image_selector"]["content_scroll"].setWidgetResizable( True) self.objects[0]["image_selector"]["content_scroll"].setAlignment( Qt.AlignTop) self.objects[0]["image_selector"]["content_scroll"].setFixedSize( self.__active_width-500, self.__active_height-400) self.objects[0]["image_selector"]["content_scroll"].setStyleSheet( 'QScrollArea { border: 0px;}') self.layouts[0]["image_selector_select"].addWidget( self.objects[0]["image_selector"]["content_scroll"]) self.layouts[0]["image_selector_select"].addLayout( self.layouts[0]["image_selector_toolbar"]) self.frames[0]["image_selector_select"].setLayout( self.layouts[0]["image_selector_select"]) self.frames[0]["image_selector"].setLayout( self.layouts[0]["image_selector"]) self.frames[0]["image_selector"].exec_()
def __init__(self, theParent, theProject): QDialog.__init__(self, theParent) logger.debug("Initialising GuiBuildNovel ...") self.setObjectName("GuiBuildNovel") self.mainConf = nw.CONFIG self.theProject = theProject self.theParent = theParent self.theTheme = theParent.theTheme self.optState = self.theProject.optState self.htmlText = [] # List of html documents self.htmlStyle = [] # List of html styles self.htmlSize = 0 # Size of the html document self.buildTime = 0 # The timestamp of the last build self.setWindowTitle(self.tr("Build Novel Project")) self.setMinimumWidth(self.mainConf.pxInt(700)) self.setMinimumHeight(self.mainConf.pxInt(600)) self.resize( self.mainConf.pxInt( self.optState.getInt("GuiBuildNovel", "winWidth", 900)), self.mainConf.pxInt( self.optState.getInt("GuiBuildNovel", "winHeight", 800))) self.docView = GuiBuildNovelDocView(self, self.theProject) hS = self.theTheme.fontPixelSize wS = 2 * hS # Title Formats # ============= self.titleGroup = QGroupBox(self.tr("Title Formats for Novel Files"), self) self.titleForm = QGridLayout(self) self.titleGroup.setLayout(self.titleForm) fmtHelp = "<br>".join([ "<b>%s</b>" % self.tr("Formatting Codes:"), self.tr("{0} for the title as set in the document").format( r"%title%"), self.tr("{0} for chapter number (1, 2, 3)").format(r"%ch%"), self.tr("{0} for chapter number as a word (one, two)").format( r"%chw%"), self.tr("{0} for chapter number in upper case Roman").format( r"%chI%"), self.tr("{0} for chapter number in lower case Roman").format( r"%chi%"), self.tr("{0} for scene number within chapter").format(r"%sc%"), self.tr("{0} for scene number within novel").format(r"%sca%"), ]) fmtScHelp = "<br><br>%s" % self.tr( "Leave blank to skip this heading, or set to a static text, like " "for instance '{0}', to make a separator. The separator will " "be centred automatically and only appear between sections of " "the same type.").format("* * *") xFmt = self.mainConf.pxInt(100) self.fmtTitle = QLineEdit() self.fmtTitle.setMaxLength(200) self.fmtTitle.setMinimumWidth(xFmt) self.fmtTitle.setToolTip(fmtHelp) self.fmtTitle.setText( self._reFmtCodes(self.theProject.titleFormat["title"])) self.fmtChapter = QLineEdit() self.fmtChapter.setMaxLength(200) self.fmtChapter.setMinimumWidth(xFmt) self.fmtChapter.setToolTip(fmtHelp) self.fmtChapter.setText( self._reFmtCodes(self.theProject.titleFormat["chapter"])) self.fmtUnnumbered = QLineEdit() self.fmtUnnumbered.setMaxLength(200) self.fmtUnnumbered.setMinimumWidth(xFmt) self.fmtUnnumbered.setToolTip(fmtHelp) self.fmtUnnumbered.setText( self._reFmtCodes(self.theProject.titleFormat["unnumbered"])) self.fmtScene = QLineEdit() self.fmtScene.setMaxLength(200) self.fmtScene.setMinimumWidth(xFmt) self.fmtScene.setToolTip(fmtHelp + fmtScHelp) self.fmtScene.setText( self._reFmtCodes(self.theProject.titleFormat["scene"])) self.fmtSection = QLineEdit() self.fmtSection.setMaxLength(200) self.fmtSection.setMinimumWidth(xFmt) self.fmtSection.setToolTip(fmtHelp + fmtScHelp) self.fmtSection.setText( self._reFmtCodes(self.theProject.titleFormat["section"])) self.buildLang = QComboBox() self.buildLang.setMinimumWidth(xFmt) theLangs = self.mainConf.listLanguages(self.mainConf.LANG_PROJ) self.buildLang.addItem("[%s]" % self.tr("Not Set"), "None") for langID, langName in theLangs: self.buildLang.addItem(langName, langID) langIdx = self.buildLang.findData(self.theProject.projLang) if langIdx != -1: self.buildLang.setCurrentIndex(langIdx) # Dummy boxes due to QGridView and QLineEdit expand bug self.boxTitle = QHBoxLayout() self.boxTitle.addWidget(self.fmtTitle) self.boxChapter = QHBoxLayout() self.boxChapter.addWidget(self.fmtChapter) self.boxUnnumb = QHBoxLayout() self.boxUnnumb.addWidget(self.fmtUnnumbered) self.boxScene = QHBoxLayout() self.boxScene.addWidget(self.fmtScene) self.boxSection = QHBoxLayout() self.boxSection.addWidget(self.fmtSection) titleLabel = QLabel(self.tr("Title")) chapterLabel = QLabel(self.tr("Chapter")) unnumbLabel = QLabel(self.tr("Unnumbered")) sceneLabel = QLabel(self.tr("Scene")) sectionLabel = QLabel(self.tr("Section")) langLabel = QLabel(self.tr("Language")) self.titleForm.addWidget(titleLabel, 0, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxTitle, 0, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(chapterLabel, 1, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxChapter, 1, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(unnumbLabel, 2, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxUnnumb, 2, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(sceneLabel, 3, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxScene, 3, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(sectionLabel, 4, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxSection, 4, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(langLabel, 5, 0, 1, 1, Qt.AlignLeft) self.titleForm.addWidget(self.buildLang, 5, 1, 1, 1, Qt.AlignRight) self.titleForm.setColumnStretch(0, 0) self.titleForm.setColumnStretch(1, 1) # Font Options # ============ self.fontGroup = QGroupBox(self.tr("Font Options"), self) self.fontForm = QGridLayout(self) self.fontGroup.setLayout(self.fontForm) ## Font Family self.textFont = QLineEdit() self.textFont.setReadOnly(True) self.textFont.setMinimumWidth(xFmt) self.textFont.setText( self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth( int(2.5 * self.theTheme.getTextWidth("..."))) self.fontButton.clicked.connect(self._selectFont) self.textSize = QSpinBox(self) self.textSize.setFixedWidth(6 * self.theTheme.textNWidth) self.textSize.setMinimum(6) self.textSize.setMaximum(72) self.textSize.setSingleStep(1) self.textSize.setValue( self.optState.getInt("GuiBuildNovel", "textSize", self.mainConf.textSize)) self.lineHeight = QDoubleSpinBox(self) self.lineHeight.setFixedWidth(6 * self.theTheme.textNWidth) self.lineHeight.setMinimum(0.8) self.lineHeight.setMaximum(3.0) self.lineHeight.setSingleStep(0.05) self.lineHeight.setDecimals(2) self.lineHeight.setValue( self.optState.getFloat("GuiBuildNovel", "lineHeight", 1.15)) # Dummy box due to QGridView and QLineEdit expand bug self.boxFont = QHBoxLayout() self.boxFont.addWidget(self.textFont) fontFamilyLabel = QLabel(self.tr("Font family")) fontSizeLabel = QLabel(self.tr("Font size")) lineHeightLabel = QLabel(self.tr("Line height")) justifyLabel = QLabel(self.tr("Justify text")) stylingLabel = QLabel(self.tr("Disable styling")) self.fontForm.addWidget(fontFamilyLabel, 0, 0, 1, 1, Qt.AlignLeft) self.fontForm.addLayout(self.boxFont, 0, 1, 1, 1, Qt.AlignRight) self.fontForm.addWidget(self.fontButton, 0, 2, 1, 1, Qt.AlignRight) self.fontForm.addWidget(fontSizeLabel, 1, 0, 1, 1, Qt.AlignLeft) self.fontForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight) self.fontForm.addWidget(lineHeightLabel, 2, 0, 1, 1, Qt.AlignLeft) self.fontForm.addWidget(self.lineHeight, 2, 1, 1, 2, Qt.AlignRight) self.fontForm.setColumnStretch(0, 0) self.fontForm.setColumnStretch(1, 1) self.fontForm.setColumnStretch(2, 0) # Styling Options # =============== self.styleGroup = QGroupBox(self.tr("Styling Options"), self) self.styleForm = QGridLayout(self) self.styleGroup.setLayout(self.styleForm) self.justifyText = QSwitch(width=wS, height=hS) self.justifyText.setChecked( self.optState.getBool("GuiBuildNovel", "justifyText", False)) self.noStyling = QSwitch(width=wS, height=hS) self.noStyling.setChecked( self.optState.getBool("GuiBuildNovel", "noStyling", False)) self.styleForm.addWidget(justifyLabel, 1, 0, 1, 1, Qt.AlignLeft) self.styleForm.addWidget(self.justifyText, 1, 1, 1, 2, Qt.AlignRight) self.styleForm.addWidget(stylingLabel, 2, 0, 1, 1, Qt.AlignLeft) self.styleForm.addWidget(self.noStyling, 2, 1, 1, 2, Qt.AlignRight) self.styleForm.setColumnStretch(0, 0) self.styleForm.setColumnStretch(1, 1) # Include Options # =============== self.textGroup = QGroupBox(self.tr("Include Options"), self) self.textForm = QGridLayout(self) self.textGroup.setLayout(self.textForm) self.includeSynopsis = QSwitch(width=wS, height=hS) self.includeSynopsis.setChecked( self.optState.getBool("GuiBuildNovel", "incSynopsis", False)) self.includeComments = QSwitch(width=wS, height=hS) self.includeComments.setChecked( self.optState.getBool("GuiBuildNovel", "incComments", False)) self.includeKeywords = QSwitch(width=wS, height=hS) self.includeKeywords.setChecked( self.optState.getBool("GuiBuildNovel", "incKeywords", False)) self.includeBody = QSwitch(width=wS, height=hS) self.includeBody.setChecked( self.optState.getBool("GuiBuildNovel", "incBodyText", True)) synopsisLabel = QLabel(self.tr("Include synopsis")) commentsLabel = QLabel(self.tr("Include comments")) keywordsLabel = QLabel(self.tr("Include keywords")) bodyLabel = QLabel(self.tr("Include body text")) self.textForm.addWidget(synopsisLabel, 0, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeSynopsis, 0, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(commentsLabel, 1, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeComments, 1, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(keywordsLabel, 2, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeKeywords, 2, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(bodyLabel, 3, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeBody, 3, 1, 1, 1, Qt.AlignRight) self.textForm.setColumnStretch(0, 1) self.textForm.setColumnStretch(1, 0) # File Filter Options # =================== self.fileGroup = QGroupBox(self.tr("File Filter Options"), self) self.fileForm = QGridLayout(self) self.fileGroup.setLayout(self.fileForm) self.novelFiles = QSwitch(width=wS, height=hS) self.novelFiles.setToolTip( self.tr("Include files with layouts other than 'Note'.")) self.novelFiles.setChecked( self.optState.getBool("GuiBuildNovel", "addNovel", True)) self.noteFiles = QSwitch(width=wS, height=hS) self.noteFiles.setToolTip(self.tr("Include files with layout 'Note'.")) self.noteFiles.setChecked( self.optState.getBool("GuiBuildNovel", "addNotes", False)) self.ignoreFlag = QSwitch(width=wS, height=hS) self.ignoreFlag.setToolTip( self. tr("Ignore the 'Include when building project' setting and include " "all files in the output.")) self.ignoreFlag.setChecked( self.optState.getBool("GuiBuildNovel", "ignoreFlag", False)) novelLabel = QLabel(self.tr("Include novel files")) notesLabel = QLabel(self.tr("Include note files")) exportLabel = QLabel(self.tr("Ignore export flag")) self.fileForm.addWidget(novelLabel, 0, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.novelFiles, 0, 1, 1, 1, Qt.AlignRight) self.fileForm.addWidget(notesLabel, 1, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.noteFiles, 1, 1, 1, 1, Qt.AlignRight) self.fileForm.addWidget(exportLabel, 2, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.ignoreFlag, 2, 1, 1, 1, Qt.AlignRight) self.fileForm.setColumnStretch(0, 1) self.fileForm.setColumnStretch(1, 0) # Export Options # ============== self.exportGroup = QGroupBox(self.tr("Export Options"), self) self.exportForm = QGridLayout(self) self.exportGroup.setLayout(self.exportForm) self.replaceTabs = QSwitch(width=wS, height=hS) self.replaceTabs.setChecked( self.optState.getBool("GuiBuildNovel", "replaceTabs", False)) self.replaceUCode = QSwitch(width=wS, height=hS) self.replaceUCode.setChecked( self.optState.getBool("GuiBuildNovel", "replaceUCode", False)) tabsLabel = QLabel(self.tr("Replace tabs with spaces")) uCodeLabel = QLabel(self.tr("Replace Unicode in HTML")) self.exportForm.addWidget(tabsLabel, 0, 0, 1, 1, Qt.AlignLeft) self.exportForm.addWidget(self.replaceTabs, 0, 1, 1, 1, Qt.AlignRight) self.exportForm.addWidget(uCodeLabel, 1, 0, 1, 1, Qt.AlignLeft) self.exportForm.addWidget(self.replaceUCode, 1, 1, 1, 1, Qt.AlignRight) self.exportForm.setColumnStretch(0, 1) self.exportForm.setColumnStretch(1, 0) # Build Button # ============ self.buildProgress = QProgressBar() self.buildNovel = QPushButton(self.tr("Build Preview")) self.buildNovel.clicked.connect(self._buildPreview) # Action Buttons # ============== self.buttonBox = QHBoxLayout() # Printing self.printMenu = QMenu(self) self.btnPrint = QPushButton(self.tr("Print")) self.btnPrint.setMenu(self.printMenu) self.printSend = QAction(self.tr("Print Preview"), self) self.printSend.triggered.connect(self._printDocument) self.printMenu.addAction(self.printSend) self.printFile = QAction(self.tr("Print to PDF"), self) self.printFile.triggered.connect( lambda: self._saveDocument(self.FMT_PDF)) self.printMenu.addAction(self.printFile) # Saving to File self.saveMenu = QMenu(self) self.btnSave = QPushButton(self.tr("Save As")) self.btnSave.setMenu(self.saveMenu) self.saveODT = QAction(self.tr("Open Document (.odt)"), self) self.saveODT.triggered.connect( lambda: self._saveDocument(self.FMT_ODT)) self.saveMenu.addAction(self.saveODT) self.saveFODT = QAction(self.tr("Flat Open Document (.fodt)"), self) self.saveFODT.triggered.connect( lambda: self._saveDocument(self.FMT_FODT)) self.saveMenu.addAction(self.saveFODT) self.saveHTM = QAction(self.tr("novelWriter HTML (.htm)"), self) self.saveHTM.triggered.connect( lambda: self._saveDocument(self.FMT_HTM)) self.saveMenu.addAction(self.saveHTM) self.saveNWD = QAction(self.tr("novelWriter Markdown (.nwd)"), self) self.saveNWD.triggered.connect( lambda: self._saveDocument(self.FMT_NWD)) self.saveMenu.addAction(self.saveNWD) self.saveMD = QAction(self.tr("Standard Markdown (.md)"), self) self.saveMD.triggered.connect(lambda: self._saveDocument(self.FMT_MD)) self.saveMenu.addAction(self.saveMD) self.saveGH = QAction(self.tr("GitHub Markdown (.md)"), self) self.saveGH.triggered.connect(lambda: self._saveDocument(self.FMT_GH)) self.saveMenu.addAction(self.saveGH) self.saveJsonH = QAction(self.tr("JSON + novelWriter HTML (.json)"), self) self.saveJsonH.triggered.connect( lambda: self._saveDocument(self.FMT_JSON_H)) self.saveMenu.addAction(self.saveJsonH) self.saveJsonM = QAction( self.tr("JSON + novelWriter Markdown (.json)"), self) self.saveJsonM.triggered.connect( lambda: self._saveDocument(self.FMT_JSON_M)) self.saveMenu.addAction(self.saveJsonM) self.btnClose = QPushButton(self.tr("Close")) self.btnClose.clicked.connect(self._doClose) self.buttonBox.addWidget(self.btnSave) self.buttonBox.addWidget(self.btnPrint) self.buttonBox.addWidget(self.btnClose) self.buttonBox.setSpacing(self.mainConf.pxInt(4)) # Assemble GUI # ============ # Splitter Position boxWidth = self.mainConf.pxInt(350) boxWidth = self.optState.getInt("GuiBuildNovel", "boxWidth", boxWidth) docWidth = max(self.width() - boxWidth, 100) docWidth = self.optState.getInt("GuiBuildNovel", "docWidth", docWidth) # The Tool Box self.toolsBox = QVBoxLayout() self.toolsBox.addWidget(self.titleGroup) self.toolsBox.addWidget(self.fontGroup) self.toolsBox.addWidget(self.styleGroup) self.toolsBox.addWidget(self.textGroup) self.toolsBox.addWidget(self.fileGroup) self.toolsBox.addWidget(self.exportGroup) self.toolsBox.addStretch(1) # Tool Box Wrapper Widget self.toolsWidget = QWidget() self.toolsWidget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.toolsWidget.setLayout(self.toolsBox) # Tool Box Scroll Area self.toolsArea = QScrollArea() self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250)) self.toolsArea.setWidgetResizable(True) self.toolsArea.setWidget(self.toolsWidget) if self.mainConf.hideVScroll: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) if self.mainConf.hideHScroll: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Tools and Buttons Layout tSp = self.mainConf.pxInt(8) self.innerBox = QVBoxLayout() self.innerBox.addWidget(self.toolsArea) self.innerBox.addSpacing(tSp) self.innerBox.addWidget(self.buildProgress) self.innerBox.addWidget(self.buildNovel) self.innerBox.addSpacing(tSp) self.innerBox.addLayout(self.buttonBox) # Tools and Buttons Wrapper Widget self.innerWidget = QWidget() self.innerWidget.setLayout(self.innerBox) # Main Dialog Splitter self.mainSplit = QSplitter(Qt.Horizontal) self.mainSplit.addWidget(self.innerWidget) self.mainSplit.addWidget(self.docView) self.mainSplit.setSizes([boxWidth, docWidth]) self.idxSettings = self.mainSplit.indexOf(self.innerWidget) self.idxDocument = self.mainSplit.indexOf(self.docView) self.mainSplit.setCollapsible(self.idxSettings, False) self.mainSplit.setCollapsible(self.idxDocument, False) # Outer Layout self.outerBox = QHBoxLayout() self.outerBox.addWidget(self.mainSplit) self.setLayout(self.outerBox) self.buildNovel.setFocus() logger.debug("GuiBuildNovel initialisation complete") return
def __init__(self, model=None): # Set ui in here super(MapEditor, self).__init__() layout = QGridLayout() # Create a tab widget self.model = MapModel() if model is None else model self.model.modelUpdated.connect(self.updateUI) self.mouseOverItem = None self.pressedItem = None self.filePathOfModel = None self.mapEditGraphics = MapEditorGraphics(self.model) self.mapEditGraphics.updatePreview.connect(self.updateUI) self.mapEditGraphics.selectedItem.connect(self.updateSelection) # Add Scrollable area for groupPreview self.scrollArea = QScrollArea() self.scrollArea.setWidget(self.mapEditGraphics) self.scrollArea.setBackgroundRole(QPalette.Dark) self.scrollArea.setAlignment(Qt.AlignCenter) self.scrollArea.setMinimumWidth(500) self.scrollArea.setMinimumHeight(500) self.tabWidget = QTabWidget() self.tabWidget.currentChanged.connect( self.mapEditGraphics.updateSelectedTab) self.tilePicker = EMModelPicker(ModelManager.TileName, TileModel, TileEditor, TilePreviewWidget) self.tilePicker.selectedModel.connect( self.mapEditGraphics.updateSelectedObject) self.groupPicker = EMModelPicker(ModelManager.GroupName, GroupModel, GroupEditor, GroupPreview) self.groupPicker.selectedModel.connect( self.mapEditGraphics.updateSelectedObject) self.notesWidget = NotesTab() self.notesWidget.setCurrentEditor(self) self.tabWidget.addTab(self.tilePicker, "Tiles") self.tabWidget.addTab(self.groupPicker, "Groups") self.tabWidget.addTab(QLabel("Coming Soon"), "Objects") self.tabWidget.addTab(self.notesWidget, "Notes") self.btnGroup = QWidget() btnLayout = QGridLayout() self.cwBtn = QPushButton("CW") self.cwBtn.clicked.connect(self.rotateTileMapCW) self.ccwBtn = QPushButton("CCW") self.ccwBtn.clicked.connect(self.rotateTileMapCCW) self.hfBtn = QPushButton("|") self.hfBtn.setCheckable(True) self.hfBtn.clicked.connect(self.flipTileMapH) self.vfBtn = QPushButton("--") self.vfBtn.setCheckable(True) self.vfBtn.clicked.connect(self.flipTileMapV) self.addRowBtn = QPushButton("Add Row") self.addRowBtn.clicked.connect(self.addGroupRow) self.delRowBtn = QPushButton("Del Row") self.delRowBtn.clicked.connect(self.delGroupRow) self.addColBtn = QPushButton("Add Col") self.addColBtn.clicked.connect(self.addGroupCol) self.delColBtn = QPushButton("Del Col") self.delColBtn.clicked.connect(self.delGroupCol) btnLayout.addWidget(self.cwBtn, 0, 0) btnLayout.addWidget(self.ccwBtn, 1, 0) btnLayout.addWidget(self.hfBtn, 0, 1) btnLayout.addWidget(self.vfBtn, 1, 1) btnLayout.addWidget(self.addRowBtn, 0, 2) btnLayout.addWidget(self.delRowBtn, 1, 2) btnLayout.addWidget(self.addColBtn, 0, 3) btnLayout.addWidget(self.delColBtn, 1, 3) self.btnGroup.setLayout(btnLayout) layout.addWidget(self.scrollArea, 0, 0) layout.addWidget(self.tabWidget, 0, 1, 2, 1) layout.addWidget(self.btnGroup, 1, 0) self.setLayout(layout)
def __init__(self, cmndpipe, rspdpipe): ''' Create a PyQt viewer which reads commands from the Pipe cmndpipe and writes responses back to rspdpipe. ''' super(PipedImagerPQ, self).__init__() self.__cmndpipe = cmndpipe self.__rspdpipe = rspdpipe # ignore Ctrl-C signal.signal(signal.SIGINT, signal.SIG_IGN) # unmodified image for creating the scene self.__sceneimage = None # bytearray of data for the above image self.__scenedata = None # flag set if in the process of reading image data from commands self.__loadingimage = False # width and height of the unmodified scene image # when the image is defined # initialize the width and height to values that will create # a viewer (mainWindow) of the right size self.__scenewidth = int(10.8 * self.physicalDpiX()) self.__sceneheight = int(8.8 * self.physicalDpiY()) # by default pay attention to any alpha channel values in colors self.__noalpha = False # initial default color for the background (opaque white) self.__lastclearcolor = QColor(0xFFFFFF) self.__lastclearcolor.setAlpha(0xFF) # scaling factor for creating the displayed scene self.__scalefactor = 1.0 # automatically adjust the scaling factor to fit the window frame? self.__autoscale = True # minimum label width and height (for minimum scaling factor) # and minimum image width and height (for error checking) self.__minsize = 128 # create the label, that will serve as the canvas, in a scrolled area self.__scrollarea = QScrollArea(self) self.__label = QLabel(self.__scrollarea) # set the initial label size and other values for the scrolled area self.__label.setMinimumSize(self.__scenewidth, self.__sceneheight) self.__label.resize(self.__scenewidth, self.__sceneheight) # setup the scrolled area self.__scrollarea.setWidget(self.__label) self.__scrollarea.setBackgroundRole(QPalette.Dark) self.setCentralWidget(self.__scrollarea) # default file name and format for saving the image self.__lastfilename = "ferret.png" self.__lastformat = "png" # command helper object self.__helper = CmndHelperPQ(self) # create the menubar self.__scaleact = QAction( self.tr("&Scale"), self, shortcut=self.tr("Ctrl+S"), statusTip=self.tr( "Scale the image (canvas and image change size)"), triggered=self.inquireSceneScale) self.__saveact = QAction(self.tr("Save &As..."), self, shortcut=self.tr("Ctrl+A"), statusTip=self.tr("Save the image to file"), triggered=self.inquireSaveFilename) self.__redrawact = QAction( self.tr("&Redraw"), self, shortcut=self.tr("Ctrl+R"), statusTip=self.tr("Clear and redraw the image"), triggered=self.redrawScene) self.__aboutact = QAction( self.tr("&About"), self, statusTip=self.tr("Show information about this viewer"), triggered=self.aboutMsg) self.__aboutqtact = QAction( self.tr("About &Qt"), self, statusTip=self.tr("Show information about the Qt library"), triggered=self.aboutQtMsg) self.createMenus() # set the initial size of the viewer self.__framedelta = 4 mwwidth = self.__scenewidth + self.__framedelta mwheight = self.__sceneheight + self.__framedelta \ + self.menuBar().height() \ + self.statusBar().height() self.resize(mwwidth, mwheight) # check the command queue any time there are no window events to deal with self.__timer = QTimer(self) self.__timer.timeout.connect(self.checkCommandPipe) self.__timer.setInterval(0) self.__timer.start()
def tabRoverUI(self): # Start button self.start_rov = QPushButton('Start', self) self.start_rov.setCheckable(True) self.start_rov.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.start_rov.toggled.connect(self.startRoverToggled) self.start_rov.setFont(QFont('Helvetica', 16)) # Config button self.config_rov = QPushButton('Config', self) self.config_rov.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.config_rov.clicked.connect(self.makeRoverConfig) self.config_rov.setFont(QFont('Helvetica', 16)) # Command window self.status_rov = QLabel('') self.status_rov.setFont(QFont('Helvetica', 11)) scroll = QScrollArea() scroll.setFrameShape(False) scroll.setWidgetResizable(True) scroll.setFixedHeight(25) scroll.setWidget(self.status_rov) # Icon fig = QPixmap(MainWindow.dirtrs + '/img/rover.png') icon = QLabel(self) icon.setPixmap(fig) # Layout hbox1 = QHBoxLayout() hbox2 = QHBoxLayout() hbox3 = QHBoxLayout() vbox1_1 = QVBoxLayout() hbox1_1 = QHBoxLayout() hbox1_2 = QHBoxLayout() hbox1_3 = QHBoxLayout() vbox = QVBoxLayout() # hbox1 hbox1.addSpacing(10) hbox1.addWidget(icon) hbox1.addSpacing(10) self.mode_spp = QPushButton('Single', self) self.mode_spp.setCheckable(True) self.mode_spp.toggle() self.mode_spp.toggled.connect(self.sppToggled) self.mode_spp.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.mode_rtks = QPushButton('RTK\n(Static)', self) self.mode_rtks.setCheckable(True) self.mode_rtks.toggled.connect(self.rtksToggled) self.mode_rtks.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.mode_rtkk = QPushButton('RTK\n(Kinematic)', self) self.mode_rtkk.setCheckable(True) self.mode_rtkk.toggled.connect(self.rtkkToggled) self.mode_rtkk.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) hbox1_2.addWidget(self.mode_spp) hbox1_2.addWidget(self.mode_rtks) hbox1_2.addWidget(self.mode_rtkk) vbox1_1.addLayout(hbox1_2) hbox1_3.addWidget(self.start_rov) hbox1_3.addWidget(self.config_rov) vbox1_1.addLayout(hbox1_3) hbox1.addLayout(vbox1_1) # lSol_ = QLabel('Sol:') lSol_.setAlignment(QtCore.Qt.AlignRight) self.lSol = QLabel('') lLat_ = QLabel('Lat:') lLat_.setAlignment(QtCore.Qt.AlignRight) self.lLat = QLabel('') lLon_ = QLabel('Lon:') lLon_.setAlignment(QtCore.Qt.AlignRight) self.lLon = QLabel('') lAlt_ = QLabel('Alt:') lAlt_.setAlignment(QtCore.Qt.AlignRight) self.lAlt = QLabel('') hbox2.addWidget(lSol_) hbox2.addWidget(self.lSol) hbox2.addWidget(lLat_) hbox2.addWidget(self.lLat) hbox2.addWidget(lLon_) hbox2.addWidget(self.lLon) hbox2.addWidget(lAlt_) hbox2.addWidget(self.lAlt) # hbox3 hbox3.addWidget(scroll) # Add to layout vbox.addLayout(hbox1, 1) vbox.addLayout(hbox2) vbox.addLayout(hbox3) # Show layout self.tabRover.setLayout(vbox)
def Format(self): from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel, QScrollArea, QScrollBar, QSpacerItem, QSizePolicy, QAbstractScrollArea, QGroupBox from PyQt5.QtGui import QPixmap, QFont from PyQt5.QtCore import Qt self.setPalette(self.palette) #self.FormatButton() total_page_layout = QVBoxLayout() pic_label = QLabel() pixmap = QPixmap('bplogo_transparent.png') pixmap = pixmap.scaled(self.width() / 6, self.height() / 6, Qt.KeepAspectRatio, Qt.FastTransformation) pic_label.setPixmap(pixmap) picture_layout = QHBoxLayout() picture_layout.addWidget(pic_label) picture_layout.setAlignment(Qt.AlignCenter) app_logo_layout = QHBoxLayout() app_label = QLabel() app_pixmap = QPixmap('applogo.png') app_pixmap = app_pixmap.scaled(self.width() / 6, self.height() / 6, Qt.KeepAspectRatio, Qt.FastTransformation) app_label.setPixmap(app_pixmap) app_logo_layout.addWidget(app_label) app_logo_layout.setAlignment(Qt.AlignCenter) title_layout = QHBoxLayout() title_label = QLabel('BPX LE Adjustment Utility') title_font = QFont("Georgia", self.height() / 30, QFont.Bold) title_label.setFont(title_font) title_layout.addWidget(title_label) title_layout.setAlignment(Qt.AlignRight) header_layout = QHBoxLayout() header_layout.addLayout(app_logo_layout) header_layout.addLayout(title_layout) header_layout.addLayout(picture_layout) total_page_layout.addLayout(header_layout) total_page_layout = self.FormatWellSelection(total_page_layout) total_page_layout = self.FormatGraphArea(total_page_layout) total_page_layout = self.FormatTableArea(total_page_layout) total_page_layout = self.FormatBottomButtonRow(total_page_layout) group_box = QGroupBox() group_box.setLayout(total_page_layout) self.scroll_area = QScrollArea() self.scroll_area.setWidget(group_box) self.scroll_area.setWidgetResizable(True) # self.scroll_area.setFixedHeight(400) global_layout = QHBoxLayout() global_layout.addWidget(self.scroll_area) widget = QWidget() widget.setLayout(global_layout) self.setCentralWidget(widget)
def GroupBoxThreeLayout(self): groupBoxTwo = QGroupBox() middleHBox = QHBoxLayout() middleRightGroupBox = QGroupBox("Flag Selection") tabVBoxLayout = QVBoxLayout() tabs = QTabWidget() tabNames = ["Flags", "Sprites", "SpriteCategories", "Battle", "Aesthetic", "Major", "Experimental", "Gamebreaking", "Beta"] ############## Checkboxes and inline descriptions ##################### #setStyleSheet("border:none"); # loop to add tab objects to 'tabs' TabWidget for t, d, names in zip(self.tablist, self.dictionaries, tabNames): tabObj = QScrollArea() tabs.addTab(tabObj, names) #we have a horizontal box that can go item1, item 2 in left-right fashion itemLayout = QHBoxLayout() #we then have two vertical boxes, one for normal flags, one for flags that have sliders or entry boxes. boxOneLayout = QVBoxLayout() boxTwoVertLayout = QVBoxLayout() boxTwoHorzLayout = QVBoxLayout() #we then have the group boxes the vertical tayouts get set into groupOneBox = QGroupBox() groupTwoVertBox = QGroupBox() groupTwoHorzBox = QGroupBox() flagGroup = QGroupBox() for flagname, flagdesc in d.items(): #TODO: this can probably be done better once I know GUI better... if flagname == "exp": cbox = FlagCheckBox(f"{flagname} - {flagdesc['explanation']}", flagname) #self.checkBoxes.append(cbox) #cbox.clicked.connect(lambda checked: self.flagButtonClicked()) #boxTwoHorzLayout.addWidget(cbox) #slider = QSlider(QtCore.Qt.Horizontal) #boxTwoHorzLayout.addWidget(slider) #groupTwoHorzBox.setLayout(boxTwoHorzLayout) #boxTwoVertLayout.addWidget(groupTwoHorzBox) #groupTwoHorzBox.setLayout(boxTwoVertLayout) else: cbox = FlagCheckBox(f"{flagname} - {flagdesc['explanation']}", flagname) self.checkBoxes.append(cbox) cbox.clicked.connect(lambda checked: self.flagButtonClicked()) boxOneLayout.addWidget(cbox) #context - adding a second pane to certain tabs for now for sliders. groupOneBox.setLayout(boxOneLayout) itemLayout.addWidget(groupOneBox) #itemLayout.addWidget(groupTwoHorzBox) t.setLayout(itemLayout) #tablayout.addStretch(1) tabObj.setWidgetResizable(True) tabObj.setWidget(t) tabVBoxLayout.addWidget(tabs) #----------- tabs done ---------------------------- # this is the line in the layout that displays the string of selected # flags # and the button to save those flags widgetV = QWidget() widgetVBoxLayout = QVBoxLayout() widgetV.setLayout(widgetVBoxLayout) widgetVBoxLayout.addWidget(QLabel("Text-string of selected flags:")) self.flagString.textChanged.connect(self.textchanged) widgetVBoxLayout.addWidget(self.flagString) saveButton = QPushButton("Save flags selection") saveButton.clicked.connect(lambda: self.saveFlags()) widgetVBoxLayout.addWidget(saveButton) # This part makes a group box and adds the selected-flags display # and a button to clear the UI flagTextWidget = QGroupBox() flagTextHBox = QHBoxLayout() flagTextHBox.addWidget(widgetV) clearUiButton = QPushButton("Reset") clearUiButton.setStyleSheet("font:bold; font-size:16px; height:60px; background-color: #5A8DBE; color: #E4E4E4;") clearUiButton.clicked.connect(lambda: self.clearUI()) clearUiButton.setCursor(QCursor(QtCore.Qt.PointingHandCursor)) effect = QGraphicsDropShadowEffect() effect.setBlurRadius(3) clearUiButton.setGraphicsEffect(effect) flagTextHBox.addWidget(clearUiButton) flagTextWidget.setLayout(flagTextHBox) tabVBoxLayout.addWidget(flagTextWidget) middleRightGroupBox.setLayout(tabVBoxLayout) # ------------- Part two (right) end # --------------------------------------- # add widgets to HBoxLayout and assign to middle groupbox layout middleHBox.addWidget(middleRightGroupBox) groupBoxTwo.setLayout(middleHBox) return groupBoxTwo
def flagBoxLayout(self): groupBoxTwo = QGroupBox() middleHBox = QHBoxLayout() middleRightGroupBox = QGroupBox("Flag Selection") tabVBoxLayout = QVBoxLayout() tabs = QTabWidget() # loop to add tab objects to 'tabs' TabWidget for t, d, names in zip(self.tablist, self.dictionaries, self.tabNames): tabObj = QScrollArea() tabs.addTab(tabObj, names) tablayout = QVBoxLayout() for flagname, flagdesc in d.items(): cbox = FlagCheckBox(f"{flagname} - {flagdesc['explanation']}", flagname) self.checkBoxes.append(cbox) tablayout.addWidget(cbox) #cbox.setCheckable(True) #cbox.setToolTip(flagdesc['explanation']) cbox.clicked.connect(lambda checked: self.flagButtonClicked()) t.setLayout(tablayout) #tablayout.addStretch(1) tabObj.setWidgetResizable(True) tabObj.setWidget(t) tabVBoxLayout.addWidget(tabs) # this is the line in the layout that displays the string of selected flags # and the button to save those flags widgetV = QWidget() widgetVBoxLayout = QVBoxLayout() widgetV.setLayout(widgetVBoxLayout) widgetVBoxLayout.addWidget(QLabel("Text-string of selected flags:")) self.flagString.textChanged.connect(self.textchanged) widgetVBoxLayout.addWidget(self.flagString) saveButton = QPushButton("Save flags selection") saveButton.clicked.connect(lambda: self.saveFlags()) widgetVBoxLayout.addWidget(saveButton) # This part makes a group box and adds the selected-flags display # and a button to clear the UI flagTextWidget = QGroupBox() flagTextHBox = QHBoxLayout() flagTextHBox.addWidget(widgetV) clearUiButton = QPushButton("Reset") clearUiButton.setStyleSheet("font-size:12px; height:60px") clearUiButton.clicked.connect(lambda: self.clearUI()) flagTextHBox.addWidget(clearUiButton) flagTextWidget.setLayout(flagTextHBox) tabVBoxLayout.addWidget(flagTextWidget) middleRightGroupBox.setLayout(tabVBoxLayout) # ------------- Part two (right) end --------------------------------------- # add widgets to HBoxLayout and assign to middle groupbox layout middleHBox.addWidget(middleRightGroupBox) groupBoxTwo.setLayout(middleHBox) return groupBoxTwo
def initUI(self): addInstitutionButton = QPushButton('') addInstitutionButton.setIcon(QIcon('image/plus_2.png')) addInstitutionButton.setIconSize(QSize(75, 75)) addInstitutionButton.clicked.connect(self.addConcl) updateButton = QPushButton('') updateButton.setIcon(QIcon('image/update_2.png')) updateButton.setIconSize(QSize(75, 75)) updateButton.clicked.connect(self.update_window) backButton = QPushButton('') backButton.setIcon(QIcon('image/back_2.png')) backButton.setIconSize(QSize(75, 75)) backButton.clicked.connect(self.back) exitButton = QPushButton('') exitButton.setIcon(QIcon('image/exit_2.png')) exitButton.setIconSize(QSize(75, 75)) exitButton.clicked.connect(self.exit) title = QLabel(self.number) buttons_left = QHBoxLayout() buttons_left.addWidget(backButton) buttons_left.addWidget(addInstitutionButton) buttons_right = QHBoxLayout() buttons_right.addWidget(updateButton) buttons_right.addWidget(exitButton) title.setStyleSheet( "background-color: rgba(255, 255, 255, 0.5); color: black;" "border: 3px solid transparent;" "padding: 10px 300% 10px 300%;" "margin-top: 0px;" "font-size: 30px; font-family: Verdana;") addInstitutionButton.setStyleSheet( "background-color: rgba(255, 255, 255, 0.1); padding: 12px;") updateButton.setStyleSheet( "background-color: rgba(255, 255, 255, 0.1); padding: 12px;") backButton.setStyleSheet( "background-color: rgba(255, 255, 255, 0.1); padding: 12px;") exitButton.setStyleSheet( "background-color: rgba(255, 255, 255, 0.1); padding: 12px;") tit_h = QHBoxLayout() tit_h.addLayout(buttons_left) tit_h.addStretch(1) tit_h.addWidget(title) tit_h.addStretch(1) tit_h.addLayout(buttons_right) addHost = QPushButton() addHost.setFixedSize(40, 40) addHost.setIcon(QIcon('image/plus.png')) addHost.setIconSize(QSize(40, 40)) textConcl = QPushButton() textConcl.setFixedSize(40, 40) textConcl.setIcon(QIcon('image/photo.png')) textConcl.setIconSize(QSize(40, 40)) photoConcl = QPushButton() photoConcl.setFixedSize(40, 40) photoConcl.setIcon(QIcon('image/text.png')) photoConcl.setIconSize(QSize(40, 40)) number = QLabel('Номер') number.setAlignment(Qt.AlignCenter) number.setFixedHeight(40) type = QLabel('Тип заключения') type.setAlignment(Qt.AlignCenter) type.setFixedHeight(40) name = QLabel('Имя') name.setAlignment(Qt.AlignCenter) name.setFixedHeight(40) date_z = QLabel('Дата заявки') date_z.setAlignment(Qt.AlignCenter) date_z.setFixedHeight(40) date_v = QLabel('Дата выдачи') date_v.setAlignment(Qt.AlignCenter) date_v.setFixedHeight(40) date_d = QLabel('Дата разрушения') date_d.setAlignment(Qt.AlignCenter) date_d.setFixedHeight(40) top_h = QHBoxLayout() top_h.addWidget(number) top_h.addWidget(type) top_h.addWidget(name) top_h.addWidget(date_z) top_h.addWidget(date_v) top_h.addWidget(date_d) top_h.addWidget(addHost) top_h.addWidget(textConcl) top_h.addWidget(photoConcl) j = 0 v_host = QVBoxLayout() v_host.setSpacing(0) scroll = QScrollArea() scroll.setWidgetResizable(True) scroll.setStyleSheet("border: none; background-color: transparent;") scroll_mini = QScrollArea() scroll_mini.setWidgetResizable(True) scroll_mini.setStyleSheet( "border: 1px solid transparent; background-color: transparent;") ii = QWidget() ii.setStyleSheet( "QWidget {background-color: rgba(255, 255, 255, 0.6);}" "QLabel {background-color: transparent;}" "QPushButton {background-color: transparent; border-radius: 10px;}" ) ii.setFixedHeight(65) ii.setLayout(top_h) scroll_mini.setWidget(ii) self.w = self.width() form = QFormLayout() db = SqliteDatabase('mydb.db') db.connect() for i in Conclusions2.select().where( Conclusions2.owner == self.number): arr = [ i.owner, i.number, i.type, i.name, i.reason, i.recommendation, i.photo, i.conclusions, i.date_z, i.date_v, i.date_d, i.text ] print(arr) if j % 2 == 0: host = Concl(arr, self.expansion) else: host = Concl(arr, self.expansion) host.move(-300, -300) form.addRow(host) j += 1 db.close() gg = QWidget() gg.setLayout(form) hei = self.height() print(hei) scroll.setWidget(gg) lbl = QLabel() h = QVBoxLayout() h.addLayout(tit_h) h.addWidget(scroll_mini) h.addWidget(scroll) '''a1 = Concl('3') a2 = Concl('3') a3 = Concl('3') a11 = QHBoxLayout() a11.addWidget(a1) a22 = QHBoxLayout() a22.addWidget(a2) a33 = QHBoxLayout() a33.addWidget(a3) grid = QFormLayout() grid.setSpacing(0) grid.addRow(a11) grid.addRow(a22) grid.addRow(a33) bloc_v = QVBoxLayout() bloc_v.setSpacing(0) bloc_v.addWidget(a1) bloc_v.addWidget(a2) bloc_v.addWidget(a3) bloc_v.setSpacing(0) frame = QFrame() frame.setLayout(bloc_v) frame.setFixedHeight(450) x = QHBoxLayout() x.addWidget(frame) self.setContentsMargins(0,0,0,0) x = QWidget() x.setLayout(grid) self.scroll = QScrollArea() self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setWidgetResizable(True) self.scroll.setWidget(x) h = QHBoxLayout() h.addWidget(self.scroll) ''' self.setLayout(h) p = QPalette() gradient = QLinearGradient(0, 0, 120, 400) gradient.setColorAt(0.0, QColor(117, 160, 252)) gradient.setColorAt(1.0, QColor(193, 203, 253)) p.setBrush(QPalette.Window, QBrush(gradient)) self.setPalette(p) if self.expansion == '1': self.showFullScreen() scroll.setMinimumHeight(hei + 100) else: self.setGeometry(0, 30, 800, 600) scroll.setMinimumHeight(hei) self.setWindowTitle('Menubar') self.show()
def __init__(self): super().__init__(flags=QtCore.Qt.Window) self.setWindowIcon(QIcon(QPixmap(":/icon/codeblock_icon.svg"))) scale_x = QDesktopWidget().screenGeometry().width()/1920 scale_y = QDesktopWidget().screenGeometry().height()/1080 self.resize(1280*scale_x, 720*scale_y) self.centralwidget = QWidget() self.centralwidget.setObjectName("centralwidget") self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setObjectName("horizontalLayout") self.splitter = QSplitter(self.centralwidget) self.tabWidget = QTabWidget(self.centralwidget) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(4) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) self.tabWidget.setSizePolicy(sizePolicy) self.tabWidget.setTabShape(QTabWidget.Rounded) self.tabWidget.setMovable(True) self.tabWidget.setObjectName("tabWidget") self.tab = QWidget() self.tab.setObjectName("tab") self.verticalLayout2 = QVBoxLayout(self.tab) self.classView = QTreeWidget(self.tab) self.classView.header().setVisible(False) self.verticalLayout2.addWidget(self.classView) self.tabWidget.addTab(self.tab, "") self.splitter.addWidget(self.tabWidget) self.tabWidget_2 = QTabWidget(self.centralwidget) self.tab_3 = QWidget() self.tab_3.setObjectName("tab_3") self.tabWidget_2.addTab(self.tab_3, "") self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 184, 148)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(7) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tabWidget_2.sizePolicy().hasHeightForWidth()) self.tabWidget_2.setSizePolicy(sizePolicy) self.tabWidget_2.setTabsClosable(False) self.tabWidget_2.setMovable(True) self.tabWidget_2.setObjectName("tabWidget_2") self.splitter.addWidget(self.tabWidget_2) self.horizontalLayout.addWidget(self.splitter) self.setCentralWidget(self.centralwidget) self.menubar = QMenuBar() self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 23)) self.menubar.setObjectName("menubar") self.menuFile = QMenu(self.menubar) self.menuHelp = QMenu(self.menubar) self.actionOpen = QAction(self) self.actionOpen.setText("Open") self.menuFile.addAction(self.actionOpen) self.menuFile.setTitle("File") self.menubar.addAction(self.actionOpen) self.actionAbout = QAction(self) self.actionAbout.setText("About Codeblock Visual Studio") self.actionTutorial = QAction(self) self.actionTutorial.setText("Rerun Tutorial") self.menuHelp.addAction(self.actionAbout) self.menuHelp.addAction(self.actionTutorial) self.menuHelp.setTitle("Help") self.menubar.addAction(self.menuHelp.menuAction()) self.setMenuBar(self.menubar) self.statusbar = QStatusBar() self.statusbar.setObjectName("statusbar") self.setStatusBar(self.statusbar) self.frameLayout = QHBoxLayout(self.tab_3) self.scroll = QScrollArea() self.scrollContents = QWidget() self.scrollContents.setGeometry(QtCore.QRect(0, 0, 5000, 50000)) self.scrollLayout = QHBoxLayout(self.scrollContents) self.codeArea = QFrame(self.scrollContents) self.codeArea.setMinimumSize(QtCore.QSize(200, 2000)) self.scrollLayout.addWidget(self.codeArea) self.frameLayout.addWidget(self.scroll) self.scroll.setWidget(self.scrollContents) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), "Class View") self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_3), "Code Area")
def _set_ui(self): main_box = QVBoxLayout(self) name_lbl = self.findChild(QLabel, "name_lbl") settings_box = QHBoxLayout(self) text_scr = QScrollArea(self) color = QColor(255, 255, 255) palette = QPalette(color) text_scr.setPalette(palette) text_w = QWidget(self) text_grid = QGridLayout(text_w) grid_row = 0 if self.copter.equal_engines: grid_column_num = 1 else: grid_column_num = 2 settings_lbl = self.findChild(QLabel, "settings_lbl") mass_lbl = self.findChild(QLabel, "mass_lbl") mass_line = self.findChild(QLineEdit, "mass_line") mass_line.setText(str(self.engine.mass)) in_moment_lbl = self.findChild(QLabel, "in_moment_lbl") in_moment_w = QWidget(text_w) in_moment_grid = QGridLayout(in_moment_w) for i in range(3): for j in range(3): in_moment_line = self.findChild( QLineEdit, "in_moment_line_{0}{1}".format(i, j)) in_moment_line.setText(str(self.engine.inertia_moment[j, i])) in_moment_grid.addWidget(in_moment_line, i, j) text_grid.addWidget(settings_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(mass_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(mass_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(in_moment_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(in_moment_w, grid_row, 0, 3, grid_column_num) grid_row += 3 if not self.copter.equal_engines: rot_dir_lbl = self.findChild(QLabel, "rot_dir_lbl") rot_dir_cmbx = self.findChild(QComboBox, "rot_dir_cmbx") rot_dir_cmbx.setCurrentText(self.engine.rotation_dir) text_grid.addWidget(rot_dir_lbl, grid_row, 0, 1, 1) text_grid.addWidget(rot_dir_cmbx, grid_row, 1, 1, 1) grid_row += 1 blade_dir_lbl = self.findChild(QLabel, "blade_dir_lbl") blade_dir_cmbx = self.findChild(QComboBox, "blade_dir_cmbx") blade_dir_cmbx.setCurrentText(self.engine.blade_dir) text_grid.addWidget(blade_dir_lbl, grid_row, 0, 1, 1) text_grid.addWidget(blade_dir_cmbx, grid_row, 1, 1, 1) grid_row += 1 max_power_lbl = self.findChild(QLabel, "max_power_lbl") max_power_line = self.findChild(QLineEdit, "max_power_line") max_power_line.setText(str(self.engine.max_power)) max_dr_moment_lbl = self.findChild(QLabel, "max_dr_moment_lbl") max_dr_moment_line = self.findChild(QLineEdit, "max_dr_moment_line") max_dr_moment_line.setText(str(self.engine.max_drive_moment)) max_pwm_lbl = self.findChild(QLabel, "max_pwm_lbl") max_pwm_line = self.findChild(QLineEdit, "max_pwm_line") max_pwm_line.setText(str(self.engine.max_pwm)) blade_diameter_lbl = self.findChild(QLabel, "blade_diameter_lbl") blade_diameter_line = self.findChild(QLineEdit, "blade_diameter_line") blade_diameter_line.setText(str(self.engine.blade_diameter)) blade_coef_a_lbl = self.findChild(QLabel, "blade_coef_a_lbl") blade_coef_a_line = self.findChild(QLineEdit, "blade_coef_a_line") blade_coef_a_line.setText(str(self.engine.blade_coef_alpha)) blade_coef_b_lbl = self.findChild(QLabel, "blade_coef_b_lbl") blade_coef_b_line = self.findChild(QLineEdit, "blade_coef_b_line") blade_coef_b_line.setText(str(self.engine.blade_coef_beta)) stretch_box_v = QVBoxLayout(self) stretch_box_v.addStretch(1) text_grid.addWidget(max_power_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(max_power_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(max_dr_moment_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(max_dr_moment_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(max_pwm_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(max_pwm_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(blade_diameter_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(blade_diameter_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(blade_coef_a_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(blade_coef_a_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(blade_coef_b_lbl, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addWidget(blade_coef_b_line, grid_row, 0, 1, grid_column_num) grid_row += 1 text_grid.addItem(stretch_box_v) text_scr.setWidgetResizable(False) text_scr.setWidget(text_w) copter_pic = QPixmap(main_window.__icon_dir__ + "copterBlueprint.png") copter_lbl = QLabel() copter_lbl.setPixmap(copter_pic) settings_box.addWidget(text_scr) settings_box.addWidget(copter_lbl) main_box.addWidget(name_lbl) main_box.addLayout(settings_box) self.setLayout(main_box) return
def __init__(self, pageNumber, driver): super().__init__() """ QUICK START IN OPTIONS HANDLE EXCEPTIONS WERES ARE BLOCKED OR NETWORK DOESNT WORK ETC -> WHEN GOING BACK ONLINE LOAD IMAGE REOPNING TAB DOESNT SAVE PAGE STATE REOPNING TAB OPENS IN DIFFERENT BROWSER BETTER WAY TO CHECK WHETHER ITS A STANDLONE EXEC OR LOCALLY RUN HAVE A LOOK AT QSETTINGS TO REMEMBER WINDOW SIZES AND SESSION STATE ETC.. FUTURE FEATURES: - MORE FREEDOM WITH REARRANGING TABS - SUPPORT OTHER DATA TYPES E.G. PDF FILE ETC.. - FAVOURITE TABS -> MOVES THEM HIGHER - ANIMATE CLOSE BUTTON FADE IN/OUT - IMPLEMENT THEMES (ONLY DARK MODE RIGHT NOW) """ # SETUP THUMBNAIL FOLDER if not (os.path.isdir(tabsettings.absImageFolderPath())): os.mkdir(tabsettings.absImageFolderPath()) self.clearingTabs = False self.acceptDrops = True self.options = tabsettings.TabSettings() self.pageNumber = pageNumber self.pageName = 'Page ' + str(self.pageNumber) self.driver = driver self.setPageName() # SETUP LAYOUTS self.mainLayout = QVBoxLayout() self.scroll = QScrollArea() self.scrollWidget = QWidget() self.scrollWidgetLayout = QVBoxLayout() self.scroll.setWidgetResizable(True) self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.scroll.setFrameStyle(QFrame.NoFrame) self.scrollWidgetLayout.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.scrollWidgetLayout.setContentsMargins(3, 3, 3, 3) self.scrollWidgetLayout.setSpacing(3) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.scrollWidget.setLayout(self.scrollWidgetLayout) self.scroll.setWidget(self.scrollWidget) self.mainLayout.addWidget(self.scroll) self.setLayout(self.mainLayout) # IF TAB FILE EXISTS REMAKE TABS self.tabFilePath = os.path.join(os.getcwd(), tabsettings.tabFileName(self)) self.tabFileName = tabsettings.tabFileName(self) self.archiveTabFileName = tabsettings.archiveTabFileName(self) exists = os.path.isfile(self.tabFilePath) size = 0 if exists: size = os.path.getsize(self.tabFilePath) if size > 0 and exists: self.loadTabs(self.tabFilePath) else: self.newTab() self.updatePageNames() self.checkArchiveTabFileSize()
def init_ui(self): # Builds GUI # Start with a status bar self.statusBar().showMessage("Welcome!") self.grid_layout = QGridLayout() # Build common menu options menubar = self.menuBar() # File Menu Items file_menu = menubar.addMenu('&File') open_logger2 = QAction(QIcon(os.path.join(module_directory,r'icons/logger2_48px.png')), '&Import CAN Logger 2', self) open_logger2.setShortcut('Ctrl+I') open_logger2.setStatusTip('Open a file from the NMFTA/TU CAN Logger 2') open_logger2.triggered.connect(self.open_open_logger2) file_menu.addAction(open_logger2) exit_action = QAction(QIcon(os.path.join(module_directory,r'icons/icons8_Close_Window_48px.png')), '&Quit', self) exit_action.setShortcut('Ctrl+Q') exit_action.setStatusTip('Exit the program.') exit_action.triggered.connect(self.confirm_quit) file_menu.addSeparator() file_menu.addAction(exit_action) #build the entries in the dockable tool bar file_toolbar = self.addToolBar("File") file_toolbar.addAction(exit_action) # RP1210 Menu Items self.rp1210_menu = menubar.addMenu('&RP1210') help_menu = menubar.addMenu('&Help') about = QAction(QIcon(os.path.join(module_directory,r'icons/icons8_Help_48px.png')), 'A&bout', self) about.setShortcut('F1') about.setStatusTip('Display a dialog box with information about the program.') about.triggered.connect(self.show_about_dialog) help_menu.addAction(about) help_toolbar = self.addToolBar("Help") help_toolbar.addAction(about) # Setup the network status windows for logging info_box = {} info_box_area = {} info_layout = {} info_box_area_layout = {} self.previous_count = {} self.status_icon = {} self.previous_count = {} self.message_count_label = {} self.message_rate_label = {} self.message_duration_label = {} for key in ["J1939","J1708"]: # Create the container widget info_box_area[key] = QScrollArea() info_box_area[key].setWidgetResizable(True) info_box_area[key].setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) bar_size = QSize(150,300) info_box_area[key].sizeHint() info_box[key] = QFrame(info_box_area[key]) info_box_area[key].setWidget(info_box[key]) info_box_area[key].setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) # create a layout strategy for the container info_layout[key] = QVBoxLayout() #set the layout so labels are at the top info_layout[key].setAlignment(Qt.AlignTop) #assign the layout strategy to the container info_box[key].setLayout(info_layout[key]) info_box_area_layout[key] = QVBoxLayout() info_box_area[key].setLayout(info_box_area_layout[key]) info_box_area_layout[key].addWidget(info_box[key]) #Add some labels and content self.status_icon[key] = QLabel("<html><img src='{}/icons/icons8_Unavailable_48px.png'><br>Network<br>Unavailable</html>".format(module_directory)) self.status_icon[key].setAlignment(Qt.AlignCenter) self.previous_count[key] = 0 self.message_count_label[key] = QLabel("Count: 0") self.message_count_label[key].setAlignment(Qt.AlignCenter) #self.message_duration = 0 self.message_duration_label[key] = QLabel("Duration: 0 sec.") self.message_duration_label[key].setAlignment(Qt.AlignCenter) #self.message_rate = 0 self.message_rate_label[key] = QLabel("Rate: 0 msg/sec") self.message_rate_label[key].setAlignment(Qt.AlignCenter) csv_save_button = QPushButton("Save as CSV") csv_save_button.setToolTip("Save all the {} Network messages to a comma separated values file.".format(key)) if key == ["J1939"]: csv_save_button.clicked.connect(self.save_j1939_csv) if key == ["J1708"]: csv_save_button.clicked.connect(self.save_j1708_csv) info_layout[key].addWidget(QLabel("<html><h3>{} Status</h3></html>".format(key))) info_layout[key].addWidget(self.status_icon[key]) info_layout[key].addWidget(self.message_count_label[key]) info_layout[key].addWidget(self.message_rate_label[key]) info_layout[key].addWidget(self.message_duration_label[key]) # Initialize tab screen self.tabs = QTabWidget() self.tabs.setTabShape(QTabWidget.Triangular) self.J1939 = J1939Tab(self, self.tabs) self.J1587 = J1587Tab(self, self.tabs) self.Components = ComponentInfoTab(self, self.tabs) self.grid_layout.addWidget(info_box_area["J1939"],0,0,1,1) self.grid_layout.addWidget(info_box_area["J1708"],1,0,1,1) self.grid_layout.addWidget(self.tabs,0,1,4,1) main_widget = QWidget() main_widget.setLayout(self.grid_layout) self.setCentralWidget(main_widget) self.show()
def __initialize_mainmenu(self): self.frames[0]["mainmenu"] = QFrame() self.objects[0]["mainmenu"] = {} self.objects[0]["mainmenu_memos"] = {} self.layouts[0]["mainmenu"] = QVBoxLayout() self.frames[0]["mainmenu"].setFixedWidth(400) self.__initialize_extended_menu() self.objects[0]["mainmenu"]["mainmenu_button"] = QPushButton( 'Main menu') self.objects[0]["mainmenu"]["mainmenu_button"].clicked.connect( self.__show_hide_extended_menu) self.layouts[0]["mainmenu"].addWidget( self.objects[0]["mainmenu"]["mainmenu_button"]) self.layouts[0]["mainmenu"].addWidget(self.frames[0]["extended_menu"]) self.layouts[0]["mainmenu"].addSpacing(25) self.objects[0]["mainmenu_memos_scroll"] = QScrollArea() self.frames[0]["mainmenu_memos"] = QFrame() self.objects[0]["mainmenu_memos_scroll"].setWidget( self.frames[0]["mainmenu_memos"]) self.objects[0]["mainmenu_memos_scroll"].ensureWidgetVisible( self.frames[0]["mainmenu_memos"]) self.objects[0]["mainmenu_memos_scroll"].setWidgetResizable(True) self.objects[0]["mainmenu_memos_scroll"].setAlignment(Qt.AlignTop) self.objects[0]["mainmenu_memos_scroll"].setFixedSize( self.__active_width-(self.__active_width-375), self.__active_height-300) self.objects[0]["mainmenu_memos_scroll"].setStyleSheet( 'QScrollArea { border: 0px;}') self.layouts[0]["mainmenu_memos"] = QVBoxLayout() self.layouts[0]["mainmenu_memos_outer"] = QVBoxLayout() self.layouts[0]["mainmenu_memos_outer"].addLayout( self.layouts[0]["mainmenu_memos"]) self.layouts[0]["mainmenu_memos_outer"].addStretch() self.frames[0]["mainmenu_memos"].setLayout( self.layouts[0]["mainmenu_memos_outer"]) self.layouts[0]["mainmenu"].addWidget( self.objects[0]["mainmenu_memos_scroll"]) self.layouts[0]["mainmenu"].addStretch() self.layouts[0]["mainmenu_buttons"] = QHBoxLayout() self.objects[0]["mainmenu"]["new_memo_button"] = QPushButton( 'New memo') self.objects[0]["mainmenu"]["new_memo_button"].clicked.connect( self.__new_memo) self.layouts[0]["mainmenu_buttons"].addWidget( self.objects[0]["mainmenu"]["new_memo_button"]) self.objects[0]["mainmenu"]["import_button"] = QPushButton( 'Import from') self.objects[0]["mainmenu"]["import_button"].clicked.connect( self.__import_from_web) self.layouts[0]["mainmenu_buttons"].addWidget( self.objects[0]["mainmenu"]["import_button"]) self.layouts[0]["mainmenu"].addLayout( self.layouts[0]["mainmenu_buttons"]) self.frames[0]["mainmenu"].setLayout(self.layouts[0]["mainmenu"])
def MAIN_VIEW(self, profile): self.comp = COMPONENTS() _id = int(profile["id"]) r = requests.get(url=f"{self.comp.APP_URL}/users/students/{_id}") self.profile = r.json() self.main_menu = self.menuBar() self.toolbar = QToolBar() self.file_menu = self.main_menu.addMenu("File") self.edit_menu = self.main_menu.addMenu("Edit") self.export = QAction(QIcon("./assets/icons/export_pdf.png"), "Export PDF", self) self.export.setShortcut("Ctrl+S") self.edit_action = QAction(QIcon("./assets/icons/edit_profile.png"), "Edit Student Details", self) self.exit_action = QAction(QIcon("./assets/icons/exit.png"), "Exit", self) self.exit_action.setShortcut("Ctrl+Q") self.file_menu.addAction(self.export) self.file_menu.addAction(self.exit_action) self.edit_menu.addAction(self.edit_action) self.export.triggered.connect(self._save_file) self.edit_action.triggered.connect(self._edit_screen) self.exit_action.triggered.connect(self.previous) self.toolbar = self.addToolBar("Toolbar") self.toolbar.addAction(self.exit_action) self.toolbar.addAction(self.edit_action) self.toolbar.addAction(self.export) main_widget = QWidget() self.vbox = QVBoxLayout() self.personal_details() self.contact_details() self.parent_detail() self.other_detail() main_widget.setLayout(self.vbox) scroll = QScrollArea() scroll.setWidget(main_widget) scroll.setWidgetResizable(True) self.setCentralWidget(scroll) self.super_layout.addWidget(self) self.super_layout.setCurrentWidget(self)
def __init__(self, config, querylist, mainwin): QSplitter.__init__(self, mainwin) self.config = config self.main_window = mainwin self.sql = querylist self.replayer = None self.db = Database.Database(self.config, sql=self.sql) filters_display = { "Heroes": True, "Sites": True, "Games": True, "Currencies": False, "Limits": True, "LimitSep": True, "LimitType": True, "Positions": True, "Type": True, "Seats": False, "SeatSep": False, "Dates": True, "Cards": True, "Groups": False, "GroupsAll": False, "Button1": True, "Button2": False } self.filters = Filters.Filters(self.db, display=filters_display) self.filters.registerButton1Name(_("Load Hands")) self.filters.registerButton1Callback(self.loadHands) self.filters.registerCardsCallback(self.filter_cards_cb) scroll = QScrollArea() scroll.setWidget(self.filters) self.handsFrame = QFrame() self.handsVBox = QVBoxLayout() self.handsFrame.setLayout(self.handsVBox) self.addWidget(scroll) self.addWidget(self.handsFrame) self.setStretchFactor(0, 0) self.setStretchFactor(1, 1) self.deck_instance = Deck.Deck(self.config, height=42, width=30) self.cardImages = self.init_card_images() # Dict of colnames and their column idx in the model/ListStore self.colnum = { 'Stakes': 0, 'Pos': 1, 'Street0': 2, 'Action0': 3, 'Street1-4': 4, 'Action1-4': 5, 'Won': 6, 'Bet': 7, 'Net': 8, 'Game': 9, 'HandId': 10, } self.view = QTableView() self.view.setSelectionBehavior(QTableView.SelectRows) self.handsVBox.addWidget(self.view) self.model = QStandardItemModel(0, len(self.colnum), self.view) self.filterModel = QSortFilterProxyModel() self.filterModel.setSourceModel(self.model) self.filterModel.setSortRole(Qt.UserRole) self.view.setModel(self.filterModel) self.view.verticalHeader().hide() self.model.setHorizontalHeaderLabels([ 'Stakes', 'Pos', 'Street0', 'Action0', 'Street1-4', 'Action1-4', 'Won', 'Bet', 'Net', 'Game', 'HandId' ]) self.view.doubleClicked.connect(self.row_activated) self.view.contextMenuEvent = self.contextMenu self.filterModel.rowsInserted.connect( lambda index, start, end: [self.view.resizeRowToContents(r) for r in xrange(start, end + 1)]) self.filterModel.filterAcceptsRow = lambda row, sourceParent: self.is_row_in_card_filter( row) self.view.resizeColumnsToContents() self.view.setSortingEnabled(True)
def initUI(self): self.controls = QWidget() self.controlsLayout = QVBoxLayout() # read json file and get jepg try: with open('e7dbherodata.json') as json_file: self.data = json.load(json_file) except: error_dialog = QtWidgets.QErrorMessage() error_dialog.showMessage("Missing e7assets.json file") error_dialog.exec_() self.userList = [] # list of characters, separated by star grade characters5 = ( 'Alencia', 'Ambitious Tywin', 'Apocalypse Ravi', 'Aramintha', 'Arbiter Vildred', 'Baal & Sezan', 'Baiken', 'Basar', 'Bellona', 'Blood Moon Haste', 'Briar Witch Iseria', 'Cecilia', 'Celine', 'Cerise', 'Cermia', 'Charles', 'Charlotte', 'Chloe', 'Choux', 'Dark Corvus', 'Desert Jewel Basar', 'Destina', 'Diene', 'Dizzy', 'Elena', 'Elphelt', 'Ervalen', 'Faithless Lidica', 'Fallen Cecilia', 'Flan', 'Haste', 'Holiday Yufine', 'Iseria', 'Judge Kise', 'Kawerik', 'Kayron', 'Ken', 'Kise', 'Krau', 'Landy', 'Last Rider Krau', 'Lidica', 'Lilias', 'Lilibet', 'Little Queen Charlotte', 'Ludwig', 'Luluca', 'Luna', 'Maid Chloe', 'Martial Artist Ken', 'Melissa', 'Mui', 'Operator Sigret', 'Pavel', 'Ravi', 'Ray', 'Remnant Violet', 'Roana', 'Ruele of Light', 'Sage Baal & Sezan', 'Seaside Bellona', 'Sez', 'Sigret', 'Silver Blade Aramintha', 'Sol', 'Specimen Sez', 'Specter Tenebria', 'Tamarinne', 'Tenebria', 'Top Model Luluca', 'Tywin', 'Vildred', 'Violet', 'Vivian', 'Yufine', 'Yuna', 'Zeno', 'Fairytale Tenebria', 'Mort') characters4 = ('Achates', 'Angelica', 'Armin', 'Assassin Cartuja', 'Assassin Cidd', 'Assassin Coli', 'Auxiliary Lots', 'Benevolent Romann', 'Blaze Dingo', 'Blood Blade Karin', 'Cartuja', 'Celestial Mercedes', 'Challenger Dominiel', 'Champion Zerato', 'Cidd', 'Clarissa', 'Coli', 'Corvus', 'Crescent Moon Rin', 'Crimson Armin', 'Crozet', 'Dingo', 'Dominiel', 'Fighter Maya', 'Free Spirit Tieria', 'Furious', 'General Purrgis', 'Guider Aither', 'Karin', 'Khawana', 'Khawazu', 'Kitty Clarissa', 'Kizuna AI', 'Leo', 'Lots', 'Maya', 'Mercedes', 'Purrgis', 'Rin', 'Roaming Warrior Leo', 'Romann', 'Rose', 'Schuri', 'Serila', 'Shadow Rose', 'Shooting Star Achates', 'Silk', 'Sinful Angelica', 'Surin', 'Tempest Surin', 'Troublemaker Crozet', 'Wanderer Silk', 'Watcher Schuri', 'Zerato') characters3 = ('Adlay', 'Adventurer Ras', 'Ainos', 'Ains', 'Aither', 'Alexa', 'All-Rounder Wanda', 'Angelic Montmorancy', 'Arowell', 'Azalea', 'Bask', 'Batisse', 'Butcher Corps Inquisitor', 'Captain Rikoris', 'Carmainerose', 'Carrot', 'Celeste', 'Chaos Inquisitor', 'Chaos Sect Ax', 'Church of Ilryos Axe', 'Commander Lorina', 'Doll Maker Pearlhorizon', 'Doris', 'Eaton', 'Elson', 'Enott', 'Falconer Kluri', 'Glenn', 'Gloomyrain', 'Godmother', 'Gunther', 'Hataan', 'Hazel', 'Helga', 'Hurado', 'Ian', 'Jecht', 'Jena', 'Judith', 'Kikirat v2', 'Kiris', 'Kluri', 'Lena', 'Lorina', 'Magic Scholar Doris', 'Mascot Hazel', 'Mercenary Helga', 'Mirsa', 'Mistychain', 'Montmorancy', 'Mucacha', 'Nemunas', 'Otillie', 'Pearlhorizon', 'Pyllis', 'Ras', 'Requiemroar', 'Researcher Carrot', 'Righteous Thief Roozid', 'Rikoris', 'Rima', 'Roozid', 'Sonia', 'Sven', 'Taranor Guard', 'Taranor Royal Guard', 'Tieria', 'Wanda', 'Zealot Carmainerose') charactersAll = characters5 + characters4 + characters3 self.widgets = [] for name in charactersAll: item = AddRemoveWidget(name) # attribute functions to each button item.button_add.clicked.connect( lambda _, name=name: self.addCharToList(name)) item.button_remove.clicked.connect( lambda _, name=name: self.removeCharFromList(name)) self.controlsLayout.addWidget(item) self.widgets.append(item) spacer = QSpacerItem(1, 1, QSizePolicy.Minimum, QSizePolicy.Expanding) self.controlsLayout.addItem(spacer) self.controls.setLayout(self.controlsLayout) self.setWindowTitle("E7 Ultimate Bravery") self.setGeometry(200, 200, 1024, 680) self.label1 = QtWidgets.QLabel(self) self.label1.setText("<h1>Epic 7 Roulette</h1>") self.label1.adjustSize() self.label1.move(10, 15) self.label2 = QtWidgets.QLabel(self) self.label2.setText("Add Characters to Roulette") self.label2.move(10, 55) self.label2.adjustSize() self.label3 = QtWidgets.QLabel(self) self.label3.setText("<h1>Team 1:</h1>") self.label3.adjustSize() self.label3.move(540, 60) self.label4 = QtWidgets.QLabel(self) self.label4.setText("") self.label4.move(540, 85) self.label5 = QtWidgets.QLabel(self) self.label5.setText("") self.label5.move(650, 85) self.label6 = QtWidgets.QLabel(self) self.label6.setText("") self.label6.move(760, 85) self.label7 = QtWidgets.QLabel(self) self.label7.setText("<h1>Team 2:</h1>") self.label7.adjustSize() self.label7.move(540, 200) self.label8 = QtWidgets.QLabel(self) self.label8.setText("") self.label8.move(540, 225) self.label9 = QtWidgets.QLabel(self) self.label9.setText("") self.label9.move(650, 225) self.label10 = QtWidgets.QLabel(self) self.label10.setText("") self.label10.move(760, 225) self.image = QImage() self.scroll = QScrollArea() self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll.setWidgetResizable(False) self.scroll.setWidget(self.controls) self.searchBar = QLineEdit() self.searchBar.adjustSize() self.searchBar.textChanged.connect(self.updateDisplay) self.completer = QCompleter(charactersAll) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.searchBar.setCompleter(self.completer) container = QWidget() containerLayout = QVBoxLayout() containerLayout.addWidget(self.searchBar) containerLayout.addWidget(self.scroll) containerLayout.setContentsMargins(10, 85, 0, 0) container.setLayout(containerLayout) container.setFixedSize(400, 600) self.setCentralWidget(container) self.b1 = QtWidgets.QPushButton(self) self.b1.setText("Roll") self.b1.setGeometry(10, 610, 390, 40) self.b1.clicked.connect(self.RandRoll) self.b2 = QtWidgets.QPushButton(self) self.b2.setText("Import") self.b2.setGeometry(250, 25, 100, 20) self.b2.clicked.connect(self.importChar) self.importStatus = QtWidgets.QLabel(self) self.importStatus.setText("") self.importStatus.move(360, 30)
def Show(self): if self.firstfit.isChecked(): firstfit = 1 bestfit = 0 worstfit = 0 elif self.bestfit.isChecked(): firstfit = 0 bestfit = 1 worstfit = 0 else: firstfit = 0 bestfit = 0 worstfit = 1 self.choice = 0 self.groupbox.hide() self.groupbox2.hide() self.groupbox3.hide() self.groupbox6.hide() self.groupbox4 = QGroupBox("De-allocate a process") self.groupbox4.setFont(QtGui.QFont("sanserif", 15)) vbox = QVBoxLayout() self.hbox.addWidget(self.groupbox4) self.pro = QRadioButton("Process") self.oldpro = QRadioButton("Old Process") self.ProcessName = QLabel("enter the process name ") self.ProcessNameLineText = QLineEdit(self) self.drawdeallocate = QPushButton("Draw after Deallocation") self.drawdeallocate.clicked.connect(self.DrawDeallocate) self.restartt = QPushButton("Restart") self.restartt.clicked.connect(self.restart) vbox.addWidget(self.pro) vbox.addWidget(self.oldpro) vbox.addWidget(self.ProcessName) vbox.addWidget(self.ProcessNameLineText) vbox.addWidget(self.drawdeallocate) vbox.addWidget(self.restartt) self.groupbox4.setLayout(vbox) self.groupbox7 = QGroupBox("AddProcess") self.groupbox7.setFont(QtGui.QFont("sanserif", 20)) vbox.addWidget(self.groupbox7) self.vbox3 = QVBoxLayout() self.numberOfSegments = QLabel("Number of segments:") self.numberOfSegments.setFont(QtGui.QFont("sanserif", 13)) self.vbox3.addWidget(self.numberOfSegments) self.numberOfSegmentsLineEdit = QLineEdit(self) self.numberOfSegmentsLineEdit.setFont(QtGui.QFont("sanserif", 13)) self.vbox3.addWidget(self.numberOfSegmentsLineEdit) self.buttonSegments = QPushButton("insert segments info", self) self.buttonSegments.clicked.connect(self.showSegmentsInfo) self.buttonSegments.setFont(QtGui.QFont("sanserif", 13)) self.vbox3.addWidget(self.buttonSegments) self.groupbox7.setLayout(self.vbox3) self.groupbox20 = QGroupBox("Method of Allocation") self.groupbox20.setFont(QtGui.QFont("sanserif", 15)) vbox.addWidget(self.groupbox20) self.vbox5 = QVBoxLayout() self.firstfit = QRadioButton("first fit") self.bestfit = QRadioButton("best fit") self.worstfit = QRadioButton("worst fit") self.vbox5.addWidget(self.firstfit) self.vbox5.addWidget(self.bestfit) self.vbox5.addWidget(self.worstfit) self.groupbox20.setLayout(self.vbox5) self.DrawingList = list() self.groupbox6 = QGroupBox("Drawing") self.groupbox6.setFont(QtGui.QFont("sanserif", 15)) self.grid = QVBoxLayout() self.grid.setSpacing(-10) totalMemory = int(self.totalMemorySize.text()) self.SortedHoles = sorted(self.holes, key=lambda x: x.startAddress, reverse=False) smallestHoles = sorted(self.holes, key=lambda x: x.size, reverse=False) largestHoles = sorted(self.holes, key=lambda x: x.size, reverse=True) self.failedProcess = list() if firstfit: sum = 1 done = 0 for i in self.proccess: lists = i.organizeProcess(self.SortedHoles, self.DrawingList, self.failedProcess) self.SortedHoles = lists[0] self.DrawingList = lists[1] if lists[2] == 1: self.failedProcess.append(i) for i in self.SortedHoles: self.DrawingList = i.organizeHole(self.DrawingList) self.SortedDrawingList = sorted(self.DrawingList, key=itemgetter('startaddress'), reverse=False) i = 0 x = 0 count = 1 while (i + x) < totalMemory: for j in self.SortedDrawingList: if j['startaddress'] == i + x and j['size'] > 0: if x != 0: process = { 'name': "oldprocess" + str(count), 'parentProcess': 'oldProcess', 'startaddress': i, 'size': x, 'oldprocess': 1, 'hole': 0, 'segment': 0, 'failed': 0, 'holeno': -1 } self.DrawingList.append(process) i = i + x + j['size'] done = 1 count = count + 1 break else: i = i + x + j['size'] done = 1 break else: done = 0 if done == 1: x = 0 else: x = x + 1 process = { 'name': "oldprocess" + str(count), 'parentProcess': 'oldProcess', 'startaddress': i, 'size': x, 'oldprocess': 1, 'hole': 0, 'segment': 0, 'failed': 0, 'holeno': -1 } self.DrawingList.append(process) self.SortedDrawingList = sorted(self.DrawingList, key=itemgetter('startaddress'), reverse=False) while len(self.failedProcess) > 0: buttonReply = QMessageBox.question( self, "System", self.failedProcess[0].name + " hasn't found a place in memory", QMessageBox.Ok) rest = self.failedProcess[0].removeProcess( self.SortedDrawingList) self.SortedDrawingList = rest[0] self.SortedHoles = rest[1] self.failedProcess.pop(0) elif bestfit: sum = 1 done = 0 for i in self.proccess: lists = i.organizeProcess(smallestHoles, self.DrawingList, self.failedProcess) smallestHoles = sorted(lists[0], key=lambda x: x.size, reverse=False) self.DrawingList = lists[1] if lists[2] == 1: self.failedProcess.append(i) for i in smallestHoles: self.DrawingList = i.organizeHole(self.DrawingList) self.SortedDrawingList = sorted(self.DrawingList, key=itemgetter('startaddress'), reverse=False) i = 0 x = 0 count = 1 while (i + x) < totalMemory: for j in self.SortedDrawingList: if j['startaddress'] == i + x and j['size'] > 0: if x != 0: process = { 'name': "oldprocess" + str(count), 'parentProcess': 'oldProcess', 'startaddress': i, 'size': x, 'oldprocess': 1, 'hole': 0, 'segment': 0, 'failed': 0, 'holeno': -1 } self.DrawingList.append(process) i = i + x + j['size'] done = 1 count = count + 1 break else: i = i + x + j['size'] done = 1 break else: done = 0 if done == 1: x = 0 else: x = x + 1 process = { 'name': "oldprocess" + str(count), 'parentProcess': 'oldProcess', 'startaddress': i, 'size': x, 'oldprocess': 1, 'hole': 0, 'segment': 0, 'failed': 0, 'holeno': -1 } self.DrawingList.append(process) self.SortedDrawingList = sorted(self.DrawingList, key=itemgetter('startaddress'), reverse=False) while len(self.failedProcess) > 0: buttonReply = QMessageBox.question( self, "System", self.failedProcess[0].name + " hasn't found a place in memory", QMessageBox.Ok) rest = self.failedProcess[0].removeProcess( self.SortedDrawingList) self.SortedDrawingList = rest[0] self.SortedHoles = rest[1] self.failedProcess.pop(0) elif worstfit: sum = 1 done = 0 for i in self.proccess: lists = i.organizeProcess(largestHoles, self.DrawingList, self.failedProcess) largestHoles = sorted(lists[0], key=lambda x: x.size, reverse=True) self.DrawingList = lists[1] if lists[2] == 1: self.failedProcess.append(i) for i in largestHoles: self.DrawingList = i.organizeHole(self.DrawingList) self.SortedDrawingList = sorted(self.DrawingList, key=itemgetter('startaddress'), reverse=False) i = 0 x = 0 count = 1 while (i + x) < totalMemory: for j in self.SortedDrawingList: if j['startaddress'] == i + x and j['size'] > 0: if x != 0: process = { 'name': "oldprocess" + str(count), 'parentProcess': 'oldProcess', 'startaddress': i, 'size': x, 'oldprocess': 1, 'hole': 0, 'segment': 0, 'failed': 0, 'holeno': -1 } self.DrawingList.append(process) i = i + x + j['size'] done = 1 count = count + 1 break else: i = i + x + j['size'] done = 1 break else: done = 0 if done == 1: x = 0 else: x = x + 1 process = { 'name': "oldprocess" + str(count), 'parentProcess': 'oldProcess', 'startaddress': i, 'size': x, 'oldprocess': 1, 'hole': 0, 'segment': 0, 'failed': 0, 'holeno': -1 } self.DrawingList.append(process) self.SortedDrawingList = sorted(self.DrawingList, key=itemgetter('startaddress'), reverse=False) while len(self.failedProcess) > 0: buttonReply = QMessageBox.question( self, "System", self.failedProcess[0].name + " hasn't found a place in memory", QMessageBox.Ok) rest = self.failedProcess[0].removeProcess( self.SortedDrawingList) self.SortedDrawingList = rest[0] self.SortedHoles = rest[1] self.failedProcess.pop(0) self.Draww() self.groupbox6.setLayout(self.grid) self.scroll2 = QScrollArea() self.scroll2.setWidget(self.groupbox6) self.scroll2.setWidgetResizable(True) self.scroll2.setFixedWidth(400) self.scroll2.setFixedHeight(700) self.hbox.addWidget(self.scroll2)
def __init__(self, parent): QWidget.__init__(self) self.CntrPane = parent self.PaneIdx = 0 # ------- HdrFont = QFont() HdrFont.setFamily("Times New Roman") HdrFont.setPointSize(18) HdrFont.setBold(True) HdrFont.setWeight(75) # -------NON SI VEDE! -> lblHedr = QLabel('Parenting Stress Index (P.S.I.)') lblHedr.setFont(HdrFont) lblHedr.setFixedWidth(320) # ------- hbxHedr = QHBoxLayout() hbxHedr.addStretch(1) hbxHedr.addWidget(lblHedr) hbxHedr.addStretch(1) # ------- lblNomePsi = QLabel('Nome del minore:') self.lneNomePsi = QLineEdit() self.lneNomePsi.setFixedWidth(150) # ------- lblCognomePsi = QLabel('Cognome del minore:') self.lneCognomePsi = QLineEdit() self.lneCognomePsi.setFixedWidth(150) # ------- lblAnniPsi = QLabel('Anni compiuti:') self.spbAnniPsi = QSpinBox() self.spbAnniPsi.setFixedWidth(50) # ------- LftFrmBox = QFormLayout() LftFrmBox.addRow(lblNomePsi, self.lneNomePsi) LftFrmBox.addRow(lblCognomePsi, self.lneCognomePsi) LftFrmBox.addRow(lblAnniPsi, self.spbAnniPsi) # ------- LftVBox = QVBoxLayout() LftVBox.addStretch(1) LftVBox.addWidget(lblHedr) LftVBox.addLayout(LftFrmBox) LftVBox.addStretch(1) # ------- self.PsiItemList = PsiItems(self) # ------- self.scaPsiItems = QScrollArea() self.scaPsiItems.resize(170, 400) self.scaPsiItems.setMaximumWidth(165) self.scaPsiItems.setSizeIncrement(0, 0) self.scaPsiItems.setWidgetResizable(True) self.scaPsiItems.setWidget(self.PsiItemList) # ------- self.btnAvantiPsi = QPushButton('Avanti') self.btnAvantiPsi.clicked.connect(self.ProcessPsiData) # ------- self.btnExitPsi = QPushButton('Exit') self.btnExitPsi.clicked.connect(self.ExitPsiData) # ------- HBox2 = QHBoxLayout() HBox2.addWidget(self.btnAvantiPsi) HBox2.addWidget(QLabel(' ')) HBox2.addWidget(self.btnExitPsi) HBox2.addStretch(1) # ------- RitVBox = QVBoxLayout() RitVBox.addWidget(self.scaPsiItems) RitVBox.addLayout(HBox2) # ------- FullHBox = QHBoxLayout() FullHBox.addLayout(LftVBox) FullHBox.addStretch(1) FullHBox.addLayout(RitVBox) # ------- self.setLayout(FullHBox)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) sp = QSizePolicy() sp.setHorizontalPolicy(QSizePolicy.Expanding) sp.setVerticalPolicy(QSizePolicy.Expanding) sp.setVerticalStretch(1) wb_city_data = load_workbook(filename=r'ДСТУ-Н Б В.1.1-27_2010.xlsx', read_only=True, data_only=True) self.__ws_city_I_ser_m_sj = wb_city_data['Лист1'] self.__ws_city_t_z = wb_city_data['Т2. Температура зовн. пов.'] self.__cityChoice = QComboBox() self.__cityChoice.addItems(c[0].value for c in self.__ws_city_I_ser_m_sj['A6':'A605'] if c[0].value) self.__q_0Edit = KwNumberEdit(.5) self.__V_budEdit = KwNumberEdit(480) self.__NEdit = QSpinBox() self.__NEdit.setRange(1, 999) self.__NEdit.setSuffix(' чол') self.__NEdit.setValue(6) self.__t_gvEdit = QSpinBox() self.__t_gvEdit.setRange(25, 70) self.__t_gvEdit.setSingleStep(5) self.__t_gvEdit.setSuffix(' \N{DEGREE CELSIUS}') self.__t_gvEdit.setValue(45) self.__a_gvEdit = QSpinBox() self.__a_gvEdit.setRange(15, 99) self.__a_gvEdit.setSuffix(' л/добу') self.__a_gvEdit.setValue(35) self.__f_zEdit = KwNumberEdit(.8) self.__varthetaEdit = KwNumberEdit(1.7) self.__S_0Edit = KwNumberEdit(1.723) self.__F_rEdit = KwNumberEdit(1) self.__eta_0Edit = KwNumberEdit(0.813) self.__ULEdit = KwNumberEdit(4.6) self.__aEdit = KwNumberEdit(.007) self.__bEdit = KwNumberEdit(1.27E-5) self.__c_paEdit = KwNumberEdit(3.16) self.__P_tpEdit = KwNumberEdit(14.1) self.__epsilon_tpEdit = KwNumberEdit(5.5) self.__epsilon_elEdit = KwNumberEdit(.88) self.__P_elEdit = KwNumberEdit(2.6) self.__t_co_1Edit = QSpinBox() self.__t_co_1Edit.setRange(25, 70) self.__t_co_1Edit.setSingleStep(5) self.__t_co_1Edit.setSuffix(' \N{DEGREE CELSIUS}') self.__t_co_1Edit.setValue(35) self.__t_co_2Edit = QSpinBox() self.__t_co_2Edit.setRange(20, 60) self.__t_co_2Edit.setSingleStep(5) self.__t_co_2Edit.setSuffix(' \N{DEGREE CELSIUS}') self.__t_co_2Edit.setValue(30) self.__eta_KEdit = KwNumberEdit(.93) self.__Q_n_rEdit = KwNumberEdit(35600) self.__c_gazEdit = KwNumberEdit(.55) self.__c_elEdit = KwNumberEdit(.25) self.__q_gruEdit = KwNumberEdit(21) self.__d_gruEdit = QSpinBox() self.__d_gruEdit.setRange(5, 99) self.__d_gruEdit.setSuffix(' мм') self.__d_gruEdit.setValue(25) self.__l_0_gruEdit = KwNumberEdit(1.7) calcButton = QPushButton('Визначити') calcButton.setObjectName('calcButton') self.__outputConsoleBrowser = KwConsoleBrowser(setup={'font': {'name': QFont('Hack').family(), 'size': 8}, 'color': 'rgb(255, 255, 255)', 'background_color': 'rgba(0, 0, 0, 218)', 'line_wrap': False}) self.__outputConsoleBrowser.setSizePolicy(sp) graphWidget = QMainWindow() graphWidget.setMinimumWidth(380) self.__graphCanvas = self.__createFigureCanvas() graphWidget.addToolBar(Qt.TopToolBarArea, NavigationToolbar(self.__graphCanvas, self)) graphWidget.setCentralWidget(self.__graphCanvas) cityLayout = QFormLayout() cityLayout.addRow('Місто:', self.__cityChoice) soGroup = QGroupBox('Для системи опалення (СО):') soInputLayout = QFormLayout(soGroup) soInputLayout.addRow('Питома потужність тепловтрат, q<sub>0</sub>, ' 'Вт/(м<sup>3</sup>\N{MIDDLE DOT}\N{DEGREE CELSIUS}):', self.__q_0Edit) soInputLayout.addRow("Об'єм будинку по зовнішніх обмірах, V<sub>буд</sub>, " "м<sup>3</sup>:", self.__V_budEdit) sgvGroup = QGroupBox(u'Для системи гарячого водопостачання (СГК):') sgvInputLayout = QFormLayout(sgvGroup) sgvInputLayout.addRow('Кількість мешканців у будинку, N:', self.__NEdit) sgvInputLayout.addRow('Температура гарячої води, t<sub>гв</sub>:', self.__t_gvEdit) sgvInputLayout.addRow('Добова витрата гарячої води на 1 особу, a<sub>гв</sub>:', self.__a_gvEdit) sgkGroup = QGroupBox('Для системи геліоколекторів (СГК):') sgkInputLayout = QFormLayout(sgkGroup) sgkInputLayout.addRow('Ступінь заміщення тепловтрат СГВ, f<sub>з</sub>:', self.__f_zEdit) sgkInputLayout.addRow('Параметр, \u03D1:', self.__varthetaEdit) sgkInputLayout.addRow('Площа 1-го геліоколектора, S<sub>0</sub>, м<sup>2</sup>:', self.__S_0Edit) sgkInputLayout.addRow('F<sub>r</sub>:', self.__F_rEdit) sgkInputLayout.addRow('Оптичний ККД, \N{GREEK SMALL LETTER ETA}:', self.__eta_0Edit) sgkInputLayout.addRow('Коефіцієнт тепловтрат, UL, Вт/(м<sup>2</sup>)' '\N{MIDDLE DOT}\N{DEGREE CELSIUS}):', self.__ULEdit) sgkInputLayout.addRow('a:', self.__aEdit) sgkInputLayout.addRow('b:', self.__bEdit) sgkInputLayout.addRow('c<sub>pa</sub>, кДж/(кг\N{MIDDLE DOT}\N{DEGREE CELSIUS}):', self.__c_paEdit) tpGroup = QGroupBox('Для теплової помпи (ТП):') tpInputLayout = QFormLayout(tpGroup) tpInputLayout.addRow('Теплова потужність, P<sub>тп</sub>, кВт:', self.__P_tpEdit) tpInputLayout.addRow('Тепловий к.к.д, \N{GREEK SMALL LETTER EPSILON}' '<sub>тп</sub>', self.__epsilon_tpEdit) tpInputLayout.addRow('Електричний к.к.д., \N{GREEK SMALL LETTER EPSILON}' '<sub>ел</sub>:', self.__epsilon_elEdit) tpInputLayout.addRow('Електрична потужність, P<sub>ел</sub>, кВт:', self.__P_elEdit) tpInputLayout.addRow('Т-ра нагрітої води для СО підлоги, t<sub>co 1</sub>:', self.__t_co_1Edit) tpInputLayout.addRow('Т-ра охолодженої води для СО підлоги, t<sub>co 2</sub>:', self.__t_co_2Edit) tpInputLayout.addRow('К.к.д. згоряння палива, eta_K:', self.__eta_KEdit) tpInputLayout.addRow('Нижча теплота згоряння палива, Q<sub>n r</sub>, кДж/м<sup>3</sup>:', self.__Q_n_rEdit) tpInputLayout.addRow('Вартість 1 м<sup>3</sup> газу, c<sub>газ</sub>, грн/м<sup>3</sup>:', self.__c_gazEdit) tpInputLayout.addRow('Вартість 1 кВт\N{MIDDLE DOT}год, c<sub>ел</sub>, ' 'грн/м<sup>3</sup>:', self.__c_elEdit) gruGroup = QGroupBox('Для ґрунту і контуру СО підлоги:') gruInputEdit = QFormLayout(gruGroup) gruInputEdit.addRow('Питома тепловіддача ґрунту, q<sub>ґр</sub>, ' 'Вт/м<sup>2</sup>:', self.__q_gruEdit) gruInputEdit.addRow('Внутрішній діаметр, d, мм:', self.__d_gruEdit) gruInputEdit.addRow('Питома довжина тепловідбору, l<sub>0</sub>, ' 'м/м<sup>2</sup>:', self.__l_0_gruEdit) inputScrollArea = QScrollArea() inputScrollArea.setWidgetResizable(True) inputScrollArea.setSizePolicy(sp) inputDataPanel = QWidget() inputDataLayout = QVBoxLayout(inputDataPanel) inputDataLayout.addLayout(cityLayout) inputDataLayout.addWidget(soGroup) inputDataLayout.addWidget(sgvGroup) inputDataLayout.addWidget(sgkGroup) inputDataLayout.addWidget(tpGroup) inputDataLayout.addWidget(gruGroup) inputScrollArea.setWidget(inputDataPanel) inputWidget = QWidget() inputLayout = QFormLayout(inputWidget) #inputLayout.setContentsMargins(0, 0, 0, 0) inputLayout.setRowWrapPolicy(QFormLayout.WrapAllRows) inputLayout.addRow('Вхідні дані:', inputScrollArea) inputLayout.addWidget(calcButton) consoleViewWidget = QWidget() consoleViewLayout = QFormLayout(consoleViewWidget) consoleViewLayout.setRowWrapPolicy(QFormLayout.WrapAllRows) consoleViewLayout.addRow(u'Результати:', self.__outputConsoleBrowser) contentSplitter = QSplitter(Qt.Horizontal) contentSplitter.setStretchFactor(0, 1) contentSplitter.setStretchFactor(1, 0) contentSplitter.setSizes([350, 380]) contentSplitter.setChildrenCollapsible(False) ioSplitter = QSplitter(Qt.Vertical) ioSplitter.setStretchFactor(0, 1) ioSplitter.setStretchFactor(1, 0) ioSplitter.setSizes([200, 320]) ioSplitter.setChildrenCollapsible(False) ioSplitter.setMinimumWidth(380) ioSplitter.addWidget(inputWidget) ioSplitter.addWidget(consoleViewWidget) contentSplitter.addWidget(ioSplitter) contentSplitter.addWidget(graphWidget) self.setCentralWidget(contentSplitter) self.resize(1200, 640) # <<< for inputValueWidget in inputWidget.findChildren((QAbstractSpinBox, KwNumberEdit)): inputValueWidget.valueChanged.connect(self._reset_output_data) for inputValueWidget in inputWidget.findChildren(QComboBox): inputValueWidget.activated.connect(self._reset_output_data) calcButton.clicked.connect(self.calc_script)
def initUI(self): # 查询条件区域 self.layout_condition_h = QHBoxLayout() self.layout_condition_h.setAlignment(Qt.AlignLeft) keyLabel = QLabel('关键字:') self.keyText = QLineEdit() self.keyText.setPlaceholderText('请输入关键字') # self.keyText.setFixedWidth(200) query = QPushButton('查询') siteLabel = QLabel('吉他谱网站:') self.sitesCombo = ComboCheckBox(list(self.sites.keys())) # self.sitesCombo.setMinimumWidth(200) self.sitesCombo.selectAll(2) query.clicked.connect(self.query) reset = QPushButton('重置') reset.clicked.connect(self.reset) self.layout_condition_h.addWidget(siteLabel) self.layout_condition_h.setStretch(0, 1) self.layout_condition_h.addWidget(self.sitesCombo) self.layout_condition_h.setStretch(1, 3) self.layout_condition_h.addWidget(keyLabel) self.layout_condition_h.setStretch(2, 1) self.layout_condition_h.addWidget(self.keyText) self.layout_condition_h.setStretch(3, 6) self.layout_condition_h.addWidget(query) self.layout_condition_h.setStretch(4, 1) self.layout_condition_h.addWidget(reset) self.layout_condition_h.setStretch(5, 1) self.layout_condition_h.addWidget(QWidget()) self.layout_condition_h.setStretch(6, 4) # 内容区域 self.layout_content_h = QHBoxLayout() self.layout_content_h.setAlignment(Qt.AlignCenter) # 内容区域-左-列表 self.tabList = TabList() # 滚动条# self.scroll = QScrollArea() self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.scroll.setWidgetResizable(True) self.scroll.setAutoFillBackground(True) self.scroll.setWidget(self.tabList) # 内容区域-右-图像 self.layout_content_pic_h = QHBoxLayout() self.layout_content_h.addWidget(self.scroll) self.layout_content_h.setStretch(0, 1) self.layout_content_h.addLayout(self.layout_content_pic_h) self.layout_content_h.setStretch(1, 2) self.vbox = QVBoxLayout() self.vbox.setAlignment(Qt.AlignLeft) self.vbox.setStretch(0, 1) self.vbox.addLayout(self.layout_condition_h) self.vbox.setStretch(1, 30) self.vbox.addLayout(self.layout_content_h) # 图片区域 self.picViewer = PicViewer() # 滚动条# self.picScroll = PicScrool() self.picScroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.picScroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.picScroll.setWidgetResizable(True) self.picScroll.setAutoFillBackground(True) self.picScroll.setAlignment(Qt.AlignCenter) self.picScroll.setWidget(self.picViewer) self.picScroll.zoomSignal.connect(self.zoomPic) self.layout_content_pic_h.addWidget(self.picScroll) self.setLayout(self.vbox)
def __init__(self, engine): super().__init__() self.setupUi(self) self._engine = engine machines = { plugin.name: _(plugin.name) for plugin in registry.list_plugins('machine') } mappings = ( # i18n: Widget: “ConfigWindow”. (_('Interface'), ( ConfigOption( _('Start minimized:'), 'start_minimized', BooleanOption, _('Minimize the main window to systray on startup.')), ConfigOption(_('Show paper tape:'), 'show_stroke_display', BooleanOption, _('Open the paper tape on startup.')), ConfigOption(_('Show suggestions:'), 'show_suggestions_display', BooleanOption, _('Open the suggestions dialog on startup.')), ConfigOption( _('Add translation dialog opacity:'), 'translation_frame_opacity', partial(IntOption, maximum=100, minimum=0), _('Set the translation dialog opacity:\n' '- 0 makes the dialog invisible\n' '- 100 is fully opaque')), ConfigOption( _('Dictionaries display order:'), 'classic_dictionaries_display_order', partial(BooleanAsDualChoiceOption, _('top-down'), _('bottom-up')), _('Set the display order for dictionaries:\n' '- top-down: match the search order; highest priority first\n' '- bottom-up: reverse search order; lowest priority first\n' )), )), # i18n: Widget: “ConfigWindow”. (_('Logging'), ( ConfigOption( _('Log file:'), 'log_file_name', partial(FileOption, _('Select a log file'), _('Log files (*.log)')), _('File to use for logging strokes/translations.')), ConfigOption(_('Log strokes:'), 'enable_stroke_logging', BooleanOption, _('Save strokes to the logfile.')), ConfigOption(_('Log translations:'), 'enable_translation_logging', BooleanOption, _('Save translations to the logfile.')), )), # i18n: Widget: “ConfigWindow”. (_('Machine'), ( ConfigOption( _('Machine:'), 'machine_type', partial(ChoiceOption, choices=machines), dependents=( ('machine_specific_options', self._update_machine_options), ('system_keymap', lambda v: self._update_keymap(machine_type=v)), )), ConfigOption(_('Options:'), 'machine_specific_options', self._machine_option), ConfigOption(_('Keymap:'), 'system_keymap', KeymapOption), )), # i18n: Widget: “ConfigWindow”. (_('Output'), ( ConfigOption(_('Enable at start:'), 'auto_start', BooleanOption, _('Enable output on startup.')), ConfigOption( _('Start attached:'), 'start_attached', BooleanOption, _('Disable preceding space on first output.\n' '\n' 'This option is only applicable when spaces are placed before.' )), ConfigOption(_('Start capitalized:'), 'start_capitalized', BooleanOption, _('Capitalize the first word.')), ConfigOption( _('Space placement:'), 'space_placement', partial(ChoiceOption, choices={ 'Before Output': _('Before Output'), 'After Output': _('After Output'), }), _('Set automatic space placement: before or after each word.' )), ConfigOption( _('Undo levels:'), 'undo_levels', partial(IntOption, maximum=10000, minimum=MINIMUM_UNDO_LEVELS), _('Set how many preceding strokes can be undone.\n' '\n' 'Note: the effective value will take into account the\n' 'dictionaries entry with the maximum number of strokes.') ), )), # i18n: Widget: “ConfigWindow”. (_('Plugins'), (ConfigOption( _('Extension:'), 'enabled_extensions', partial(MultipleChoicesOption, choices={ plugin.name: plugin.name for plugin in registry.list_plugins('extension') }, labels=(_('Name'), _('Enabled'))), _('Configure enabled plugin extensions.')), )), # i18n: Widget: “ConfigWindow”. (_('System'), (ConfigOption( _('System:'), 'system_name', partial(ChoiceOption, choices={ plugin.name: plugin.name for plugin in registry.list_plugins('system') }), dependents=( ('system_keymap', lambda v: self._update_keymap(system_name=v)), )), )), ) # Only keep supported options, to avoid messing with things like # dictionaries, that are handled by another (possibly concurrent) # dialog. self._supported_options = set() for section, option_list in mappings: self._supported_options.update(option.option_name for option in option_list) self._update_config() # Create and fill tabs. option_by_name = {} for section, option_list in mappings: layout = QFormLayout() for option in option_list: option_by_name[option.option_name] = option option.layout = layout option.widget = self._create_option_widget(option) option.label = QLabel(option.display_name) option.label.setToolTip(option.help_text) option.label.setBuddy(option.widget) layout.addRow(option.label, option.widget) frame = QFrame() frame.setLayout(layout) frame.setAccessibleName(section) frame.setFocusProxy(option_list[0].widget) scroll_area = QScrollArea() scroll_area.setWidgetResizable(True) scroll_area.setWidget(frame) scroll_area.setFocusProxy(frame) self.tabs.addTab(scroll_area, section) # Update dependents. for option in option_by_name.values(): option.dependents = [ (option_by_name[option_name], update_fn) for option_name, update_fn in option.dependents ] self.buttons.button(QDialogButtonBox.Ok).clicked.connect(self.on_apply) self.buttons.button(QDialogButtonBox.Apply).clicked.connect( self.on_apply) self.tabs.currentWidget().setFocus() self.restore_state() self.finished.connect(self.save_state)
__Copyright__ = 'Copyright (c) 2018 Irony' __Version__ = 1.0 class Window(QWidget): def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) self.setAttribute(Qt.WA_StyledBackground, True) self.setStyleSheet('Window{background:rgb(241,242,246);}') layout = QVBoxLayout(self) colors = Colors.allColors() for color in colors: widget = ButtonGroup(self) for i in range(3): c = color() btn = Button(c.name() + str(i), widget) btn.Color = c widget.addButton(btn) layout.addWidget(widget) if __name__ == "__main__": app = QApplication(sys.argv) window = QScrollArea() window.setWidgetResizable(True) window.setWidget(Window()) window.show() sys.exit(app.exec_())
def init_widgets(self): mainWindow = RememberedMainWindow() self.janus.widgets["mainwindow"] = mainWindow mainWindow.setWindowTitle(self.applicationName()) central_widget = QWidget(mainWindow) mainLayout = QVBoxLayout(central_widget) mainWindow.setCentralWidget(central_widget) self.janus.widgets["mainWindowlayout"] = mainLayout # # setup main splitter # splitter = QSplitter(central_widget) # # left side camera stuff # cameraSceneWidget = QWidget(splitter) cameraSceneLayout = QVBoxLayout(cameraSceneWidget) cameraSceneLayout.setContentsMargins(6, 0, 6, 0) onaxis = self.janus.devices["onaxis_camera"] axis_controller = self.janus.controllers["grid_axis_controller"] grid = self.janus.controllers["grid"] chip_registry = self.janus.controllers["chip_registry"] grid_widget = GridWidget(parent=cameraSceneWidget, grid_controller=grid, camera=onaxis, axis_controller=axis_controller, chip_registry=chip_registry) self.janus.widgets["gridWidget"] = grid_widget gridToolbar = GridToolBar(cameraSceneWidget, grid_widget) self.janus.widgets["toolBar"] = gridToolbar cameraSceneLayout.addWidget(gridToolbar.widget) cameraSceneLayout.addWidget(grid_widget) cameraSceneWidget.setLayout(cameraSceneLayout) # # Right Widget and layout for the controls # controlsScrollArea = QScrollArea(splitter) controlsScrollArea.setWidgetResizable(True) scrollAreaWidget = QWidget() scrollAreaLAyout = QVBoxLayout(scrollAreaWidget) cameraControls = CameraControls( parent=scrollAreaWidget, device=self.janus.devices["onaxis_camera"]) self.janus.widgets["cameraControls"] = cameraControls scrollAreaLAyout.addWidget(cameraControls.widget) # grid controls gridControls = GridControls( parent=scrollAreaWidget, grid_controller=self.janus.controllers["grid"], chip_registry=self.janus.controllers["chip_registry"]) self.janus.widgets["gridControls"] = gridControls scrollAreaLAyout.addWidget(gridControls.widget) # auto/continous focus controls focusControls = AutoFocusControls( focus_controller=self.janus.controllers["continuous_focus"], axis_controller=axis_controller, parent=scrollAreaWidget) self.janus.widgets["focusControls"] = focusControls scrollAreaLAyout.addWidget(focusControls.widget) # scan controls raw_tango_devices = { "linear_scan_device": self.janus.devices["linear_scan_device"], #"pilc_shutter_device": self.janus.devices["rr_pilc_device"] } scanControls = ScanControls( parent=scrollAreaWidget, grid_controller=self.janus.controllers["grid"], grid_axis_controller=self.janus. controllers["grid_axis_controller"], raw_tango_devices=raw_tango_devices) self.janus.widgets["scanControls"] = scanControls scrollAreaLAyout.addWidget(scanControls.widget) # motorcontrols controls #motorControls = MotorControls(parent=scrollAreaWidget) #self.janus.widgets["motorControls"] = motorControls #scrollAreaLAyout.addWidget(motorControls.widget) # beamprofile controls beamProfile = BeamProfile(parent=scrollAreaWidget) self.janus.widgets["beamProfile"] = beamProfile scrollAreaLAyout.addWidget(beamProfile.widget) # log console logView = Log(parent=scrollAreaWidget, handler=self.janus.utils["logHandler"]) self.janus.widgets["logView"] = logView scrollAreaLAyout.addWidget(logView.widget) # all the bars! #self.janus.widgets["menuBar"] = MainMenuBar(mainWindow) self.janus.widgets["statusBar"] = StatusBar(mainWindow) controlsScrollArea.setWidget(scrollAreaWidget) splitter.addWidget(cameraSceneWidget) splitter.addWidget(controlsScrollArea) splitter.setCollapsible(0, False) splitter.setCollapsible(1, False) splitter.setStretchFactor(0, 250) splitter.setStretchFactor(1, 150) mainLayout.addWidget(splitter)
def setupUI(self): self.setWindowIcon(Hariku_Style.getIcon()) self.centralwidget = QWidget(self) self.setFocus() self.gridLayout = QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.topcenter_layout = QHBoxLayout() spacerItem = QSpacerItem(25, 20, QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.topcenter_layout.addItem(spacerItem) self.monthFilter = QDateEdit(self.centralwidget) self.monthFilter.setCurrentSection(QDateTimeEdit.MonthSection) self.monthFilter.setButtonSymbols(QSpinBox.NoButtons) self.monthFilter.setDate(datetime.now()) self.monthFilter.setDisplayFormat("MMMM/yyyy") self.monthFilter.setFont(Hariku_Style.get_font(10)) self.monthFilter.setStyleSheet(Hariku_Style.get_dateedit_stylesheet()) self.monthFilter.dateChanged.connect(self.filterDiaryByMonth) self.topcenter_layout.addWidget(self.monthFilter) self.showAllBtn = QPushButton("Remove Filter", self.centralwidget) self.showAllBtn.setFont(Hariku_Style.get_font(8)) self.showAllBtn.clicked.connect(self.getDiaries) self.showAllBtn.setStyleSheet( Hariku_Style.get_moodBtn_stylesheet("rgb(38, 160, 173)", "rgb(8, 102, 112)")) self.topcenter_layout.addWidget(self.showAllBtn) spacerItem1 = QSpacerItem(25, 20, QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.topcenter_layout.addItem(spacerItem1) self.gridLayout.addLayout(self.topcenter_layout, 1, 0, 1, 1) self.bottomLayout = QHBoxLayout() spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.bottomLayout.addItem(spacerItem2) self.createBtn = QPushButton("+ Add New Diary", self.centralwidget) self.createBtn.setFont(Hariku_Style.get_font(10)) self.createBtn.clicked.connect(self.addNewDiary) self.createBtn.setStyleSheet( Hariku_Style.get_moodBtn_stylesheet("rgb(40, 186, 130)", "rgb(207, 207, 188)")) self.bottomLayout.addWidget(self.createBtn) self.gridLayout.addLayout(self.bottomLayout, 4, 0, 1, 1) self.contentScrollArea = QScrollArea(self.centralwidget) self.contentScrollArea.setEnabled(True) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.contentScrollArea.sizePolicy().hasHeightForWidth()) self.contentScrollArea.setSizePolicy(sizePolicy) self.contentScrollArea.setStyleSheet( Hariku_Style.get_scrollarea_stylesheet()) self.contentScrollArea.setWidgetResizable(True) self.contentScrollArea.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 487, 321)) self.scrollAreaLayout = QVBoxLayout(self.scrollAreaWidgetContents) self.getDiaries() self.contentScrollArea.setWidget(self.scrollAreaWidgetContents) self.gridLayout.addWidget(self.contentScrollArea, 2, 0, 1, 1) self.judul = QLabel("\nWelcome Home:)\n", self) self.judul.setFont(Hariku_Style.get_font(18)) self.judul.setAlignment(QtCore.Qt.AlignCenter) self.gridLayout.addWidget(self.judul, 0, 0, 1, 1) self.setCentralWidget(self.centralwidget)