def __init__(self): super(Window, self).__init__() box = QBoxLayout(QBoxLayout.LeftToRight, self) self.resize(1200, 800) def canvas_on_close_handler(_1, _2): self.close() _context.canvas.set_on_close_handler(canvas_on_close_handler) box.addWidget(_context.canvas.native) rightBoxWidget = QWidget() rightBox = QBoxLayout(QBoxLayout.TopToBottom, rightBoxWidget) rightBox.setAlignment(Qt.AlignTop) box.addWidget(rightBoxWidget) tensor_view_selector = TensorRankViewSelector() rightBox.addWidget(tensor_view_selector) #button = QPushButton('Change View', self) #button.setToolTip('Change View Port') #rightBox.addWidget(button) xyzRangeSelector = XYZRangeSelector() rightBox.addWidget(xyzRangeSelector) tw_container = TensorRankShower() rightBox.addWidget(tw_container) self.show()
def init_widget(self): self.setWindowTitle("Hello World") widget_laytout = QBoxLayout(QBoxLayout.LeftToRight) group = QGroupBox() box = QBoxLayout(QBoxLayout.TopToBottom) group.setLayout(box) group.setTitle("Buttons") widget_laytout.addWidget(group) fruits = [ "Buttons in GroupBox", "TextBox in GroupBox", "Label in GroupBox", "TextEdit" ] view = QListView(self) model = QStandardItemModel() for f in fruits: model.appendRow(QStandardItem(f)) view.setModel(model) box.addWidget(view) self.stk_w.addWidget(Widget_1()) self.stk_w.addWidget(Widget_2()) self.stk_w.addWidget(Widget_3()) self.stk_w.addWidget(QTextEdit()) widget_laytout.addWidget(self.stk_w) self.setLayout(widget_laytout) view.clicked.connect(self.slot_clicked_item)
def get_setting_control(self, name, text): value = self.settings[name] if isinstance(value, bool): layout = QBoxLayout(QBoxLayout.TopToBottom) control = QCheckBox(text, self) control.setChecked(value) elif isinstance(value, str): layout = QBoxLayout(QBoxLayout.TopToBottom) label = QLabel(text, self) control = QLineEdit(value, self) control.returnPressed.connect(self.on_ok_clicked) layout.addWidget(label) elif isinstance(value, int) or isinstance(value, float): if isinstance(value, float): control = QDoubleSpinBox(self) else: control = QSpinBox(self) control.setRange(self.min_, self.max_) control.setValue(value) layout = QBoxLayout(QBoxLayout.LeftToRight) label = QLabel(text, self) layout.addWidget(label) elif isinstance(value, list) or isinstance(value, dict): self.list_values[name] = value control = QPushButton('Изменить список', self) control.clicked.connect(lambda: self.on_list_change_clicked(name)) label = QLabel(text, self) layout = QBoxLayout(QBoxLayout.LeftToRight) layout.addWidget(label) else: raise ValueError(f'Не GUI для настройки типа {type(value)} ') layout.addWidget(control) return control, layout
def __init__(self): QWidget.__init__(self, flags=Qt.Widget) # 레이아웃 선언 및 Form Widget에 설정 self.layout_1 = QBoxLayout(QBoxLayout.LeftToRight, self) self.layout_2 = QBoxLayout(QBoxLayout.LeftToRight) self.layout_3 = QBoxLayout(QBoxLayout.TopToBottom) # 부모 레이아웃에 자식 레이아웃을 추가 self.layout_1.addLayout(self.layout_2) self.layout_1.addLayout(self.layout_3) self.web = QWebEngineView() self.pb_1 = QPushButton("요청하기") self.pb_2 = QPushButton("밝기지도") self.pb_3 = QPushButton("길찾기") # self.te_1 = QTextEdit() # Web과 통신할 수 있게 채널링 channel = QWebChannel(self.web.page()) self.web.page().setWebChannel(channel) self.handler = CallHandler() # 반드시 인스턴스 변수로 사용해야 한다. channel.registerObject('handler', self.handler) # js에서 불리울 이름 self.setLayout(self.layout_1) self.init_widget()
def __init__(self): QWidget.__init__(self, flags=Qt.Widget) self.setWindowTitle("QTreeWidget Column") self.setFixedWidth(300) self.setFixedHeight(300) # TreeWidget 1 self.tw_1 = QTreeWidget(self) self.tw_1.setColumnCount(1) self.tw_1.setHeaderLabels(self.HEADER) # TreeWidget 1 self.tw_2 = QTreeWidget(self) self.tw_2.setColumnCount(1) self.tw_2.setHeaderLabels(self.HEADER) # Buttons self.pb_move_left = QPushButton("<-") self.pb_move_right = QPushButton("->") layout = QBoxLayout(QBoxLayout.LeftToRight) layout.addWidget(self.tw_1) layout.addWidget(self.tw_2) main_layout = QBoxLayout(QBoxLayout.TopToBottom) main_layout.addLayout(layout) main_layout.addWidget(self.pb_move_right) main_layout.addWidget(self.pb_move_left) self.setLayout(main_layout)
def __init__(self): super(Window, self).__init__() box = QBoxLayout(QBoxLayout.LeftToRight, self) self.resize(1200, 800) tensor_display_context = TensorDisplayContext(_tensor_data) def canvas_on_close_handler(_1, _2): self.close() tensor_display_context.canvas.set_on_close_handler(canvas_on_close_handler) box.addWidget(tensor_display_context.canvas.native) rightBoxWidget = QWidget() rightBox = QBoxLayout(QBoxLayout.TopToBottom, rightBoxWidget) rightBox.setAlignment(Qt.AlignTop) box.addWidget(rightBoxWidget) tensor_view_selector = TensorRankViewSelector() rightBox.addWidget(tensor_view_selector) xyzRangeSelector = XYZRangeSelector(_tensor_data) rightBox.addWidget(xyzRangeSelector) tw_container = TensorRankShower(_tensor_data) rightBox.addWidget(tw_container) # esc_shortcut = QShortcut(self) # esc_shortcut.activated.connect(self.close) self.show()
def __init__(self, parent): super(PolicyWindow, self).__init__(parent) self.parent = parent mainLayout = QBoxLayout(QBoxLayout.TopToBottom) topLayout = QBoxLayout(QBoxLayout.TopToBottom) buttonLayout = QBoxLayout(QBoxLayout.LeftToRight) self.policy = QGroupBox() self.remain = QLabel() self.opt = [QRadioButton("Radio " + str(i)) for i in range(6)] for i in self.opt: topLayout.addWidget(i) self.policy.setLayout(topLayout) self.cancel = QPushButton("Cancel") self.accept = QPushButton("OK") buttonLayout.addWidget(self.cancel) buttonLayout.addWidget(self.accept) self.cancel.released.connect(self.close) self.accept.released.connect(self.doEnactPolicy) mainLayout.addWidget(self.policy) mainLayout.addWidget(self.remain) mainLayout.addLayout(buttonLayout) self.setLayout(mainLayout) self.setFixedSize(300, 250) self.setModal(True)
def __init__(self): QWidget.__init__(self, flags=Qt.Widget) self.setWindowTitle("RadioButton") # 배치될 위젯 변수 선언 grp_1 = QGroupBox("Group 1") grp_2 = QGroupBox("Group 2") rb_1 = QRadioButton("RadioButton 1") rb_2 = QRadioButton("RadioButton 2") rb_3 = QRadioButton("RadioButton 3") rb_4 = QRadioButton("RadioButton 4") rb_5 = QRadioButton("RadioButton 5") # 레이아웃 선언 및 Form Widget에 설정 base_layout = QBoxLayout(QBoxLayout.TopToBottom, self) grp_1_layout = QBoxLayout(QBoxLayout.TopToBottom) grp_2_layout = QBoxLayout(QBoxLayout.TopToBottom) grp_1.setLayout(grp_1_layout) grp_2.setLayout(grp_2_layout) grp_1_layout.addWidget(rb_1) grp_1_layout.addWidget(rb_2) grp_1_layout.addWidget(rb_3) grp_2_layout.addWidget(rb_4) grp_2_layout.addWidget(rb_5) base_layout.addWidget(grp_1) base_layout.addWidget(grp_2) self.setLayout(base_layout)
def __init__(self, parent): super(ScoresWindow, self).__init__(parent) self.parent = parent mainLayout = QBoxLayout(QBoxLayout.TopToBottom) columnLayout = QBoxLayout(QBoxLayout.LeftToRight) column = [QBoxLayout(QBoxLayout.TopToBottom) for i in range(3)] for i in column: columnLayout.addLayout(i) self.cell = [QLabel() for i in range(9)] for i in range(9): column[i//3].addWidget(self.cell[i]) chartView = QChartView() axisY = QValueAxis() axisY.setRange(-700,700) axisY.setLabelFormat("%d") self.chart = LineChart(((10,20,30,40,50,60,70,80),(0,-10,-20,-30,-40,50,-20,0))) self.chart.addAxis(axisY, Qt.AlignLeft) for i in self.chart.series: i.attachAxis(axisY) chartView.setChart(self.chart) self.level = QLabel() mainLayout.addLayout(columnLayout) mainLayout.addWidget(chartView) self.setLayout(mainLayout) self.setFixedSize(300,400) self.setModal(True) self.setStrings()
def loginParents(self): gb1 = QGroupBox("Login") self.main_box.addWidget(gb1) # base layout base_box = QBoxLayout(QBoxLayout.TopToBottom, self) button_box = QBoxLayout(QBoxLayout.LeftToRight, self) line_edit_id = self.loginID() line_edit_password = self.loginPassword() line_edit_id.textChanged.connect(self.senderTextID) line_edit_password.textChanged.connect(self.senderTextPassword) #self.password_text = line_edit_password.setEchoMode(QLineEdit.Password) save_button = self.saveButton() cancel_button = self.cancelButton() save_button.pressed.connect(self.saveFile) layout = QGridLayout() layout.addItem(QSpacerItem(30, 0)) layout.addWidget(QLabel("ID : "), 1, 0) layout.addWidget(line_edit_id, 1, 1) layout.addWidget(QLabel("Password : "),2 ,0) layout.addWidget(line_edit_password, 2, 1) button_box.addWidget(save_button) button_box.addWidget(cancel_button) base_box.addLayout(layout) base_box.addLayout(button_box) gb1.setLayout(base_box)
def init_widget(self): """ 현재 위젯의 모양등을 초기화 """ self.setWindowTitle("Hello World") form_lbx = QBoxLayout(QBoxLayout.TopToBottom, parent=self) self.setLayout(form_lbx) gb_1 = QGroupBox(self) gb_1.setTitle("GroupBox") form_lbx.addWidget(gb_1) lbx = QBoxLayout(QBoxLayout.LeftToRight) gb_1.setLayout(lbx) lbx.addWidget(QCheckBox("check box #1")) lbx.addWidget(QCheckBox("check box #2")) lbx.addWidget(QCheckBox("check box #3")) gb_2 = QGroupBox(self) gb_2.setTitle("GroupBox") gb_2.setCheckable(True) gb_2.setChecked(False) form_lbx.addWidget(gb_2) lbx = QBoxLayout(QBoxLayout.LeftToRight) gb_2.setLayout(lbx) lbx.addWidget(QRadioButton("radio button #1")) lbx.addWidget(QRadioButton("radio button #2")) lbx.addWidget(QRadioButton("radio button #3"))
def __init__(self): QWidget.__init__(self, flags=Qt.Widget) self.setGeometry(300, 300, 400, 400) self.setWindowFlag(Qt.WindowStaysOnTopHint) layout = QBoxLayout(QBoxLayout.TopToBottom) self.target_rect = QWidget(parent=self, flags=Qt.Widget) self.target_rect.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.target_rect.setStyleSheet("background-color: black") layout.addWidget(self.target_rect) buttons = QWidget() buttons.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) layout.addWidget(buttons) layout2 = QBoxLayout(QBoxLayout.LeftToRight) buttons.setLayout(layout2) self.btn_capture = QPushButton(parent=self, text='분석') self.btn_exit = QPushButton(parent=self, text='종료') self.btn_capture.clicked.connect(self.on_btn_capture_clicked) self.btn_exit.clicked.connect(sys.exit) layout2.addWidget(self.btn_capture) layout2.addWidget(self.btn_exit) self.result_text = QPlainTextEdit() self.result_text.setMaximumHeight(100) self.result_text.setEnabled(False) self.result_text.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) layout.addWidget(self.result_text) self.setLayout(layout) self.image_process_thread = ImageProcessClass(self) self.image_process_thread.resstr.connect(self.thread_end)
def __init__(self): "另一种初始化方法" super(Window, self).__init__() self.initGUI("BoxLayout") layout = QBoxLayout(QBoxLayout.LeftToRight) self.setLayout(layout) label = QLabel("C") layout.addWidget(label, 0) label = QLabel("C++") layout.addWidget(label, 0) layout2 = QBoxLayout(QBoxLayout.TopToBottom) layout.addLayout(layout2) label = QLabel("Java") layout2.addWidget(label, 0) label = QLabel("Python") layout2.addWidget(label, 0) # 新的布局,管理两个按钮 layout3 = QBoxLayout(QBoxLayout.RightToLeft) layout.addLayout(layout3) # TODO: 给按钮添加响应方法 btn_opacity_half = QPushButton("半透明") layout3.addWidget(btn_opacity_half) btn_opacity_all = QPushButton("完全不透明") layout3.addWidget(btn_opacity_all)
def put_into_layout(self, programs, qbtn, sbtn): layout = QBoxLayout(2) # TopToBottom upper = QBoxLayout(2) lower = QBoxLayout(0) # LeftToRight upperboxes = {} # calculation of boxlayout for i in range(self.funcs['HOWMANYPROGRAMS']): columns = self.funcs['COLUMNS'] if i % columns == 0: upperboxes[f'box{i}'] = QBoxLayout(0) for j in range(columns): try: upperboxes[f'box{i}'].addWidget( programs[f'program{j+i}']) except: continue upper.addLayout(upperboxes[f'box{i}']) lower.addWidget(qbtn) lower.addWidget(sbtn) layout.addLayout(upper) layout.addLayout(lower) return layout
def __init__(self): QWidget.__init__(self, flags=Qt.Widget) self.setWindowTitle("Soccer Highlight") self.setWindowIcon(QIcon('./images/soccer.png')) self.setFixedWidth(640) self.setFixedHeight(480) # self.setStyleSheet("background-color: white") # self.setWindowOpacity() layout_base = QBoxLayout(QBoxLayout.TopToBottom, self) self.setLayout(layout_base) # 첫 번째 그룹 QBoxLayout grp_1 = QGroupBox("LEAUGE") layout_base.addWidget(grp_1) layout = QHBoxLayout() layout.addWidget(QPushButton("Laliga")) layout.addWidget(QPushButton("Serie A")) layout.addWidget(QPushButton("Ligue 1")) layout.addWidget(QPushButton("Bundesliga")) layout.addWidget(QPushButton("K-League")) grp_1.setLayout(layout) # 두 번째 그룹 QGridLayout grp_2 = QGroupBox("Select your file & League") layout_base.addWidget(grp_2) grp_2_layout = QBoxLayout(QBoxLayout.LeftToRight) grp_2.setLayout(grp_2_layout) layout = QGridLayout() # layout.addItem(QSpacerItem(10, 200)) # 파일 선택 버튼 self.file_b = QPushButton('File Open') self.file_b.clicked.connect(self.pushButtonClicked) layout.addWidget(self.file_b, 1, 0) # 파일 이름 출력 self.f_label = QLabel() layout.addWidget(self.f_label) # 리그 선택 L_cb = QComboBox(self) L_cb.addItem('Laliga') L_cb.addItem('Serie A') L_cb.addItem('Ligue 1') L_cb.addItem('Bundesliga') L_cb.addItem('K-League') grp_2_layout.addLayout(layout) grp_2_layout.addWidget(L_cb) # 세 번째 그룹 QFormLaytout grp_3 = QGroupBox("Make HighLight") layout_base.addWidget(grp_3) layout = QFormLayout() grp_3.setLayout(layout) self.submit_b = QPushButton('확인') self.submit_b.clicked.connect(self.makeHighlight) layout.addRow(self.submit_b)
def __init__(self, parent = None, direction = "ltr", rtf = False): """ Creates a new QPageWidget on given parent object. parent: QWidget parent direction: "ltr" -> Left To Right "ttb" -> Top To Bottom rtf: Return to first, if its True it flips to the first page when next page requested at the last page """ # First initialize, QPageWidget is based on QScrollArea QScrollArea.__init__(self, parent) # Properties for QScrollArea self.setFrameShape(QFrame.NoFrame) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setWidgetResizable(True) # Main widget, which stores all Pages in it self.widget = QWidget(self) # Layout based on QBoxLayout which supports Vertical or Horizontal layout if direction == "ltr": self.layout = QBoxLayout(QBoxLayout.LeftToRight, self.widget) self.__scrollBar = self.horizontalScrollBar() self.__base_value = self.width else: self.layout = QBoxLayout(QBoxLayout.TopToBottom, self.widget) self.__scrollBar = self.verticalScrollBar() self.__base_value = self.height self.layout.setSpacing(0) self.layout.setMargin(0) # Return to first self.__return_to_first = rtf # TMP_PAGE, its using as last page in stack # A workaround for a QScrollArea bug self.__tmp_page = Page(QWidget(self.widget)) self.__pages = [self.__tmp_page] self.__current = 0 self.__last = 0 # Set main widget self.setWidget(self.widget) # Animation TimeLine self.__timeline = QTimeLine() self.__timeline.setUpdateInterval(2) # Updates scrollbar position when frame changed self.__timeline.frameChanged.connect(lambda x: self.__scrollBar.setValue(x)) # End of the animation self.__timeline.finished.connect(self._animateFinished) # Initialize animation self.setAnimation() self.setDuration()
def createLayout(self): #build layout for the dialog box importButton = QPushButton("Import", self) importButton.clicked.connect(self.importSVG) saveButton = QPushButton("Save", self) saveButton.clicked.connect(self.saveEvent) self.symbolName = QLineEdit(self) self.symbolName.setPlaceholderText("Enter Symbol Name") symbolNameLabel = QLabel("Symbol Name") symbolNameLabel.setBuddy(self.symbolName) self.symbolClass = QLineEdit(self) self.symbolClass.setPlaceholderText("Enter Symbol Class Name") symbolClassLabel = QLabel("Symbol Class Name") symbolClassLabel.setBuddy(self.symbolClass) self.symbolCategory = QLineEdit(self) self.symbolCategory.setPlaceholderText("Enter Symbol Category") symbolCategoryLabel = QLabel("Symbol Category") symbolCategoryLabel.setBuddy(self.symbolCategory) addGripItem = QPushButton("Add Grip Item", self) addGripItem.clicked.connect(self.addGrip) addLineGripItem = QPushButton("Add Line Grip Item", self) addLineGripItem.clicked.connect(self.addLineGrip) self.painter = QGraphicsScene() view = QGraphicsView(self.painter) layout = QGridLayout(self) subLayout = QBoxLayout(QBoxLayout.LeftToRight) subLayout.addWidget(importButton) subLayout.addWidget(saveButton) subLayout.addStretch(1) layout.addLayout(subLayout, 0, 0, 1, -1) subLayout2 = QBoxLayout(QBoxLayout.LeftToRight) subLayout2.addWidget(view, stretch=1) subLayout3 = QBoxLayout(QBoxLayout.TopToBottom) subLayout3.addWidget(symbolNameLabel) subLayout3.addWidget(self.symbolName) subLayout3.addWidget(symbolClassLabel) subLayout3.addWidget(self.symbolClass) subLayout3.addWidget(symbolCategoryLabel) subLayout3.addWidget(self.symbolCategory) subLayout3.addStretch(1) subLayout3.addWidget(addGripItem) subLayout3.addWidget(addLineGripItem) subLayout2.addLayout(subLayout3) layout.addLayout(subLayout2, 1, 0, -1, -1) self.setLayout(layout)
def __init__(self, title, contents, is_contents_from_table=False, does_detail_exists=True): QWidget.__init__(self) QObject.__init__(self) top_widget_height = 35 pointer_cursor = QCursor(Qt.PointingHandCursor) self.setWindowTitle(title) self.setMinimumSize(self.width(), self.height()) self.setWindowIcon(QIcon(CONSTANT.ICON_PATH[0])) layout = QBoxLayout(QBoxLayout.TopToBottom, self) top_layout = QBoxLayout(QBoxLayout.LeftToRight, self) layout.addLayout(top_layout) if is_contents_from_table: contents.setParent(self) self.table = contents else: self.table = ArtifactTable(self, contents) if not does_detail_exists: self.table.is_detail_allowed = does_detail_exists self.table.artifacts_list = contents self.table.ui() layout.addWidget(self.table) self.filtering_widget = filtering_widget("Filter ({})".format(title)) self.filtering_widget.setCheckedStatus(self.table.checked_status) self.filtering_widget.itemChanged.connect(self.table.filter) filter_btn = QPushButton(self) filter_btn.setIcon(QIcon(CONSTANT.ICON_PATH[1])) filter_btn.setFixedSize(top_widget_height, top_widget_height) filter_btn.setStyleSheet("background-color: darkslategray") filter_btn.setShortcut("Ctrl+D") filter_btn.clicked.connect(self.filtering_widget.show) filter_btn.setCursor(pointer_cursor) self.search_box = QLineEdit(self) self.search_box.setFixedHeight(top_widget_height) self.search_box.showMaximized() self.search_box.setFont(QFont("Arial", 12)) self.search_box.setPlaceholderText("Search") self.search_box.returnPressed.connect(self.search) top_layout.addWidget(filter_btn) top_layout.addWidget(self.search_box) layout.addWidget(self.table) if self.table.isHidden(): self.table.show()
def init_lectures(self): headers = ['과목','시간','캠퍼스','강의실','교수명'] self.lecture_list.setColumnCount(len(headers)) self.lecture_list.setHeaderLabels(headers) self.wishlist.setColumnCount(len(headers)) self.wishlist.setHeaderLabels(headers) list_layout = QBoxLayout(QBoxLayout.LeftToRight) list_layout.addWidget(self.lecture_list) list_layout.addWidget(self.wishlist) lecture_root = QTreeWidget.invisibleRootItem(self.lecture_list) # append data for exam datas = ['하','이','루','방','가'] item = QTreeWidgetItem() for idx, data in enumerate(datas): item.setText(idx, data) lecture_root.addChild(item) datas = ['바','이','루','방','가'] item = QTreeWidgetItem() for idx, data in enumerate(datas): item.setText(idx, data) lecture_root.addChild(item) datas = ['D', '0', 'R', 'K', '_'] item = QTreeWidgetItem() for idx, data in enumerate(datas): item.setText(idx, data) lecture_root.addChild(item) # add button by layout btn_layout = QBoxLayout(QBoxLayout.RightToLeft) btn_layout.addWidget(self.add_btn) btn_layout.addWidget(self.del_btn) main_layout = QBoxLayout(QBoxLayout.TopToBottom) main_layout.addLayout(list_layout) main_layout.addLayout(btn_layout) # connect event when button clicked self.add_btn.clicked.connect(self.move_item) self.del_btn.clicked.connect(self.move_item) self.setLayout(main_layout) return main_layout
def _init_ui(self): self.layout = QBoxLayout(QBoxLayout.TopToBottom) self.frames_layout = QHBoxLayout() self.tags_layout = QHBoxLayout() self.tags_layout.setSpacing(0) self.tags_layout.setContentsMargins(0,0,0,0) self.start_frame_label = PressableLabel(str(self.start_frame), False, self._on_label_click) self.frame_separator = PressableLabel("-") self.frame_separator.setDisabled(True) self.end_container = QBoxLayout(QBoxLayout.LeftToRight) if not self.end_frame: self.end_button = QPushButton('End') self.end_container.setAlignment(Qt.AlignRight) self.end_container.addWidget(self.end_button) self.end_button.clicked.connect(self._handle_set_end_frame) else: self.end_widget = PressableLabel(str(self.end_frame), False, self._on_label_click) self.end_container.addWidget(self.end_widget) self.frames_layout.setSpacing(0) self.frames_layout.addWidget(self.start_frame_label) self.frames_layout.addWidget(self.frame_separator) if not self.end_frame: self.frames_layout.addStretch() self.frames_layout.addLayout(self.end_container) self.delete_cont = QBoxLayout(QBoxLayout.TopToBottom) self.delete = QPushButton('Del') self.delete_cont.addWidget(self.delete) self.delete_cont.setAlignment(Qt.AlignRight) self.frames_layout.addLayout(self.delete_cont) self.delete.clicked.connect(self._handle_delete) self.tags_layout.addWidget(PressableLabel('', True)) for tag in self.segment.tags: self.tags_layout.addWidget(PressableLabel(tag.name, True)) self.tags_layout.addStretch() self.layout.setContentsMargins(0,0,0,0) self.layout.addLayout(self.frames_layout) self.setLayout(self.layout) self.layout.addLayout(self.tags_layout) if self.is_selected: self.setProperty('class', 'selected') self._init_style()
def __init__(self, urls, toggle_sequence): super(MainWidget, self).__init__() proxy = proxy_module.Proxy() proxy.start_monitoring_daemon() self._captive_portal_url = '' self._urls = cycle(urls) self._current_url = next(self._urls) self._browser_widget = browser_widget.BrowserWidget( self._current_url, proxy.get_current) self._is_captive_portal_visible = False self._captive_portal_message = captive_portal_message.CaptivePortalMessage( self._toggle_captive_portal) self._layout = QBoxLayout(QBoxLayout.BottomToTop) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self._layout.addWidget(self._browser_widget) # Start captive portal when state is initialized self._captive_portal = captive_portal.CaptivePortal( proxy.get_current, self.set_captive_portal_url) self._captive_portal.start_monitoring_daemon() QShortcut(toggle_sequence, self).activated.connect(self._load_next_url) self.setLayout(self._layout) self.show()
def __init__(self, parent, max_cnt): QWidget.__init__(self, parent) QObject.__init__(self) self.setStyleSheet("background-color: #31353a;") self.setAutoFillBackground(True) self.loading_img_path = "img/loading.gif" layout = QBoxLayout(QBoxLayout.TopToBottom, self) self.setLayout(layout) self.loading_movie = QMovie(self.loading_img_path) self.loading_img = QLabel(self) self.loading_img.setMovie(self.loading_movie) self.loading_img.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.loading_img.setAlignment(Qt.AlignCenter) self.log_label = QLabelLogger(self) self.log_label.setFormatter(logging.Formatter('%(message)s')) logging.getLogger().addHandler(self.log_label) logging.getLogger().setLevel(logging.INFO) self.loading_bar = QProgressBar(self) self.loading_bar.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) self.loading_bar.setMaximum(max_cnt * 100) self.loading_bar.setFixedHeight(10) self.loading_bar.setTextVisible(False) self.bar_thread = LoadingBarThread(self, 100) self.bar_thread.change_value.connect(self.loading_bar.setValue) layout.addWidget(self.loading_img) layout.addWidget(self.log_label.widget) layout.addWidget(self.loading_bar) self.layout().setContentsMargins(0, 0, 0, 0)
def _init_content(self, direction, collapsed): content = QFrame(self) content_layout = QBoxLayout(direction) content_layout.setAlignment(Qt.AlignTop) content.setLayout(content_layout) content.setVisible(not collapsed) return content
def init_ui(self): self.setMinimumWidth(320) self.setMinimumHeight(240) layout = QBoxLayout(QBoxLayout.LeftToRight) self.setLayout(layout) lb_1 = QLabel() self.origin_pixmap = self.origin_pixmap.scaledToHeight(240) # 사이즈가 조정 lb_1.setPixmap(self.origin_pixmap) layout.addWidget(lb_1) # 자를 영역 선택, 복사 rect = QRect(50, 50, 50, 50) cropped = self.origin_pixmap.copy(rect) self.lb_2 = QLabel() self.lb_2.setPixmap(cropped) self.lb_2.setFixedSize(100, 100) layout.addWidget(self.lb_2) w = Rectangle(parent=lb_1) w.setGeometry(0, 0, 100, 100) w.setStyleSheet("background-color: red") opacity_effect = QGraphicsOpacityEffect(self) opacity_effect.setOpacity(0.3) w.setGraphicsEffect(opacity_effect) w.change_position.connect(self.crop_image)
def init_widget(self): self.setWindowTitle("Timer") form_lbx = QBoxLayout(QBoxLayout.TopToBottom, parent=self) self.setLayout(form_lbx) self.th.change_value.connect(self.pgsb.setValue) form_lbx.addWidget(self.pgsb)
def init_widget(self): self.setWindowTitle("Serial Controller") layout = QBoxLayout(QBoxLayout.TopToBottom, parent=self) grid_box = QGridLayout() grid_box.addWidget(QLabel(self.tr("Port")), 0, 0) grid_box.addWidget(self.cb_port, 0, 1) grid_box.addWidget(QLabel(self.tr("Baud Rate")), 1, 0) grid_box.addWidget(self.cb_baud_rate, 1, 1) grid_box.addWidget(QLabel(self.tr("Data Bits")), 2, 0) grid_box.addWidget(self.cb_data_bits, 2, 1) grid_box.addWidget(QLabel(self.tr("Flow Control")), 3, 0) grid_box.addWidget(self.cb_flow_control, 3, 1) grid_box.addWidget(QLabel(self.tr("Parity")), 4, 0) grid_box.addWidget(self.cb_parity, 4, 1) grid_box.addWidget(QLabel(self.tr("Stop Bits")), 5, 0) grid_box.addWidget(self.cb_stop_bits, 5, 1) self._fill_serial_info() self.gb.setLayout(grid_box) layout.addWidget(self.gb) self.setLayout(layout)
def add_settings(self): main_layout = QBoxLayout(QBoxLayout.TopToBottom) for box_title, settings in self.gui_settings.items(): box = QGroupBox(box_title, self) box_layout = QBoxLayout(QBoxLayout.TopToBottom) for name, text in settings.items(): control, layout = self.get_setting_control(name, text) box_layout.addLayout(layout) self.controls[name] = control box.setLayout(box_layout) main_layout.addWidget(box) if main_layout.count() > 2: self.settingsLayout.addItem(main_layout) main_layout = QBoxLayout(QBoxLayout.TopToBottom) main_layout.addStretch() self.settingsLayout.addItem(main_layout)
def init_widget(self): """ 현재 위젯의 모양등을 초기화 """ self.setWindowTitle( "Movon - Nordic Mesh Serial Comm Test Program v0.1") form_lbx = QBoxLayout(QBoxLayout.TopToBottom, parent=self) self.setLayout(form_lbx) self.pb.clicked.connect(self.slot_clicked_connect_button) self.pb_clear.clicked.connect(self.slot_clicked_clear_button) self.serial.received_data.connect(self.read_data) #test_data = bytes([0x02]) + bytes("TEST DATA", "utf-8") + bytes([0x03]) test_data = bytes([0x06]) + bytes([0x02]) + bytes([0x48]) + bytes([ 0x65 ]) + bytes([0x6C]) + bytes([0x6C]) + bytes([0x6F]) # test text 'Hello' self.pb_send.clicked.connect(lambda: self.serial.writeData(test_data)) form_lbx.addWidget(self.serial) form_lbx.addWidget(self.te) form_lbx.addWidget(self.pb_clear) form_lbx.addWidget(self.pb_send) form_lbx.addWidget(self.pb) # 많이 사용하는 옵션을 미리 지정해 둔다. # 115200 8N1 self.serial.cb_baud_rate.setCurrentIndex(7) self.serial.cb_data_bits.setCurrentIndex(3)
def __init__(self, title, parent=None): super(ServoControls, self).__init__(title, parent) self.slider = QSlider(Qt.Horizontal) self.slider.setFocusPolicy(Qt.StrongFocus) self.slider.setTickPosition(QSlider.TicksBothSides) self.slider.setTickInterval(10) self.slider.setSingleStep(1) self.dial = QDial() self.dial.setFocusPolicy(Qt.StrongFocus) self.dial.setNotchesVisible(True) self.lcd_display = QLCDNumber() self.lcd_display.display(22) self.slider.valueChanged.connect(self.dial.setValue) self.dial.valueChanged.connect(self.lcd_display.display) self.dial.valueChanged.connect(self.slider.setValue) self.dial.valueChanged.connect(self.valueChanged) boxLayout = QBoxLayout(QBoxLayout.TopToBottom) boxLayout.addWidget(self.slider) boxLayout.addWidget(self.dial) boxLayout.addWidget(self.lcd_display) boxLayout.setStretchFactor(self.dial, 20) self.setLayout(boxLayout) self.setMinimum(0) self.setMaximum(100) self.dial.setWrapping(True)
def __init__(self, viewport): super().__init__() self.viewport = viewport self.moduleName = "QViewportHeader" self.setContentsMargins(0, 0, 0, 0) boxLayout = QBoxLayout(QBoxLayout.LeftToRight) boxLayout.setContentsMargins(0, 0, 0, 0) boxLayout.setSpacing(0) self.setLayout(boxLayout) titleBtn = QToolButton() titleBtn.setAutoRaise(True) titleBtn.setToolButtonStyle(Qt.ToolButtonTextOnly) titleBtn.setPopupMode(QToolButton.InstantPopup) self.titleBtn = titleBtn pivotSnapping = QToolButton() pivotSnapping.setToolTip("Pivot Snapping") pivotSnapping.setAutoRaise(True) pivotSnapping.setCheckable(True) self.pivotSnapping = pivotSnapping boxLayout.addWidget(titleBtn, 1) boxLayout.addStretch(1)