def __init__(self): QTreeView.__init__(self) # MVC # 可拖拽 self.dragEnabled() # 可释放 self.acceptDrops() # 拖拽 indicator self.showDropIndicator() # 拖拽模式 self.setDragDropMode(QAbstractItemView.InternalMove) # 标题拉伸最后一列 self.header().setStretchLastSection(True) # 无 focus, 去掉蓝框 self.setFocusPolicy(Qt.NoFocus) # 设置样式 self.setStyleSheet(get_theme("TreeView"))
def __init__(self): QWidget.__init__(self) self.title = u"Web对象管理" # Page _page = PageContainer() # Window _window = ViewWindow() # Widget _widget = WidgetContainer() # 页面 tab _tab = QTabWidget() _tab.addTab(_page, _page.title) _tab.addTab(_window, _window.title) _tab.addTab(_widget, _widget.title) _tab.setTabPosition(QTabWidget.West) _tab.setStyleSheet(get_theme("TabViewWeb")) # 测试区 self.__test = WidgetTest() self.__test.setStyleSheet(get_theme("TestWidget")) # 主layout _layout = QHBoxLayout() _layout.addWidget(_tab) _layout.addWidget(self.__test) _layout.setStretch(0, 5) _layout.setStretch(1, 1) _layout.setContentsMargins(0, 0, 0, 0) _layout.setSpacing(0) self.setLayout(_layout) # 信号 _page.sig_selected.connect(self.set_page) _widget.sig_selected.connect(self.set_widget) self.__test.sig_exec.connect(self.send)
def __init__(self): QTreeView.__init__(self) # MVC self.dragEnabled() self.acceptDrops() self.showDropIndicator() self.setDragDropMode(QAbstractItemView.InternalMove) self.header().setStretchLastSection(True) self.setFocusPolicy(Qt.NoFocus) self.setStyleSheet(get_theme("TreeView"))
def __init__(self, p_def): QWidget.__init__(self) self.__fields = p_def # 控件定义 self.widgets = dict() # 控件 _lay_inputs = QGridLayout() for _index in range(len(self.__fields)): if not self.__fields[_index]["ADD"]: continue _id = self.__fields[_index]["ID"] _type = self.__fields[_index]["TYPE"] _name = self.__fields[_index]["NAME"] _ess = self.__fields[_index]["ESSENTIAL"] _widget = create_editor(self, dict(TYPE=_type, SOURCE="ADD", FLAG=_id)) self.widgets[_id] = dict(TYPE=_type, NAME=_name, WIDGET=_widget, ESSENTIAL=_ess) if "OPERATE" == _type: _widget.sig_operate.connect(self.sig_operate.emit) _label = QLabel(("*" if _ess else " ") + _name + ":") _lay_inputs.addWidget(_label, _index, 0) _lay_inputs.addWidget(self.widgets[_id]["WIDGET"], _index, 1) buttuns = ViewButtons( [dict(id="submit", name=u"提交"), dict(id="cancel", name=u"取消")]) lay_main = QVBoxLayout() lay_main.addLayout(_lay_inputs) lay_main.addWidget(buttuns) self.setLayout(lay_main) buttuns.sig_clicked.connect(self.__operate) self.setStyleSheet(get_theme("Input"))
def __init__(self): super(StartView, self).__init__() self.setWindowTitle("hello") self.resize(1024, 768) # Menu main_menu = self.menuBar() self.create = main_menu.addMenu('&Create') self.run = main_menu.addMenu('&Run') self.report = main_menu.addMenu('&Report') self.help = main_menu.addMenu('&Help') action_batch = self.create.addAction('&Batch') action_case = self.create.addAction('&Case') action_data = self.create.addAction('&Data') action_web = self.create.addAction('&Web') action_run = self.run.addAction('&Run') action_test = self.run.addAction('&Test') action_report = self.report.addAction('&Report') self.connect(action_batch, SIGNAL('triggered()'), self.open_batch) self.connect(action_case, SIGNAL('triggered()'), self.open_case) self.connect(action_test, SIGNAL('triggered()'), self.open_test) self.connect(action_data, SIGNAL('triggered()'), self.open_data) self.connect(action_web, SIGNAL('triggered()'), self.open_web_object) self.connect(action_run, SIGNAL('triggered()'), self.open_run) self.connect(action_report, SIGNAL('triggered()'), self.open_report) # Dock self.dock_category = DockCategory() # category widget self.dock_log = DockBottom() # log widget self.dock_detail = DockDetail() # detail widget self.__dock_displayed = False # center widget self.__wid_center = QTabWidget() self.setCentralWidget(self.__wid_center) self.__wid_center.setStyleSheet(get_theme("TabViewMain")) self.__wid_center.setTabsClosable(True) self.connect(self.__wid_center, SIGNAL("tabCloseRequested(int)"), self.close_tab)
def __init__(self, p_def, p_direction="HOR"): """ 生成一个按钮组 :param p_def: [{id, name, type=None}] :return: None """ QWidget.__init__(self) # 定义 self.__definition = p_def # 按钮字典 self.__buttons = dict() # 设置方向 if "HOR" == p_direction: self.__layout = QHBoxLayout() else: self.__layout = QVBoxLayout() # 设置 layout self.setLayout(self.__layout) # 添加按钮 for t_def in self.__definition: _id = t_def["id"] _name = t_def["name"] _type = None if "type" not in t_def else t_def["type"] _button = QPushButton(_name) # Toggle button if _type is not None and "CHECK" == _type: _button.setCheckable(True) _button.clicked.connect(partial(self.sig_clicked.emit, _id)) self.__buttons["id"] = _button self.__layout.addWidget(_button) # 默认向右对齐 self.align_back() # 设置样式 self.setStyleSheet(get_theme("Buttons"))
def __init__(self): QTableView.__init__(self) self.__configer = get_config() # 拉申最后一列 self.horizontalHeader().setStretchLastSection(True) # ... self.resizeColumnToContents(True) # 不显示格间距 self.setShowGrid(False) self.alternatingRowColors() self.setStyleSheet(get_theme("TableView"))
def __submit(self): _res = dict() for t_id in self.widgets: _res[t_id] = self.get_data(t_id) # Guarantee input is not null if self.widgets[t_id]["ESSENTIAL"] and is_null(_res[t_id]): _message = u"%s不可以为空" % self.widgets[t_id]["NAME"] _msg_box = QMessageBox(QMessageBox.Warning, "Alert", _message) _msg_box.setStyleSheet(get_theme("Buttons")) _msg_box.exec_() return self.sig_submit[dict].emit(_res) self.close()
def __init__(self, p_def): """ :param p_def: {id, name, type} :return: """ QWidget.__init__(self) # 控件定义 self.__fields_def = p_def # 每行默认控件数 self.__columns = 4 # 控件字典 self.__inputs = {} # 布局 self.__layout_srh = QGridLayout() self.setLayout(self.__layout_srh) self.setStyleSheet(get_theme("Input"))
def __init__(self): QWidget.__init__(self) self.__dict = LibDict() self.__service = WebMainService() self.id = None self.type = None self.operation = None self.data = None self.env = None # 输入框 _layout_top = QGridLayout() self.__edit_type = OrcSelect() # 类型,页面或者控件 self.__edit_flag = OrcLineEdit() # 标识符 self.__widget_type = SelectWidgetType(True) # 控件类型 self.__widget_ope = SelectWidgetOperation(True) # 控件操作类型 self.__widget_data = OrcLineEdit() self.__edit_type.set_empty() self.__edit_type.set_flag("operate_object_type") self.__edit_type.setEnabled(False) self.__edit_flag.setEnabled(False) self.__widget_type.setEnabled(False) self.__widget_data.setEnabled(False) _layout_top.addWidget(QLabel(u"类型:"), 0, 0) _layout_top.addWidget(self.__edit_type, 0, 1) _layout_top.addWidget(QLabel(u"标识:"), 1, 0) _layout_top.addWidget(self.__edit_flag, 1, 1) _layout_top.addWidget(QLabel(u"控件:"), 2, 0) _layout_top.addWidget(self.__widget_type, 2, 1) _layout_top.addWidget(QLabel(u"操作:"), 3, 0) _layout_top.addWidget(self.__widget_ope, 3, 1) _layout_top.addWidget(QLabel(u"数据:"), 4, 0) _layout_top.addWidget(self.__widget_data, 4, 1) self.__edit_status = OrcTextArea(self) self.__edit_status.setReadOnly(True) # 按钮 _layout_button = QHBoxLayout() self.__btn_exec = QPushButton(u"执行") self.__btn_exec.setStyleSheet(get_theme("Buttons")) _layout_button.addStretch() _layout_button.addWidget(self.__btn_exec) # 主界面 _layout = QVBoxLayout() _layout.addLayout(_layout_top) _layout.addWidget(self.__edit_status) _layout.addLayout(_layout_button) self.setLayout(_layout) self.__widget_ope.currentIndexChanged.connect(self.__set_operation) self.__widget_data.textChanged.connect(self.__set_data) self.__btn_exec.clicked.connect(self.sig_exec.emit)