def __init__(self, arg=None): super(Table, self).__init__(arg) # 设置窗体的标题和初始大小 self.setWindowTitle("QTableView 表格视图控件的例子") self.resize(600, 300) # 准备数据模型,设置数据层次结构为6行5列 self.model = QStandardItemModel(6, 5) # 设置数据栏名称 self.model.setHorizontalHeaderLabels(['标题1', '标题2', '标题3', '标题4', '标题5']) for row in range(6): for column in range(5): item = QStandardItem("行 %s, 列 %s" % (row, column )) self.model.setItem(row, column, item) # 实例化表格视图,设置模型为自定义的模型 self.tableView = QTableView() self.tableView.setModel(self.model) ############ 下面代码让表格 100% 的填满窗口 self.tableView.horizontalHeader().setStretchLastSection(True) self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # 局部布局 vboxLayout = QVBoxLayout() vboxLayout.addWidget(self.tableView) # 全局布局 wl = QVBoxLayout(self) wl.addLayout(vboxLayout)
def __init__(self): QWidget.__init__(self) self.model = CustomTableModel() self.table_view = QTableView() self.table_view.setModel(self.model) self.table_view.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.table_view.verticalHeader().setSectionResizeMode( QHeaderView.Stretch) self.chart = QtCharts.QChart() self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations) self.series = QtCharts.QLineSeries() self.series.setName("Line 1") self.mapper = QtCharts.QVXYModelMapper(self) self.mapper.setXColumn(0) self.mapper.setYColumn(1) self.mapper.setSeries(self.series) self.mapper.setModel(self.model) self.chart.addSeries(self.series) # for storing color hex from the series seriesColorHex = "#000000" # get the color of the series and use it for showing the mapped area seriesColorHex = "{}".format(self.series.pen().color().name()) self.model.add_mapping(seriesColorHex, QRect(0, 0, 2, self.model.rowCount())) # series 2 self.series = QtCharts.QLineSeries() self.series.setName("Line 2") self.mapper = QtCharts.QVXYModelMapper(self) self.mapper.setXColumn(2) self.mapper.setYColumn(3) self.mapper.setSeries(self.series) self.mapper.setModel(self.model) self.chart.addSeries(self.series) # get the color of the series and use it for showing the mapped area seriesColorHex = "{}".format(self.series.pen().color().name()) self.model.add_mapping(seriesColorHex, QRect(2, 0, 2, self.model.rowCount())) self.chart.createDefaultAxes() self.chart_view = QtCharts.QChartView(self.chart) self.chart_view.setRenderHint(QPainter.Antialiasing) self.chart_view.setMinimumSize(640, 480) # create main layout self.main_layout = QGridLayout() self.main_layout.addWidget(self.table_view, 1, 0) self.main_layout.addWidget(self.chart_view, 1, 1) self.main_layout.setColumnStretch(1, 1) self.main_layout.setColumnStretch(0, 0) self.setLayout(self.main_layout)
def __init__(self, config: Config) -> None: super().__init__() self._pool = QThreadPool.globalInstance() self._view = QTableView() self._view.horizontalHeader().setCascadingSectionResizes(True) self._view.horizontalHeader().setStretchLastSection(True) self._view.setAlternatingRowColors(True) self._view.setSelectionBehavior(QTableView.SelectRows) self.config = config self._init_options_group_box() self._init_button_box() main_layout = QGridLayout() main_layout.addWidget(self._options_group_box, 0, 0) main_layout.addWidget(self._button_box, 1, 0) main_layout.addWidget(self._view, 2, 0) main_layout.setSizeConstraint(QLayout.SetMinimumSize) self._main_layout = main_layout self.setLayout(self._main_layout) self._type_changed() self.setWindowTitle('Train Model')
def setupTabs(self): """ Setup the various tabs in the AddressWidget. """ groups = ["ABC", "DEF", "GHI", "JKL", "MNO", "PQR", "STU", "VW", "XYZ"] for group in groups: proxyModel = QSortFilterProxyModel(self) proxyModel.setSourceModel(self.tableModel) proxyModel.setDynamicSortFilter(True) tableView = QTableView() tableView.setModel(proxyModel) tableView.setSortingEnabled(True) tableView.setSelectionBehavior(QAbstractItemView.SelectRows) tableView.horizontalHeader().setStretchLastSection(True) tableView.verticalHeader().hide() tableView.setEditTriggers(QAbstractItemView.NoEditTriggers) tableView.setSelectionMode(QAbstractItemView.SingleSelection) # This here be the magic: we use the group name (e.g. "ABC") to # build the regex for the QSortFilterProxyModel for the group's # tab. The regex will end up looking like "^[ABC].*", only # allowing this tab to display items where the name starts with # "A", "B", or "C". Notice that we set it to be case-insensitive. re = QRegularExpression("^[{}].*".format(group)) assert re.isValid() re.setPatternOptions(QRegularExpression.CaseInsensitiveOption) proxyModel.setFilterRegularExpression(re) proxyModel.setFilterKeyColumn(0) # Filter on the "name" column proxyModel.sort(0, Qt.AscendingOrder) # This prevents an application crash (see: http://www.qtcentre.org/threads/58874-QListView-SelectionModel-selectionChanged-Crash) viewselectionmodel = tableView.selectionModel() tableView.selectionModel().selectionChanged.connect(self.selectionChanged) self.addTab(tableView, group)
def setupUi(self, ProfitLossReportWidget): if not ProfitLossReportWidget.objectName(): ProfitLossReportWidget.setObjectName(u"ProfitLossReportWidget") ProfitLossReportWidget.resize(648, 301) self.verticalLayout = QVBoxLayout(ProfitLossReportWidget) self.verticalLayout.setSpacing(0) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.ReportParamsFrame = QFrame(ProfitLossReportWidget) self.ReportParamsFrame.setObjectName(u"ReportParamsFrame") self.ReportParamsFrame.setFrameShape(QFrame.Panel) self.ReportParamsFrame.setFrameShadow(QFrame.Sunken) self.horizontalLayout = QHBoxLayout(self.ReportParamsFrame) self.horizontalLayout.setSpacing(6) self.horizontalLayout.setObjectName(u"horizontalLayout") self.horizontalLayout.setContentsMargins(2, 2, 2, 2) self.ReportRange = DateRangeSelector(self.ReportParamsFrame) self.ReportRange.setObjectName(u"ReportRange") self.ReportRange.setProperty("ItemsList", u"QTD;YTD;this_year;last_year") self.horizontalLayout.addWidget(self.ReportRange) self.ReportAccountLbl = QLabel(self.ReportParamsFrame) self.ReportAccountLbl.setObjectName(u"ReportAccountLbl") self.horizontalLayout.addWidget(self.ReportAccountLbl) self.ReportAccountBtn = AccountButton(self.ReportParamsFrame) self.ReportAccountBtn.setObjectName(u"ReportAccountBtn") self.horizontalLayout.addWidget(self.ReportAccountBtn) self.ReportFrameSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(self.ReportFrameSpacer) self.verticalLayout.addWidget(self.ReportParamsFrame) self.ReportTableView = QTableView(ProfitLossReportWidget) self.ReportTableView.setObjectName(u"ReportTableView") self.ReportTableView.setFrameShape(QFrame.Panel) self.ReportTableView.setFrameShadow(QFrame.Sunken) self.ReportTableView.setEditTriggers(QAbstractItemView.NoEditTriggers) self.ReportTableView.setAlternatingRowColors(True) self.ReportTableView.setGridStyle(Qt.DotLine) self.ReportTableView.setWordWrap(False) self.ReportTableView.verticalHeader().setVisible(False) self.ReportTableView.verticalHeader().setMinimumSectionSize(20) self.ReportTableView.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.ReportTableView) self.retranslateUi(ProfitLossReportWidget) QMetaObject.connectSlotsByName(ProfitLossReportWidget)
def setupUi(self, CategoryReportWidget): if not CategoryReportWidget.objectName(): CategoryReportWidget.setObjectName(u"CategoryReportWidget") CategoryReportWidget.resize(636, 345) self.verticalLayout = QVBoxLayout(CategoryReportWidget) self.verticalLayout.setSpacing(0) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.ReportParamsFrame = QFrame(CategoryReportWidget) self.ReportParamsFrame.setObjectName(u"ReportParamsFrame") self.ReportParamsFrame.setFrameShape(QFrame.Panel) self.ReportParamsFrame.setFrameShadow(QFrame.Sunken) self.gridLayout = QGridLayout(self.ReportParamsFrame) self.gridLayout.setSpacing(6) self.gridLayout.setObjectName(u"gridLayout") self.gridLayout.setContentsMargins(2, 2, 2, 2) self.ReportFrameSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(self.ReportFrameSpacer, 0, 3, 1, 1) self.ReportRange = DateRangeSelector(self.ReportParamsFrame) self.ReportRange.setObjectName(u"ReportRange") self.ReportRange.setProperty("ItemsList", u"QTD;YTD;this_year;last_year") self.gridLayout.addWidget(self.ReportRange, 0, 0, 1, 1) self.ReportCategoryLbl = QLabel(self.ReportParamsFrame) self.ReportCategoryLbl.setObjectName(u"ReportCategoryLbl") self.gridLayout.addWidget(self.ReportCategoryLbl, 0, 1, 1, 1) self.ReportCategoryEdit = CategorySelector(self.ReportParamsFrame) self.ReportCategoryEdit.setObjectName(u"ReportCategoryEdit") self.gridLayout.addWidget(self.ReportCategoryEdit, 0, 2, 1, 1) self.verticalLayout.addWidget(self.ReportParamsFrame) self.ReportTableView = QTableView(CategoryReportWidget) self.ReportTableView.setObjectName(u"ReportTableView") self.ReportTableView.setFrameShape(QFrame.Panel) self.ReportTableView.setFrameShadow(QFrame.Sunken) self.ReportTableView.setEditTriggers(QAbstractItemView.NoEditTriggers) self.ReportTableView.setAlternatingRowColors(True) self.ReportTableView.setGridStyle(Qt.DotLine) self.ReportTableView.setWordWrap(False) self.ReportTableView.verticalHeader().setVisible(False) self.ReportTableView.verticalHeader().setMinimumSectionSize(20) self.ReportTableView.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.ReportTableView) self.retranslateUi(CategoryReportWidget) QMetaObject.connectSlotsByName(CategoryReportWidget)
def __init__(self, parent, rows, selected=None, disabled=None): super().__init__(parent) self.setWindowTitle("Select XDF Stream") self.model = QStandardItemModel() self.model.setHorizontalHeaderLabels( ["ID", "Name", "Type", "Channels", "Format", "Sampling Rate"]) for index, stream in enumerate(rows): items = [] for item in stream: tmp = QStandardItem() tmp.setData(item, Qt.DisplayRole) items.append(tmp) for item in items: item.setEditable(False) if disabled is not None and index in disabled: item.setFlags(Qt.NoItemFlags) self.model.appendRow(items) self.view = QTableView() self.view.setModel(self.model) self.view.verticalHeader().setVisible(False) self.view.horizontalHeader().setStretchLastSection(True) self.view.setShowGrid(False) self.view.setSelectionMode(QAbstractItemView.SingleSelection) self.view.setSelectionBehavior(QAbstractItemView.SelectRows) if selected is not None: self.view.selectRow(selected) self.view.setSortingEnabled(True) self.view.sortByColumn(0, Qt.AscendingOrder) vbox = QVBoxLayout(self) vbox.addWidget(self.view) hbox = QHBoxLayout() self._effective_srate = QCheckBox("Use effective sampling rate") self._effective_srate.setChecked(True) hbox.addWidget(self._effective_srate) self._prefix_markers = QCheckBox("Prefix markers with stream ID") self._prefix_markers.setChecked(False) if not disabled: self._prefix_markers.setEnabled(False) hbox.addWidget(self._prefix_markers) vbox.addLayout(hbox) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(self.buttonbox) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) self.resize(775, 650) self.view.setColumnWidth(0, 90) self.view.setColumnWidth(1, 200) self.view.setColumnWidth(2, 140)
def __init__(self, parent, info, title="Channel Properties"): super().__init__(parent) self.setWindowTitle(title) self.model = QStandardItemModel(info["nchan"], 4) self.model.setHorizontalHeaderLabels(["#", "Label", "Type", "Bad"]) for index, ch in enumerate(info["chs"]): item = QStandardItem() item.setData(index, Qt.DisplayRole) item.setFlags(item.flags() & ~Qt.ItemIsEditable) self.model.setItem(index, 0, item) self.model.setItem(index, 1, QStandardItem(ch["ch_name"])) kind = channel_type(info, index).upper() self.model.setItem(index, 2, QStandardItem(str(kind))) bad = QStandardItem() bad.setData(ch["ch_name"] in info["bads"], Qt.UserRole) bad.setCheckable(True) bad.setEditable(False) checked = ch["ch_name"] in info["bads"] bad.setCheckState(Qt.Checked if checked else Qt.Unchecked) self.model.setItem(index, 3, bad) self.model.itemChanged.connect(bad_changed) self.proxymodel = MySortFilterProxyModel() self.proxymodel.setDynamicSortFilter(False) self.proxymodel.setSourceModel(self.model) self.view = QTableView() self.view.setModel(self.proxymodel) self.view.setItemDelegateForColumn(2, ComboBoxDelegate(self.view)) self.view.setEditTriggers(QAbstractItemView.AllEditTriggers) self.view.verticalHeader().setVisible(False) self.view.horizontalHeader().setStretchLastSection(True) self.view.setShowGrid(False) self.view.setSelectionMode(QAbstractItemView.NoSelection) self.view.setSortingEnabled(True) self.view.sortByColumn(0, Qt.AscendingOrder) vbox = QVBoxLayout(self) vbox.addWidget(self.view) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(self.buttonbox) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) self.resize(475, 650) self.view.setColumnWidth(0, 70) self.view.setColumnWidth(1, 155) self.view.setColumnWidth(2, 90)
def buildStatistics(self): self.buildWindow(self.window()) self.statTableMain = QTableView(self.window()) self.statTableMain.setObjectName(u"statTableMain") statTableHeader = QHeaderView(Qt.Orientation.Vertical) # self.statTableMain.commitData() # https://doc.qt.io/qt-5/sql-model.html self.statTableMain.setVerticalHeader(statTableHeader) self.statTableMain.setGeometry(self.winw(5), self.winh(10), self.winw(90), self.winh(80)) hypixelAPILabel = QLabel("Hypixel API Load:", self.window()) hypixelAPILabel.setGeometry(self.winw(5), self.winh(90), self.winw(15), self.winh(5)) minecraftAPILabel = QLabel("Minecraft API Load:", self.window()) minecraftAPILabel.setGeometry(self.winw(20), self.winh(90), self.winw(15), self.winh(5)) overlayProgressLabel = QLabel("Overlay Load:", self.window()) overlayProgressLabel.setGeometry(self.winw(35), self.winh(90), self.winw(15), self.winh(5)) self.hypixelProgressBar = QProgressBar(self.window()) self.hypixelProgressBar.setValue(self.hypixelAPILoad) self.hypixelProgressBar.setGeometry(self.winw(5), self.winh(95), self.winw(15), self.winh(3)) self.minecraftProgressBar = QProgressBar(self.window()) self.minecraftProgressBar.setValue(self.minecraftAPILoad) self.minecraftProgressBar.setGeometry(self.winw(20), self.winh(95), self.winw(15), self.winh(3)) self.overlayProgressBar = QProgressBar(self.window()) self.overlayProgressBar.setValue(self.overlayLoad) self.overlayProgressBar.setGeometry(self.winw(35), self.winh(95), self.winw(15), self.winh(3)) self.statisticsButton = QPushButton("&Stats", self.window()) self.statisticsButton.setGeometry(self.winw(5), self.winh(4), self.winw(10), self.winh(4)) self.statisticsButton.setObjectName(u"menuButton") self.optionsButton = QPushButton("&Options", self.window()) self.optionsButton.setGeometry(self.winw(16), self.winh(4), self.winw(10), self.winh(4)) self.optionsButton.setObjectName(u"menuButton") self.exitButton = QPushButton("&Exit", self.window()) self.exitButton.setGeometry(self.winw(85), self.winh(4), self.winw(10), self.winh(4)) self.exitButton.setObjectName(u"menuButton") self.statisticsButton.clicked.connect( lambda: self.statisticsButtonClick()) self.optionsButton.clicked.connect(lambda: self.optionsButtonClick()) self.exitButton.clicked.connect(lambda: self.exitButtonClick())
def __init__(self, parent): super(MainWindow, self).__init__() self._width = 360 self._height = 320 self.setMinimumSize(self._width, self._height) self.setMaximumSize(self._width, self._height) #self.resize(self._width, self._height) self.setWindowTitle('0-бед or 0-bet') self.VBox = QVBoxLayout(self) self.VBox.setContentsMargins(5, 5, 5, 5) self.restText = QLabel(self) self.restText.setText("Список заведений: ") self.restTable = QTableView(self) self.sep1 = QFrame(self) self.sep1.setFrameShape(QFrame.HLine) self.sep1.setFrameShadow(QFrame.Sunken) self.restUnitName = QLineEdit(self) self.restAddButt = QPushButton(self) self.restAddButt.setText('Добавить заведение') self.restRmvButt = QPushButton(self) self.restRmvButt.setText('Удалить заведение') self.sep2 = QFrame(self) self.sep2.setFrameShape(QFrame.HLine) self.sep2.setFrameShadow(QFrame.Sunken) self.restLotteryButt = QPushButton(self) self.restLotteryButt.setText('Лотерея') self.VBox.addWidget(self.restText) self.VBox.addWidget(self.restTable) self.VBox.addWidget(self.sep1) self.VBox.addWidget(self.restUnitName) self.VBox.addWidget(self.restAddButt) self.VBox.addWidget(self.restRmvButt) self.VBox.addWidget(self.sep2) self.VBox.addWidget(self.restLotteryButt) self.setLayout(self.VBox) self.restAddButt.clicked.connect(self.addRestItem) self.restLotteryButt.clicked.connect(self.startLottery) self.restRmvButt.clicked.connect(self.removeRestItem) self.restTable.clicked.connect(self.selectRest) self.name_list = [] self.reqCount_list = [] self.sg = Sig() parent.sg.updateTable.connect(self.updTbl)
def show_play_table(self, plays): """Shows a table with all the plays to be imported, allowing user to select some to skip""" tree_model = PlayTableModel(plays) table_widget = QTableView() table_widget.setModel(tree_model) table_widget.verticalHeader().setVisible(False) table_view_header = table_widget.horizontalHeader() table_view_header.setStretchLastSection(True) for column in range(tree_model.columnCount()): column_size = tree_model.data(tree_model.index(0, column), PlayTableModel.SIZE_ROLE) table_view_header.resizeSection(column, column_size) table_widget_dialog = QDialog(self) table_widget_dialog.setModal(True) grid_layout = QGridLayout(table_widget_dialog) grid_layout.addWidget(table_widget, 1, 1) table_widget_dialog.resize(800, 600) table_widget_dialog.exec_() skipped_plays = tree_model.get_skipped_plays() return [play for play in plays if play.id not in skipped_plays]
def __init__(self, parent, name, data): if not type(data) == BinaryView: raise Exception('expected widget data to be a BinaryView') self.bv = data QWidget.__init__(self, parent) DockContextHandler.__init__(self, self, name) self.actionHandler = UIActionHandler() self.actionHandler.setupActionHandler(self) self.table = QTableView(self) self.model = DebugThreadsListModel(self.table) self.table.setModel(self.model) self.table.clicked.connect(self.threadRowClicked) self.item_delegate = DebugThreadsItemDelegate(self) self.table.setItemDelegate(self.item_delegate) # self.table.setSortingEnabled(True) self.table.setSelectionBehavior( QAbstractItemView.SelectionBehavior.SelectRows) self.table.setSelectionMode(QAbstractItemView.ExtendedSelection) self.table.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.table.verticalHeader().setVisible(False) self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel) self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) self.table.resizeColumnsToContents() self.table.resizeRowsToContents() self.table.horizontalHeader().setSectionResizeMode( 1, QHeaderView.Stretch) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.table) self.setLayout(layout)
def setupUi(self, ReferenceDataDialog): if not ReferenceDataDialog.objectName(): ReferenceDataDialog.setObjectName(u"ReferenceDataDialog") ReferenceDataDialog.resize(869, 300) self.verticalLayout = QVBoxLayout(ReferenceDataDialog) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(2, 2, 2, 2) self.EditFrame = QFrame(ReferenceDataDialog) self.EditFrame.setObjectName(u"EditFrame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.EditFrame.sizePolicy().hasHeightForWidth()) self.EditFrame.setSizePolicy(sizePolicy) self.EditFrame.setFrameShape(QFrame.Panel) self.EditFrame.setFrameShadow(QFrame.Plain) self.EditFrame.setLineWidth(0) self.edit_layout = QHBoxLayout(self.EditFrame) self.edit_layout.setObjectName(u"edit_layout") self.edit_layout.setContentsMargins(0, 0, 0, 0) self.GroupLbl = QLabel(self.EditFrame) self.GroupLbl.setObjectName(u"GroupLbl") self.edit_layout.addWidget(self.GroupLbl) self.GroupCombo = QComboBox(self.EditFrame) self.GroupCombo.setObjectName(u"GroupCombo") self.edit_layout.addWidget(self.GroupCombo) self.Toggle = QCheckBox(self.EditFrame) self.Toggle.setObjectName(u"Toggle") self.Toggle.setChecked(False) self.edit_layout.addWidget(self.Toggle) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.edit_layout.addItem(self.horizontalSpacer) self.AddBtn = QPushButton(self.EditFrame) self.AddBtn.setObjectName(u"AddBtn") self.edit_layout.addWidget(self.AddBtn) self.AddChildBtn = QPushButton(self.EditFrame) self.AddChildBtn.setObjectName(u"AddChildBtn") self.edit_layout.addWidget(self.AddChildBtn) self.RemoveBtn = QPushButton(self.EditFrame) self.RemoveBtn.setObjectName(u"RemoveBtn") self.edit_layout.addWidget(self.RemoveBtn) self.CommitBtn = QPushButton(self.EditFrame) self.CommitBtn.setObjectName(u"CommitBtn") self.CommitBtn.setEnabled(False) self.edit_layout.addWidget(self.CommitBtn) self.RevertBtn = QPushButton(self.EditFrame) self.RevertBtn.setObjectName(u"RevertBtn") self.RevertBtn.setEnabled(False) self.edit_layout.addWidget(self.RevertBtn) self.verticalLayout.addWidget(self.EditFrame) self.SearchFrame = QFrame(ReferenceDataDialog) self.SearchFrame.setObjectName(u"SearchFrame") self.SearchFrame.setFrameShape(QFrame.Panel) self.SearchFrame.setFrameShadow(QFrame.Plain) self.SearchFrame.setLineWidth(0) self.search_layout = QHBoxLayout(self.SearchFrame) self.search_layout.setObjectName(u"search_layout") self.search_layout.setContentsMargins(0, 0, 0, 0) self.SearchLbl = QLabel(self.SearchFrame) self.SearchLbl.setObjectName(u"SearchLbl") self.search_layout.addWidget(self.SearchLbl) self.SearchString = QLineEdit(self.SearchFrame) self.SearchString.setObjectName(u"SearchString") self.search_layout.addWidget(self.SearchString) self.verticalLayout.addWidget(self.SearchFrame) self.DataView = QTableView(ReferenceDataDialog) self.DataView.setObjectName(u"DataView") self.DataView.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.DataView.setAlternatingRowColors(True) self.DataView.setSelectionBehavior(QAbstractItemView.SelectRows) self.DataView.verticalHeader().setVisible(True) self.DataView.verticalHeader().setMinimumSectionSize(20) self.DataView.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.DataView) self.TreeView = QTreeView(ReferenceDataDialog) self.TreeView.setObjectName(u"TreeView") self.TreeView.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.TreeView.setTabKeyNavigation(True) self.TreeView.setAlternatingRowColors(True) self.TreeView.setSelectionMode(QAbstractItemView.ExtendedSelection) self.TreeView.setExpandsOnDoubleClick(False) self.TreeView.header().setStretchLastSection(False) self.verticalLayout.addWidget(self.TreeView) self.retranslateUi(ReferenceDataDialog) QMetaObject.connectSlotsByName(ReferenceDataDialog)
"""Override method from QAbstractTableModel Return dataframe index as vertical header data and columns as horizontal header data. """ if role == Qt.DisplayRole: if orientation == Qt.Horizontal: return str(self._dataframe.columns[section]) if orientation == Qt.Vertical: return str(self._dataframe.index[section]) return None if __name__ == "__main__": app = QApplication(sys.argv) df = pd.read_csv("iris.csv") view = QTableView() view.resize(800, 500) view.horizontalHeader().setStretchLastSection(True) view.setAlternatingRowColors(True) view.setSelectionBehavior(QTableView.SelectRows) model = PandasModel(df) view.setModel(model) view.show() app.exec_()
def setupUi(self, AssetDialog): if not AssetDialog.objectName(): AssetDialog.setObjectName(u"AssetDialog") AssetDialog.setWindowModality(Qt.ApplicationModal) AssetDialog.resize(927, 323) AssetDialog.setModal(False) self.gridLayout = QGridLayout(AssetDialog) self.gridLayout.setSpacing(2) self.gridLayout.setObjectName(u"gridLayout") self.gridLayout.setContentsMargins(2, 2, 2, 2) self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(self.horizontalSpacer_4, 1, 2, 1, 1) self.frame = QFrame(AssetDialog) self.frame.setObjectName(u"frame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) self.frame.setSizePolicy(sizePolicy) self.frame.setFrameShape(QFrame.NoFrame) self.frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_3 = QHBoxLayout(self.frame) self.horizontalLayout_3.setSpacing(2) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.splitter = QSplitter(self.frame) self.splitter.setObjectName(u"splitter") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth()) self.splitter.setSizePolicy(sizePolicy1) self.splitter.setOrientation(Qt.Horizontal) self.SymbolsFrame = QFrame(self.splitter) self.SymbolsFrame.setObjectName(u"SymbolsFrame") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(5) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth(self.SymbolsFrame.sizePolicy().hasHeightForWidth()) self.SymbolsFrame.setSizePolicy(sizePolicy2) self.SymbolsFrame.setFrameShape(QFrame.NoFrame) self.SymbolsFrame.setFrameShadow(QFrame.Raised) self.verticalLayout = QVBoxLayout(self.SymbolsFrame) self.verticalLayout.setSpacing(2) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.SymbolsCaptionFrame = QFrame(self.SymbolsFrame) self.SymbolsCaptionFrame.setObjectName(u"SymbolsCaptionFrame") self.SymbolsCaptionFrame.setFrameShape(QFrame.NoFrame) self.SymbolsCaptionFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout_5 = QHBoxLayout(self.SymbolsCaptionFrame) self.horizontalLayout_5.setSpacing(2) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.SymbolsLabel = QLabel(self.SymbolsCaptionFrame) self.SymbolsLabel.setObjectName(u"SymbolsLabel") self.horizontalLayout_5.addWidget(self.SymbolsLabel) self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_5.addItem(self.horizontalSpacer_2) self.AddSymbolButton = QPushButton(self.SymbolsCaptionFrame) self.AddSymbolButton.setObjectName(u"AddSymbolButton") self.horizontalLayout_5.addWidget(self.AddSymbolButton) self.RemoveSymbolButton = QPushButton(self.SymbolsCaptionFrame) self.RemoveSymbolButton.setObjectName(u"RemoveSymbolButton") self.horizontalLayout_5.addWidget(self.RemoveSymbolButton) self.verticalLayout.addWidget(self.SymbolsCaptionFrame) self.SymbolsTable = QTableView(self.SymbolsFrame) self.SymbolsTable.setObjectName(u"SymbolsTable") self.SymbolsTable.setEditTriggers(QAbstractItemView.AnyKeyPressed|QAbstractItemView.EditKeyPressed|QAbstractItemView.SelectedClicked) self.SymbolsTable.setAlternatingRowColors(True) self.SymbolsTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.SymbolsTable.verticalHeader().setVisible(False) self.SymbolsTable.verticalHeader().setMinimumSectionSize(20) self.SymbolsTable.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.SymbolsTable) self.splitter.addWidget(self.SymbolsFrame) self.DataFrame = QFrame(self.splitter) self.DataFrame.setObjectName(u"DataFrame") sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy3.setHorizontalStretch(2) sizePolicy3.setVerticalStretch(0) sizePolicy3.setHeightForWidth(self.DataFrame.sizePolicy().hasHeightForWidth()) self.DataFrame.setSizePolicy(sizePolicy3) self.DataFrame.setFrameShape(QFrame.NoFrame) self.DataFrame.setFrameShadow(QFrame.Raised) self.verticalLayout_2 = QVBoxLayout(self.DataFrame) self.verticalLayout_2.setSpacing(2) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.DataCaptionFrame = QFrame(self.DataFrame) self.DataCaptionFrame.setObjectName(u"DataCaptionFrame") self.DataCaptionFrame.setFrameShape(QFrame.NoFrame) self.DataCaptionFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout_2 = QHBoxLayout(self.DataCaptionFrame) self.horizontalLayout_2.setSpacing(2) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.DataLbl = QLabel(self.DataCaptionFrame) self.DataLbl.setObjectName(u"DataLbl") self.horizontalLayout_2.addWidget(self.DataLbl) self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(self.horizontalSpacer_3) self.AddDataButton = QPushButton(self.DataCaptionFrame) self.AddDataButton.setObjectName(u"AddDataButton") self.horizontalLayout_2.addWidget(self.AddDataButton) self.RemoveDataButton = QPushButton(self.DataCaptionFrame) self.RemoveDataButton.setObjectName(u"RemoveDataButton") self.horizontalLayout_2.addWidget(self.RemoveDataButton) self.verticalLayout_2.addWidget(self.DataCaptionFrame) self.DataTable = QTableView(self.DataFrame) self.DataTable.setObjectName(u"DataTable") self.DataTable.setEditTriggers(QAbstractItemView.AnyKeyPressed|QAbstractItemView.EditKeyPressed|QAbstractItemView.SelectedClicked) self.DataTable.setAlternatingRowColors(True) self.DataTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.DataTable.verticalHeader().setVisible(False) self.DataTable.verticalHeader().setMinimumSectionSize(20) self.DataTable.verticalHeader().setDefaultSectionSize(20) self.verticalLayout_2.addWidget(self.DataTable) self.splitter.addWidget(self.DataFrame) self.horizontalLayout_3.addWidget(self.splitter) self.gridLayout.addWidget(self.frame, 3, 0, 1, 5) self.NameLbl = QLabel(AssetDialog) self.NameLbl.setObjectName(u"NameLbl") self.gridLayout.addWidget(self.NameLbl, 0, 0, 1, 1) self.isinLbl = QLabel(AssetDialog) self.isinLbl.setObjectName(u"isinLbl") self.gridLayout.addWidget(self.isinLbl, 1, 0, 1, 1) self.BaseAssetSelector = AssetSelector(AssetDialog) self.BaseAssetSelector.setObjectName(u"BaseAssetSelector") self.gridLayout.addWidget(self.BaseAssetSelector, 2, 1, 1, 1) self.ButtonsFrame = QFrame(AssetDialog) self.ButtonsFrame.setObjectName(u"ButtonsFrame") self.ButtonsFrame.setFrameShape(QFrame.NoFrame) self.ButtonsFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout = QHBoxLayout(self.ButtonsFrame) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setObjectName(u"horizontalLayout") self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(self.horizontalSpacer) self.CancelButton = QPushButton(self.ButtonsFrame) self.CancelButton.setObjectName(u"CancelButton") self.horizontalLayout.addWidget(self.CancelButton) self.OkButton = QPushButton(self.ButtonsFrame) self.OkButton.setObjectName(u"OkButton") self.horizontalLayout.addWidget(self.OkButton) self.gridLayout.addWidget(self.ButtonsFrame, 10, 0, 1, 5) self.BaseLbl = QLabel(AssetDialog) self.BaseLbl.setObjectName(u"BaseLbl") self.gridLayout.addWidget(self.BaseLbl, 2, 0, 1, 1) self.TypeLbl = QLabel(AssetDialog) self.TypeLbl.setObjectName(u"TypeLbl") self.gridLayout.addWidget(self.TypeLbl, 1, 3, 1, 1) self.isinEdit = QLineEdit(AssetDialog) self.isinEdit.setObjectName(u"isinEdit") self.gridLayout.addWidget(self.isinEdit, 1, 1, 1, 1) self.CountryLbl = QLabel(AssetDialog) self.CountryLbl.setObjectName(u"CountryLbl") self.gridLayout.addWidget(self.CountryLbl, 2, 3, 1, 1) self.CountryCombo = CountryCombo(AssetDialog) self.CountryCombo.setObjectName(u"CountryCombo") self.gridLayout.addWidget(self.CountryCombo, 2, 4, 1, 1) self.TypeCombo = AssetTypeCombo(AssetDialog) self.TypeCombo.setObjectName(u"TypeCombo") self.gridLayout.addWidget(self.TypeCombo, 1, 4, 1, 1) self.NameEdit = QLineEdit(AssetDialog) self.NameEdit.setObjectName(u"NameEdit") self.gridLayout.addWidget(self.NameEdit, 0, 1, 1, 4) self.retranslateUi(AssetDialog) self.OkButton.clicked.connect(AssetDialog.accept) self.CancelButton.clicked.connect(AssetDialog.reject) QMetaObject.connectSlotsByName(AssetDialog)
def setupUi(self, TaxEstimationDialog): if not TaxEstimationDialog.objectName(): TaxEstimationDialog.setObjectName(u"TaxEstimationDialog") TaxEstimationDialog.resize(754, 191) self.verticalLayout = QVBoxLayout(TaxEstimationDialog) self.verticalLayout.setSpacing(2) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setSpacing(2) self.horizontalLayout.setObjectName(u"horizontalLayout") self.RateFrame = QFrame(TaxEstimationDialog) self.RateFrame.setObjectName(u"RateFrame") self.RateFrame.setFrameShape(QFrame.StyledPanel) self.RateFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout_2 = QHBoxLayout(self.RateFrame) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.LastQuoteLbl = QLabel(self.RateFrame) self.LastQuoteLbl.setObjectName(u"LastQuoteLbl") font = QFont() font.setBold(True) self.LastQuoteLbl.setFont(font) self.horizontalLayout_2.addWidget(self.LastQuoteLbl) self.QuoteLbl = QLabel(self.RateFrame) self.QuoteLbl.setObjectName(u"QuoteLbl") self.horizontalLayout_2.addWidget(self.QuoteLbl) self.RateSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(self.RateSpacer) self.horizontalLayout.addWidget(self.RateFrame) self.QuoteFrame = QFrame(TaxEstimationDialog) self.QuoteFrame.setObjectName(u"QuoteFrame") self.QuoteFrame.setFrameShape(QFrame.StyledPanel) self.QuoteFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout_3 = QHBoxLayout(self.QuoteFrame) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.CurrentRateLbl = QLabel(self.QuoteFrame) self.CurrentRateLbl.setObjectName(u"CurrentRateLbl") self.CurrentRateLbl.setFont(font) self.horizontalLayout_3.addWidget(self.CurrentRateLbl) self.RateLbl = QLabel(self.QuoteFrame) self.RateLbl.setObjectName(u"RateLbl") self.horizontalLayout_3.addWidget(self.RateLbl) self.QuoteSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_3.addItem(self.QuoteSpacer) self.horizontalLayout.addWidget(self.QuoteFrame) self.verticalLayout.addLayout(self.horizontalLayout) self.DealsView = QTableView(TaxEstimationDialog) self.DealsView.setObjectName(u"DealsView") self.DealsView.setSelectionBehavior(QAbstractItemView.SelectRows) self.DealsView.verticalHeader().setVisible(False) self.DealsView.verticalHeader().setMinimumSectionSize(20) self.DealsView.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.DealsView) self.retranslateUi(TaxEstimationDialog) QMetaObject.connectSlotsByName(TaxEstimationDialog)
def __init__(self, arg=None): super(Table, self).__init__(arg) # 设置窗体的标题和初始大小 self.setWindowTitle("QTableView表格视图控件的例子") self.resize(500, 300) # 准备数据模型,设置数据层次结构为5行4列 self.model = QStandardItemModel(5, 4) # 设置数据栏名称 self.model.setHorizontalHeaderLabels(['标题1', '标题2', '标题3', '标题4']) for row in range(5): for column in range(4): item = QStandardItem("row %s, column %s" % (row, column)) self.model.setItem(row, column, item) # 实例化表格视图,设置模型为自定义的模型 self.tableView = QTableView() self.tableView.setModel(self.model) # 下面代码让表格 100% 的填满窗口 self.tableView.horizontalHeader().setStretchLastSection(True) self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # 下面代码让表格禁止编辑 self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers) # 下面代码让表格设置选中背景色 self.tableView.setStyleSheet("selection-background-color:lightblue;") # 下面代码要限定只能选择整行 # self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) # 设置只能选中整行 # self.tableView.setSelectionMode(QAbstractItemView.SingleSelection) # 设置只能选中一行 # 下面代码可以选中表格的多行 self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) # 设置只能选中整行 self.tableView.setSelectionMode(QAbstractItemView.ExtendedSelection) # 设置只能选中多行 # 下面代码可以打印表格的1行2列数据 data = self.tableView.model().index(1, 2).data() print(data) # 下面代码去掉左边表格的行号 # headerView = self.tableView.verticalHeader() # headerView.setHidden(True) # 局部布局 vboxLayout = QVBoxLayout() vboxLayout.addWidget(self.tableView) self.add_btn = QPushButton("添加记录") # 连接信号槽,点击按钮 add_btn 绑定槽事件 self.add_btn.clicked.connect(self.add_records_btn_click) self.del_btn = QPushButton("删除多行记录") # 连接信号槽,点击按钮 del_btn 绑定槽事件 self.del_btn.clicked.connect(self.del_records_btn_click) # 局部布局 hboxLayout = QHBoxLayout() hboxLayout.addWidget(self.add_btn) hboxLayout.addWidget(self.del_btn) # 全局布局 wl = QVBoxLayout(self) wl.addLayout(vboxLayout) wl.addLayout(hboxLayout)
def __init__(self, parent=None): AbstractOperationDetails.__init__(self, parent) self.name = "Income/Spending" self.details_model = None self.category_delegate = CategorySelectorDelegate() self.tag_delegate = TagSelectorDelegate() self.float_delegate = FloatDelegate(2) self.date_label = QLabel(self) self.details_label = QLabel(self) self.account_label = QLabel(self) self.peer_label = QLabel(self) self.main_label.setText(self.tr("Income / Spending")) self.date_label.setText(self.tr("Date/Time")) self.details_label.setText(self.tr("Details")) self.account_label.setText(self.tr("Account")) self.peer_label.setText(self.tr("Peer")) self.timestamp_editor = QDateTimeEdit(self) self.timestamp_editor.setCalendarPopup(True) self.timestamp_editor.setTimeSpec(Qt.UTC) self.timestamp_editor.setFixedWidth( self.timestamp_editor.fontMetrics().horizontalAdvance( "00/00/0000 00:00:00") * 1.25) self.timestamp_editor.setDisplayFormat("dd/MM/yyyy hh:mm:ss") self.account_widget = AccountSelector(self) self.peer_widget = PeerSelector(self) self.a_currency = OptionalCurrencyComboBox(self) self.a_currency.setText(self.tr("Paid in foreign currency:")) self.add_button = QPushButton(load_icon("add.png"), '', self) self.add_button.setToolTip(self.tr("Add detail")) self.del_button = QPushButton(load_icon("remove.png"), '', self) self.del_button.setToolTip(self.tr("Remove detail")) self.copy_button = QPushButton(load_icon("copy.png"), '', self) self.copy_button.setToolTip(self.tr("Copy detail")) self.details_table = QTableView(self) self.details_table.horizontalHeader().setFont(self.bold_font) self.details_table.setAlternatingRowColors(True) self.details_table.verticalHeader().setVisible(False) self.details_table.verticalHeader().setMinimumSectionSize(20) self.details_table.verticalHeader().setDefaultSectionSize(20) self.layout.addWidget(self.date_label, 1, 0, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.details_label, 2, 0, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.timestamp_editor, 1, 1, 1, 4) self.layout.addWidget(self.add_button, 2, 1, 1, 1) self.layout.addWidget(self.copy_button, 2, 2, 1, 1) self.layout.addWidget(self.del_button, 2, 3, 1, 1) self.layout.addWidget(self.account_label, 1, 5, 1, 1, Qt.AlignRight) self.layout.addWidget(self.peer_label, 2, 5, 1, 1, Qt.AlignRight) self.layout.addWidget(self.account_widget, 1, 6, 1, 1) self.layout.addWidget(self.peer_widget, 2, 6, 1, 1) self.layout.addWidget(self.a_currency, 1, 7, 1, 1) self.layout.addWidget(self.commit_button, 0, 9, 1, 1) self.layout.addWidget(self.revert_button, 0, 10, 1, 1) self.layout.addWidget(self.details_table, 4, 0, 1, 11) self.layout.addItem(self.horizontalSpacer, 1, 8, 1, 1) self.add_button.clicked.connect(self.addChild) self.copy_button.clicked.connect(self.copyChild) self.del_button.clicked.connect(self.delChild) super()._init_db("actions") self.model.beforeInsert.connect(self.before_record_insert) self.model.beforeUpdate.connect(self.before_record_update) self.mapper.setItemDelegate(IncomeSpendingWidgetDelegate(self.mapper)) self.details_model = DetailsModel(self.details_table, db_connection()) self.details_model.setTable("action_details") self.details_model.setEditStrategy(QSqlTableModel.OnManualSubmit) self.details_table.setModel(self.details_model) self.details_model.dataChanged.connect(self.onDataChange) self.account_widget.changed.connect(self.mapper.submit) self.peer_widget.changed.connect(self.mapper.submit) self.a_currency.changed.connect(self.mapper.submit) self.a_currency.name_updated.connect(self.details_model.setAltCurrency) self.mapper.addMapping(self.timestamp_editor, self.model.fieldIndex("timestamp")) self.mapper.addMapping(self.account_widget, self.model.fieldIndex("account_id")) self.mapper.addMapping(self.peer_widget, self.model.fieldIndex("peer_id")) self.mapper.addMapping(self.a_currency, self.model.fieldIndex("alt_currency_id")) self.details_table.setItemDelegateForColumn(2, self.category_delegate) self.details_table.setItemDelegateForColumn(3, self.tag_delegate) self.details_table.setItemDelegateForColumn(4, self.float_delegate) self.details_table.setItemDelegateForColumn(5, self.float_delegate) self.model.select() self.details_model.select() self.details_model.configureView()
def setupUi(self, OperationsWidget): if not OperationsWidget.objectName(): OperationsWidget.setObjectName(u"OperationsWidget") OperationsWidget.resize(1232, 552) self.verticalLayout_4 = QVBoxLayout(OperationsWidget) self.verticalLayout_4.setSpacing(0) self.verticalLayout_4.setObjectName(u"verticalLayout_4") self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) self.BalanceOperationsSplitter = QSplitter(OperationsWidget) self.BalanceOperationsSplitter.setObjectName( u"BalanceOperationsSplitter") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.BalanceOperationsSplitter.sizePolicy().hasHeightForWidth()) self.BalanceOperationsSplitter.setSizePolicy(sizePolicy) self.BalanceOperationsSplitter.setOrientation(Qt.Horizontal) self.BalanceBox = QGroupBox(self.BalanceOperationsSplitter) self.BalanceBox.setObjectName(u"BalanceBox") sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(1) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.BalanceBox.sizePolicy().hasHeightForWidth()) self.BalanceBox.setSizePolicy(sizePolicy1) self.BalanceBox.setMaximumSize(QSize(16777215, 16777215)) self.verticalLayout = QVBoxLayout(self.BalanceBox) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.BalanceConfigFrame = QFrame(self.BalanceBox) self.BalanceConfigFrame.setObjectName(u"BalanceConfigFrame") self.BalanceConfigFrame.setMinimumSize(QSize(408, 0)) self.BalanceConfigFrame.setMaximumSize(QSize(16777215, 44)) self.BalanceConfigFrame.setFrameShape(QFrame.Panel) self.BalanceConfigFrame.setFrameShadow(QFrame.Plain) self.BalanceConfigFrame.setLineWidth(0) self.horizontalLayout_2 = QHBoxLayout(self.BalanceConfigFrame) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout_2.setContentsMargins(2, 2, 2, 2) self.BalanceDate = QDateEdit(self.BalanceConfigFrame) self.BalanceDate.setObjectName(u"BalanceDate") self.BalanceDate.setDateTime( QDateTime(QDate(2020, 11, 25), QTime(21, 0, 0))) self.BalanceDate.setCalendarPopup(True) self.BalanceDate.setTimeSpec(Qt.UTC) self.horizontalLayout_2.addWidget(self.BalanceDate) self.CurrencyLbl = QLabel(self.BalanceConfigFrame) self.CurrencyLbl.setObjectName(u"CurrencyLbl") self.CurrencyLbl.setLayoutDirection(Qt.LeftToRight) self.CurrencyLbl.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.horizontalLayout_2.addWidget(self.CurrencyLbl) self.BalancesCurrencyCombo = CurrencyComboBox(self.BalanceConfigFrame) self.BalancesCurrencyCombo.setObjectName(u"BalancesCurrencyCombo") self.horizontalLayout_2.addWidget(self.BalancesCurrencyCombo) self.ShowInactiveCheckBox = QCheckBox(self.BalanceConfigFrame) self.ShowInactiveCheckBox.setObjectName(u"ShowInactiveCheckBox") self.horizontalLayout_2.addWidget(self.ShowInactiveCheckBox) self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(self.horizontalSpacer_2) self.verticalLayout.addWidget(self.BalanceConfigFrame) self.BalancesTableView = QTableView(self.BalanceBox) self.BalancesTableView.setObjectName(u"BalancesTableView") self.BalancesTableView.setFrameShape(QFrame.Panel) self.BalancesTableView.setEditTriggers( QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.BalancesTableView.setAlternatingRowColors(True) self.BalancesTableView.setSelectionMode(QAbstractItemView.NoSelection) self.BalancesTableView.setGridStyle(Qt.DotLine) self.BalancesTableView.setWordWrap(False) self.BalancesTableView.verticalHeader().setVisible(False) self.BalancesTableView.verticalHeader().setMinimumSectionSize(20) self.BalancesTableView.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.BalancesTableView) self.BalanceOperationsSplitter.addWidget(self.BalanceBox) self.OperationsBox = QGroupBox(self.BalanceOperationsSplitter) self.OperationsBox.setObjectName(u"OperationsBox") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(4) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth( self.OperationsBox.sizePolicy().hasHeightForWidth()) self.OperationsBox.setSizePolicy(sizePolicy2) self.OperationsBox.setContextMenuPolicy(Qt.DefaultContextMenu) self.verticalLayout_2 = QVBoxLayout(self.OperationsBox) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.OperationConfigFrame = QFrame(self.OperationsBox) self.OperationConfigFrame.setObjectName(u"OperationConfigFrame") self.OperationConfigFrame.setEnabled(True) self.OperationConfigFrame.setMinimumSize(QSize(0, 0)) self.OperationConfigFrame.setFrameShape(QFrame.Panel) self.OperationConfigFrame.setFrameShadow(QFrame.Plain) self.OperationConfigFrame.setLineWidth(0) self.horizontalLayout_3 = QHBoxLayout(self.OperationConfigFrame) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(2, 2, 2, 2) self.DateRange = DateRangeSelector(self.OperationConfigFrame) self.DateRange.setObjectName(u"DateRange") self.DateRange.setProperty("ItemsList", u"week;month;quarter;year;all") self.horizontalLayout_3.addWidget(self.DateRange) self.AccountLbl = QLabel(self.OperationConfigFrame) self.AccountLbl.setObjectName(u"AccountLbl") self.horizontalLayout_3.addWidget(self.AccountLbl) self.ChooseAccountBtn = AccountButton(self.OperationConfigFrame) self.ChooseAccountBtn.setObjectName(u"ChooseAccountBtn") self.horizontalLayout_3.addWidget(self.ChooseAccountBtn) self.SearchLbl = QLabel(self.OperationConfigFrame) self.SearchLbl.setObjectName(u"SearchLbl") self.horizontalLayout_3.addWidget(self.SearchLbl) self.SearchString = QLineEdit(self.OperationConfigFrame) self.SearchString.setObjectName(u"SearchString") self.horizontalLayout_3.addWidget(self.SearchString) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer) self.verticalLayout_2.addWidget(self.OperationConfigFrame) self.OperationsDetailsSplitter = QSplitter(self.OperationsBox) self.OperationsDetailsSplitter.setObjectName( u"OperationsDetailsSplitter") self.OperationsDetailsSplitter.setOrientation(Qt.Vertical) self.OperationsTableView = QTableView(self.OperationsDetailsSplitter) self.OperationsTableView.setObjectName(u"OperationsTableView") sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy3.setHorizontalStretch(0) sizePolicy3.setVerticalStretch(4) sizePolicy3.setHeightForWidth( self.OperationsTableView.sizePolicy().hasHeightForWidth()) self.OperationsTableView.setSizePolicy(sizePolicy3) self.OperationsTableView.setAlternatingRowColors(True) self.OperationsTableView.setSelectionMode( QAbstractItemView.ExtendedSelection) self.OperationsTableView.setSelectionBehavior( QAbstractItemView.SelectRows) self.OperationsTableView.setWordWrap(False) self.OperationsDetailsSplitter.addWidget(self.OperationsTableView) self.OperationsTableView.verticalHeader().setVisible(False) self.OperationsTableView.verticalHeader().setMinimumSectionSize(20) self.OperationsTableView.verticalHeader().setDefaultSectionSize(20) self.OperationDetails = QFrame(self.OperationsDetailsSplitter) self.OperationDetails.setObjectName(u"OperationDetails") sizePolicy4 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy4.setHorizontalStretch(0) sizePolicy4.setVerticalStretch(1) sizePolicy4.setHeightForWidth( self.OperationDetails.sizePolicy().hasHeightForWidth()) self.OperationDetails.setSizePolicy(sizePolicy4) self.OperationDetails.setMinimumSize(QSize(0, 100)) self.OperationDetails.setMaximumSize(QSize(16777215, 300)) self.OperationDetails.setFrameShape(QFrame.Panel) self.OperationDetails.setFrameShadow(QFrame.Sunken) self.OperationDetails.setLineWidth(1) self.horizontalLayout_4 = QHBoxLayout(self.OperationDetails) self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) self.OperationsTabs = QStackedWidget(self.OperationDetails) self.OperationsTabs.setObjectName(u"OperationsTabs") self.NoOperation = QWidget() self.NoOperation.setObjectName(u"NoOperation") self.OperationsTabs.addWidget(self.NoOperation) self.IncomeSpending = IncomeSpendingWidget() self.IncomeSpending.setObjectName(u"IncomeSpending") self.OperationsTabs.addWidget(self.IncomeSpending) self.Dividend = DividendWidget() self.Dividend.setObjectName(u"Dividend") self.OperationsTabs.addWidget(self.Dividend) self.Trade = TradeWidget() self.Trade.setObjectName(u"Trade") self.OperationsTabs.addWidget(self.Trade) self.Transfer = TransferWidget() self.Transfer.setObjectName(u"Transfer") self.OperationsTabs.addWidget(self.Transfer) self.CorporateAction = CorporateActionWidget() self.CorporateAction.setObjectName(u"CorporateAction") self.OperationsTabs.addWidget(self.CorporateAction) self.horizontalLayout_4.addWidget(self.OperationsTabs) self.OperationsButtons = QFrame(self.OperationDetails) self.OperationsButtons.setObjectName(u"OperationsButtons") self.verticalLayout_3 = QVBoxLayout(self.OperationsButtons) self.verticalLayout_3.setSpacing(2) self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.verticalLayout_3.setContentsMargins(2, 2, 2, 2) self.NewOperationBtn = QPushButton(self.OperationsButtons) self.NewOperationBtn.setObjectName(u"NewOperationBtn") self.verticalLayout_3.addWidget(self.NewOperationBtn) self.CopyOperationBtn = QPushButton(self.OperationsButtons) self.CopyOperationBtn.setObjectName(u"CopyOperationBtn") self.verticalLayout_3.addWidget(self.CopyOperationBtn) self.DeleteOperationBtn = QPushButton(self.OperationsButtons) self.DeleteOperationBtn.setObjectName(u"DeleteOperationBtn") self.verticalLayout_3.addWidget(self.DeleteOperationBtn) self.verticalSpacer_4 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_3.addItem(self.verticalSpacer_4) self.horizontalLayout_4.addWidget(self.OperationsButtons) self.OperationsDetailsSplitter.addWidget(self.OperationDetails) self.verticalLayout_2.addWidget(self.OperationsDetailsSplitter) self.BalanceOperationsSplitter.addWidget(self.OperationsBox) self.verticalLayout_4.addWidget(self.BalanceOperationsSplitter) self.retranslateUi(OperationsWidget) self.OperationsTabs.setCurrentIndex(5) QMetaObject.connectSlotsByName(OperationsWidget)
def setupUi(self, testGlWindow): if not testGlWindow.objectName(): testGlWindow.setObjectName(u"testGlWindow") testGlWindow.resize(952, 847) testGlWindow.setAcceptDrops(True) icon = QIcon() icon.addFile(u":/images/candle_256.png", QSize(), QIcon.Normal, QIcon.Off) testGlWindow.setWindowIcon(icon) testGlWindow.setStyleSheet(u"") self.centralWidget = QWidget(testGlWindow) self.centralWidget.setObjectName(u"centralWidget") self.horizontalLayout_5 = QHBoxLayout(self.centralWidget) self.horizontalLayout_5.setSpacing(9) self.horizontalLayout_5.setContentsMargins(11, 11, 11, 11) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.horizontalLayout_5.setContentsMargins(9, 9, 5, 9) self.grpProgram = QGroupBox(self.centralWidget) self.grpProgram.setObjectName(u"grpProgram") self.grpProgram.setFlat(False) self.verticalLayout_17 = QVBoxLayout(self.grpProgram) self.verticalLayout_17.setSpacing(7) self.verticalLayout_17.setContentsMargins(11, 11, 11, 11) self.verticalLayout_17.setObjectName(u"verticalLayout_17") self.verticalLayout_17.setContentsMargins(8, 8, 8, 8) self.splitter = QSplitter(self.grpProgram) self.splitter.setObjectName(u"splitter") self.splitter.setOrientation(Qt.Vertical) self.splitter.setHandleWidth(12) self.frame = QWidget(self.splitter) self.frame.setObjectName(u"frame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frame.sizePolicy().hasHeightForWidth()) self.frame.setSizePolicy(sizePolicy) self.frame.setMinimumSize(QSize(0, 600)) self.frame.setStyleSheet(u"border: 1px solid gray;") self.verticalLayout_8 = QVBoxLayout(self.frame) self.verticalLayout_8.setSpacing(6) self.verticalLayout_8.setContentsMargins(11, 11, 11, 11) self.verticalLayout_8.setObjectName(u"verticalLayout_8") self.verticalLayout_8.setContentsMargins(1, 1, 1, 1) self.splitter.addWidget(self.frame) self.layoutWidget = QWidget(self.splitter) self.layoutWidget.setObjectName(u"layoutWidget") self.verticalLayout_7 = QVBoxLayout(self.layoutWidget) self.verticalLayout_7.setSpacing(9) self.verticalLayout_7.setContentsMargins(11, 11, 11, 11) self.verticalLayout_7.setObjectName(u"verticalLayout_7") self.verticalLayout_7.setContentsMargins(0, 0, 0, 0) self.tblProgram = QTableView(self.layoutWidget) self.tblProgram.setObjectName(u"tblProgram") font = QFont() font.setPointSize(9) self.tblProgram.setFont(font) self.tblProgram.setContextMenuPolicy(Qt.CustomContextMenu) self.tblProgram.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.tblProgram.setSelectionMode(QAbstractItemView.ContiguousSelection) self.tblProgram.setSelectionBehavior(QAbstractItemView.SelectRows) self.tblProgram.setGridStyle(Qt.DashLine) self.tblProgram.horizontalHeader().setMinimumSectionSize(50) self.tblProgram.horizontalHeader().setHighlightSections(False) self.tblProgram.verticalHeader().setVisible(False) self.verticalLayout_7.addWidget(self.tblProgram) self.splitter.addWidget(self.layoutWidget) self.verticalLayout_17.addWidget(self.splitter) self.verticalLayout_17.setStretch(0, 1) self.horizontalLayout_5.addWidget(self.grpProgram) self.horizontalLayout_5.setStretch(0, 100) testGlWindow.setCentralWidget(self.centralWidget) self.menuBar = QMenuBar(testGlWindow) self.menuBar.setObjectName(u"menuBar") self.menuBar.setGeometry(QRect(0, 0, 952, 21)) testGlWindow.setMenuBar(self.menuBar) self.retranslateUi(testGlWindow) QMetaObject.connectSlotsByName(testGlWindow)
def setupUi(self, ImportSlipDlg): if not ImportSlipDlg.objectName(): ImportSlipDlg.setObjectName(u"ImportSlipDlg") ImportSlipDlg.resize(850, 587) self.verticalLayout = QVBoxLayout(ImportSlipDlg) self.verticalLayout.setSpacing(6) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(2, 2, 2, 2) self.InputFrame = QFrame(ImportSlipDlg) self.InputFrame.setObjectName(u"InputFrame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.InputFrame.sizePolicy().hasHeightForWidth()) self.InputFrame.setSizePolicy(sizePolicy) self.InputFrame.setFrameShape(QFrame.NoFrame) self.InputFrame.setFrameShadow(QFrame.Plain) self.horizontalLayout_3 = QHBoxLayout(self.InputFrame) self.horizontalLayout_3.setSpacing(2) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.QRGroup = QGroupBox(self.InputFrame) self.QRGroup.setObjectName(u"QRGroup") sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.QRGroup.sizePolicy().hasHeightForWidth()) self.QRGroup.setSizePolicy(sizePolicy1) self.QRGroup.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter) self.verticalLayout_3 = QVBoxLayout(self.QRGroup) self.verticalLayout_3.setSpacing(6) self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.verticalLayout_3.setContentsMargins(2, 2, 2, 2) self.GetQRfromCameraBtn = QPushButton(self.QRGroup) self.GetQRfromCameraBtn.setObjectName(u"GetQRfromCameraBtn") self.verticalLayout_3.addWidget(self.GetQRfromCameraBtn) self.LoadQRfromFileBtn = QPushButton(self.QRGroup) self.LoadQRfromFileBtn.setObjectName(u"LoadQRfromFileBtn") self.verticalLayout_3.addWidget(self.LoadQRfromFileBtn) self.GetQRfromClipboardBtn = QPushButton(self.QRGroup) self.GetQRfromClipboardBtn.setObjectName(u"GetQRfromClipboardBtn") self.verticalLayout_3.addWidget(self.GetQRfromClipboardBtn) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_3.addItem(self.verticalSpacer) self.horizontalLayout_3.addWidget(self.QRGroup) self.SlipDataGroup = QGroupBox(self.InputFrame) self.SlipDataGroup.setObjectName(u"SlipDataGroup") sizePolicy1.setHeightForWidth( self.SlipDataGroup.sizePolicy().hasHeightForWidth()) self.SlipDataGroup.setSizePolicy(sizePolicy1) self.gridLayout_2 = QGridLayout(self.SlipDataGroup) self.gridLayout_2.setObjectName(u"gridLayout_2") self.gridLayout_2.setContentsMargins(2, 2, 2, 2) self.GetSlipBtn = QPushButton(self.SlipDataGroup) self.GetSlipBtn.setObjectName(u"GetSlipBtn") self.gridLayout_2.addWidget(self.GetSlipBtn, 7, 1, 1, 1) self.AmountLbl = QLabel(self.SlipDataGroup) self.AmountLbl.setObjectName(u"AmountLbl") self.gridLayout_2.addWidget(self.AmountLbl, 0, 2, 1, 1) self.SlipTimstamp = QDateTimeEdit(self.SlipDataGroup) self.SlipTimstamp.setObjectName(u"SlipTimstamp") self.SlipTimstamp.setTimeSpec(Qt.UTC) self.gridLayout_2.addWidget(self.SlipTimstamp, 0, 1, 1, 1) self.TimestampLbl = QLabel(self.SlipDataGroup) self.TimestampLbl.setObjectName(u"TimestampLbl") self.gridLayout_2.addWidget(self.TimestampLbl, 0, 0, 1, 1) self.FDlbl = QLabel(self.SlipDataGroup) self.FDlbl.setObjectName(u"FDlbl") self.gridLayout_2.addWidget(self.FDlbl, 2, 0, 1, 1) self.SlipAmount = QLineEdit(self.SlipDataGroup) self.SlipAmount.setObjectName(u"SlipAmount") self.gridLayout_2.addWidget(self.SlipAmount, 0, 3, 1, 1) self.FP = QLineEdit(self.SlipDataGroup) self.FP.setObjectName(u"FP") self.gridLayout_2.addWidget(self.FP, 2, 3, 1, 1) self.FD = QLineEdit(self.SlipDataGroup) self.FD.setObjectName(u"FD") self.gridLayout_2.addWidget(self.FD, 2, 1, 1, 1) self.FNlbl = QLabel(self.SlipDataGroup) self.FNlbl.setObjectName(u"FNlbl") self.gridLayout_2.addWidget(self.FNlbl, 4, 0, 1, 1) self.DummyLbl = QLabel(self.SlipDataGroup) self.DummyLbl.setObjectName(u"DummyLbl") self.gridLayout_2.addWidget(self.DummyLbl, 7, 0, 1, 1) self.SlipTypeLbl = QLabel(self.SlipDataGroup) self.SlipTypeLbl.setObjectName(u"SlipTypeLbl") self.gridLayout_2.addWidget(self.SlipTypeLbl, 4, 2, 1, 1) self.FN = QLineEdit(self.SlipDataGroup) self.FN.setObjectName(u"FN") self.gridLayout_2.addWidget(self.FN, 4, 1, 1, 1) self.LoadJSONfromFileBtn = QPushButton(self.SlipDataGroup) self.LoadJSONfromFileBtn.setObjectName(u"LoadJSONfromFileBtn") self.gridLayout_2.addWidget(self.LoadJSONfromFileBtn, 7, 3, 1, 1) self.FPlbl = QLabel(self.SlipDataGroup) self.FPlbl.setObjectName(u"FPlbl") self.gridLayout_2.addWidget(self.FPlbl, 2, 2, 1, 1) self.line = QFrame(self.SlipDataGroup) self.line.setObjectName(u"line") self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.gridLayout_2.addWidget(self.line, 5, 0, 1, 4) self.SlipType = QComboBox(self.SlipDataGroup) self.SlipType.addItem("") self.SlipType.addItem("") self.SlipType.setObjectName(u"SlipType") self.gridLayout_2.addWidget(self.SlipType, 4, 3, 1, 1) self.horizontalLayout_3.addWidget(self.SlipDataGroup) self.CameraGroup = QGroupBox(self.InputFrame) self.CameraGroup.setObjectName(u"CameraGroup") self.verticalLayout_2 = QVBoxLayout(self.CameraGroup) self.verticalLayout_2.setSpacing(2) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(2, 2, 2, 2) self.ScannerQR = QRScanner(self.CameraGroup) self.ScannerQR.setObjectName(u"ScannerQR") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth( self.ScannerQR.sizePolicy().hasHeightForWidth()) self.ScannerQR.setSizePolicy(sizePolicy2) self.verticalLayout_2.addWidget(self.ScannerQR) self.CameraBtnFrame = QFrame(self.CameraGroup) self.CameraBtnFrame.setObjectName(u"CameraBtnFrame") self.CameraBtnFrame.setFrameShape(QFrame.NoFrame) self.CameraBtnFrame.setFrameShadow(QFrame.Plain) self.horizontalLayout_5 = QHBoxLayout(self.CameraBtnFrame) self.horizontalLayout_5.setSpacing(2) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.StopCameraBtn = QPushButton(self.CameraBtnFrame) self.StopCameraBtn.setObjectName(u"StopCameraBtn") self.horizontalLayout_5.addWidget(self.StopCameraBtn) self.verticalLayout_2.addWidget(self.CameraBtnFrame) self.horizontalLayout_3.addWidget(self.CameraGroup) self.verticalLayout.addWidget(self.InputFrame) self.SlipGroup = QGroupBox(ImportSlipDlg) self.SlipGroup.setObjectName(u"SlipGroup") sizePolicy2.setHeightForWidth( self.SlipGroup.sizePolicy().hasHeightForWidth()) self.SlipGroup.setSizePolicy(sizePolicy2) self.gridLayout = QGridLayout(self.SlipGroup) self.gridLayout.setObjectName(u"gridLayout") self.gridLayout.setContentsMargins(2, 2, 2, 2) self.SlipDateTime = QDateTimeEdit(self.SlipGroup) self.SlipDateTime.setObjectName(u"SlipDateTime") self.SlipDateTime.setTimeSpec(Qt.UTC) self.gridLayout.addWidget(self.SlipDateTime, 2, 1, 1, 1) self.DateTimeLbl = QLabel(self.SlipGroup) self.DateTimeLbl.setObjectName(u"DateTimeLbl") self.gridLayout.addWidget(self.DateTimeLbl, 1, 1, 1, 1) self.CorrespondenceLbl = QLabel(self.SlipGroup) self.CorrespondenceLbl.setObjectName(u"CorrespondenceLbl") self.gridLayout.addWidget(self.CorrespondenceLbl, 3, 2, 1, 1) self.PeerEdit = PeerSelector(self.SlipGroup) self.PeerEdit.setObjectName(u"PeerEdit") self.gridLayout.addWidget(self.PeerEdit, 3, 3, 1, 1) self.PeerLbl = QLabel(self.SlipGroup) self.PeerLbl.setObjectName(u"PeerLbl") self.gridLayout.addWidget(self.PeerLbl, 3, 0, 1, 1) self.SlipShopName = QLineEdit(self.SlipGroup) self.SlipShopName.setObjectName(u"SlipShopName") self.SlipShopName.setEnabled(False) self.gridLayout.addWidget(self.SlipShopName, 3, 1, 1, 1) self.LinesLbl = QLabel(self.SlipGroup) self.LinesLbl.setObjectName(u"LinesLbl") self.LinesLbl.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) self.gridLayout.addWidget(self.LinesLbl, 4, 0, 1, 1) self.AccountLbl = QLabel(self.SlipGroup) self.AccountLbl.setObjectName(u"AccountLbl") self.gridLayout.addWidget(self.AccountLbl, 1, 3, 1, 1) self.AccountEdit = AccountSelector(self.SlipGroup) self.AccountEdit.setObjectName(u"AccountEdit") self.gridLayout.addWidget(self.AccountEdit, 2, 3, 1, 1) self.LinesTableView = QTableView(self.SlipGroup) self.LinesTableView.setObjectName(u"LinesTableView") self.LinesTableView.verticalHeader().setVisible(False) self.LinesTableView.verticalHeader().setMinimumSectionSize(20) self.LinesTableView.verticalHeader().setDefaultSectionSize(20) self.gridLayout.addWidget(self.LinesTableView, 4, 1, 1, 4) self.AssignCategoryBtn = QPushButton(self.SlipGroup) self.AssignCategoryBtn.setObjectName(u"AssignCategoryBtn") self.gridLayout.addWidget(self.AssignCategoryBtn, 2, 4, 1, 1) self.AssignTagBtn = QPushButton(self.SlipGroup) self.AssignTagBtn.setObjectName(u"AssignTagBtn") self.gridLayout.addWidget(self.AssignTagBtn, 3, 4, 1, 1) self.verticalLayout.addWidget(self.SlipGroup) self.DialogButtonsFrame = QFrame(ImportSlipDlg) self.DialogButtonsFrame.setObjectName(u"DialogButtonsFrame") self.DialogButtonsFrame.setFrameShape(QFrame.NoFrame) self.DialogButtonsFrame.setFrameShadow(QFrame.Plain) self.horizontalLayout_4 = QHBoxLayout(self.DialogButtonsFrame) self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.horizontalLayout_4.setContentsMargins(2, 2, 2, 2) self.ClearBtn = QPushButton(self.DialogButtonsFrame) self.ClearBtn.setObjectName(u"ClearBtn") self.ClearBtn.setEnabled(True) self.horizontalLayout_4.addWidget(self.ClearBtn) self.AddOperationBtn = QPushButton(self.DialogButtonsFrame) self.AddOperationBtn.setObjectName(u"AddOperationBtn") self.AddOperationBtn.setEnabled(True) self.horizontalLayout_4.addWidget(self.AddOperationBtn) self.CloseBtn = QPushButton(self.DialogButtonsFrame) self.CloseBtn.setObjectName(u"CloseBtn") self.horizontalLayout_4.addWidget(self.CloseBtn) self.verticalLayout.addWidget(self.DialogButtonsFrame) self.retranslateUi(ImportSlipDlg) self.CloseBtn.clicked.connect(ImportSlipDlg.close) QMetaObject.connectSlotsByName(ImportSlipDlg)
def __init__(self, parent, chunks, fname): super().__init__(parent) self.setWindowTitle(f"XDF Chunks ({fname})") self.chunks = chunks TAGS = { 1: "FileHeader", 2: "StreamHeader", 3: "Samples", 4: "ClockOffset", 5: "Boundary", 6: "StreamFooter" } self.model = QStandardItemModel() self.model.setHorizontalHeaderLabels( ["#", "Bytes", "Tag", "Stream ID"]) for i, chunk in enumerate(chunks, start=1): row = [] row.append(_add_item(i)) row.append(_add_item(chunk["nbytes"])) row.append(_add_item(f"{chunk['tag']} ({TAGS[chunk['tag']]})")) row.append(_add_item(chunk.get("stream_id", ""))) self.model.appendRow(row) self.view = QTableView() self.view.setModel(self.model) self.view.verticalHeader().setVisible(False) self.view.horizontalHeader().setStretchLastSection(True) self.view.setShowGrid(False) self.view.setSelectionMode(QAbstractItemView.SingleSelection) self.view.setSelectionBehavior(QAbstractItemView.SelectRows) self.view.setSortingEnabled(True) self.view.sortByColumn(0, Qt.AscendingOrder) self.view.setEditTriggers(QTableView.NoEditTriggers) self.view.setFixedWidth(450) self.details = QPlainTextEdit("") self.details.setFixedWidth(450) self.details.setReadOnly(True) self.details.setTabStopDistance(30) font = QFont() font.setFamily("monospace") font.setStyleHint(QFont.Monospace) self.details.setFont(font) self.details.setLineWrapMode(QPlainTextEdit.NoWrap) hbox = QHBoxLayout() hbox.addWidget(self.view) hbox.addWidget(self.details) vbox = QVBoxLayout(self) vbox.addLayout(hbox) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok) vbox.addWidget(self.buttonbox) self.buttonbox.accepted.connect(self.accept) self.view.clicked.connect(self._update_details) self.setFixedSize(980, 650) self.view.setColumnWidth(0, 70) self.view.setColumnWidth(1, 80) self.view.setColumnWidth(2, 150) self.view.setColumnWidth(3, 70)
def setupUi(self, tfm): if not tfm.objectName(): tfm.setObjectName(u"tfm") tfm.resize(800, 600) tfm.setContextMenuPolicy(Qt.NoContextMenu) tfm.setLocale(QLocale(QLocale.English, QLocale.UnitedStates)) self.action_menu = QAction(tfm) self.action_menu.setObjectName(u"action_menu") self.action_new_dir = QAction(tfm) self.action_new_dir.setObjectName(u"action_new_dir") self.action_new_file = QAction(tfm) self.action_new_file.setObjectName(u"action_new_file") self.action_back = QAction(tfm) self.action_back.setObjectName(u"action_back") self.action_up = QAction(tfm) self.action_up.setObjectName(u"action_up") self.action_home = QAction(tfm) self.action_home.setObjectName(u"action_home") self.action_go = QAction(tfm) self.action_go.setObjectName(u"action_go") self.action_forward = QAction(tfm) self.action_forward.setObjectName(u"action_forward") self.action_copy = QAction(tfm) self.action_copy.setObjectName(u"action_copy") self.action_paste = QAction(tfm) self.action_paste.setObjectName(u"action_paste") self.action_cut = QAction(tfm) self.action_cut.setObjectName(u"action_cut") self.action_show_hidden = QAction(tfm) self.action_show_hidden.setObjectName(u"action_show_hidden") self.action_show_hidden.setCheckable(True) self.action_delete = QAction(tfm) self.action_delete.setObjectName(u"action_delete") self.action_rename = QAction(tfm) self.action_rename.setObjectName(u"action_rename") self.action_add_to_bookmarks = QAction(tfm) self.action_add_to_bookmarks.setObjectName(u"action_add_to_bookmarks") self.action_remove_bookmark = QAction(tfm) self.action_remove_bookmark.setObjectName(u"action_remove_bookmark") self.action_copy_path = QAction(tfm) self.action_copy_path.setObjectName(u"action_copy_path") self.action_extract_here = QAction(tfm) self.action_extract_here.setObjectName(u"action_extract_here") self.action_mount_iso = QAction(tfm) self.action_mount_iso.setObjectName(u"action_mount_iso") self.centralwidget = QWidget(tfm) self.centralwidget.setObjectName(u"centralwidget") self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setObjectName(u"horizontalLayout") self.vsplit = QSplitter(self.centralwidget) self.vsplit.setObjectName(u"vsplit") self.vsplit.setOrientation(Qt.Horizontal) self.hsplit = QSplitter(self.vsplit) self.hsplit.setObjectName(u"hsplit") self.hsplit.setOrientation(Qt.Vertical) self.fs_tree = QTreeView(self.hsplit) self.fs_tree.setObjectName(u"fs_tree") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.fs_tree.sizePolicy().hasHeightForWidth()) self.fs_tree.setSizePolicy(sizePolicy) self.fs_tree.setTabKeyNavigation(True) self.fs_tree.setProperty("showDropIndicator", True) self.fs_tree.setDragEnabled(False) self.fs_tree.setDragDropMode(QAbstractItemView.DropOnly) self.fs_tree.setDefaultDropAction(Qt.MoveAction) self.fs_tree.setRootIsDecorated(False) self.hsplit.addWidget(self.fs_tree) self.fs_tree.header().setVisible(False) self.bookmark_view = QListView(self.hsplit) self.bookmark_view.setObjectName(u"bookmark_view") self.bookmark_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.bookmark_view.setEditTriggers(QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.bookmark_view.setTabKeyNavigation(True) self.bookmark_view.setDragDropOverwriteMode(True) self.bookmark_view.setDragDropMode(QAbstractItemView.DropOnly) self.bookmark_view.setDefaultDropAction(Qt.CopyAction) self.bookmark_view.setAlternatingRowColors(True) self.hsplit.addWidget(self.bookmark_view) self.mounts_view = QListView(self.hsplit) self.mounts_view.setObjectName(u"mounts_view") self.mounts_view.setTabKeyNavigation(True) self.mounts_view.setAlternatingRowColors(True) self.hsplit.addWidget(self.mounts_view) self.vsplit.addWidget(self.hsplit) self.table_view = QTableView(self.vsplit) self.table_view.setObjectName(u"table_view") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy1.setHorizontalStretch(1) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.table_view.sizePolicy().hasHeightForWidth()) self.table_view.setSizePolicy(sizePolicy1) self.table_view.viewport().setProperty("cursor", QCursor(Qt.ArrowCursor)) self.table_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.table_view.setAcceptDrops(True) self.table_view.setToolTipDuration(-3) self.table_view.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.table_view.setDragEnabled(True) self.table_view.setDragDropMode(QAbstractItemView.DragDrop) self.table_view.setDefaultDropAction(Qt.MoveAction) self.table_view.setAlternatingRowColors(True) self.table_view.setSelectionMode(QAbstractItemView.ExtendedSelection) self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.table_view.setTextElideMode(Qt.ElideMiddle) self.table_view.setShowGrid(False) self.table_view.setSortingEnabled(True) self.table_view.setWordWrap(False) self.vsplit.addWidget(self.table_view) self.table_view.horizontalHeader().setDefaultSectionSize(150) self.table_view.horizontalHeader().setHighlightSections(False) self.table_view.horizontalHeader().setStretchLastSection(True) self.table_view.verticalHeader().setVisible(False) self.horizontalLayout.addWidget(self.vsplit) tfm.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(tfm) self.statusbar.setObjectName(u"statusbar") self.statusbar.setContextMenuPolicy(Qt.NoContextMenu) self.statusbar.setSizeGripEnabled(False) tfm.setStatusBar(self.statusbar) self.toolbar = QToolBar(tfm) self.toolbar.setObjectName(u"toolbar") self.toolbar.setContextMenuPolicy(Qt.PreventContextMenu) self.toolbar.setMovable(False) tfm.addToolBar(Qt.TopToolBarArea, self.toolbar) self.toolbar.addAction(self.action_back) self.toolbar.addAction(self.action_forward) self.toolbar.addAction(self.action_up) self.toolbar.addAction(self.action_home) self.toolbar.addAction(self.action_go) self.retranslateUi(tfm) QMetaObject.connectSlotsByName(tfm)