def CreateApp(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0,0,0,0) # Create Tabs self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CloseTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) self.tabbar.setDrawBase(False) # Create a shortcut key for a new tab self.shortcutNewTab = QShortcut(QKeySequence("Ctrl+T"), self) self.shortcutNewTab.activated.connect(self.AddTab) # keep track of tabs self.tabCount = 0 self.tabs = [] # Create Addressbar self.Toolbar = QWidget() self.Toolbar.setObjectName("Toolbar") self.ToolbarLayout = QHBoxLayout() self.addressbar = AddressBar() self.AddTabButton = QPushButton("+") # Connect Addressbar + button signals self.addressbar.returnPressed.connect(self.BrowseTo) self.AddTabButton.clicked.connect(self.AddTab) # set toolbar buttons and signals self.BackButton = QPushButton("<") self.BackButton.clicked.connect(self.GoBack) self.ForwardButton = QPushButton(">") self.ForwardButton.clicked.connect(self.GoForward) self.ReloadButton = QPushButton("↻") self.ReloadButton.clicked.connect(self.GoReload) # Build toolbar self.Toolbar.setLayout(self.ToolbarLayout) self.ToolbarLayout.addWidget(self.BackButton) self.ToolbarLayout.addWidget(self.ForwardButton) self.ToolbarLayout.addWidget(self.ReloadButton) self.ToolbarLayout.addWidget(self.addressbar) self.ToolbarLayout.addWidget(self.AddTabButton) # set main view self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) # construct main view self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) self.AddTab() self.show()
def CreateApp(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) # Tabbar(tabs) self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.closeTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) # keep tracks of tabs self.tabCount = 0 self.tabs = [] # toolbar items # back,forward,reload button (item 1) self.BackButton = QPushButton("<") self.ForwardButton = QPushButton(">") self.ReloadButton = QPushButton("R") self.BackButton.clicked.connect(self.GoBack) self.ForwardButton.clicked.connect(self.GoForward) self.ReloadButton.clicked.connect(self.ReloadPage) # Address (item 2) self.addressbar = AddressBar() self.addressbar.returnPressed.connect(self.BrowseTo) # new tab button (item 3) self.AddTabButton = QPushButton("+") self.AddTabButton.clicked.connect(self.AddTab) # Toolbar self.Toolbar = QWidget() self.ToolbarLayout = QHBoxLayout() self.Toolbar.setLayout(self.ToolbarLayout) # adding buttons and addressbar in toolbar self.ToolbarLayout.addWidget(self.BackButton) self.ToolbarLayout.addWidget(self.ForwardButton) self.ToolbarLayout.addWidget(self.ReloadButton) self.ToolbarLayout.addWidget(self.addressbar) self.ToolbarLayout.addWidget(self.AddTabButton) # main view (container) self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) # adding widget to main layout: tabbar,toolbar,container self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) self.AddTab() self.show()
def _setupUi(self): self.setWindowTitle(self.app.NAME) self.resize(640, 480) self.tabBar = QTabBar() self.verticalLayout = QVBoxLayout() self.verticalLayout.setContentsMargins(0, 0, 0, 0) self._setupActions() self._setupMenu() self.centralWidget = QWidget(self) self.setCentralWidget(self.centralWidget) self.stackedWidget = QStackedWidget() self.centralWidget.setLayout(self.verticalLayout) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.addWidget(self.menubar, 0, Qt.AlignTop) self.horizontalLayout.addWidget(self.tabBar, 0, Qt.AlignTop) self.verticalLayout.addLayout(self.horizontalLayout) self.verticalLayout.addWidget(self.stackedWidget) self.tabBar.currentChanged.connect(self.showWidget) self.tabBar.tabCloseRequested.connect(self.onTabCloseRequested) self.stackedWidget.currentChanged.connect(self.updateMenuBar) self.stackedWidget.widgetRemoved.connect(self.onRemovedWidget) self.tabBar.setTabsClosable(True) self.restoreGeometry()
def help_tab(): vcontrols = QLabel("view controls:") lmd = QLabel( "\tmouse dragging with left mouse button:\n\t\trotation (only in 3D)") rmd = QLabel( "\tmouse dragging with right mouse button:\n\t\tdragging the view") mw = QLabel("\tscrolling:\n\t\tzooming") ccontrols = QLabel("\ncursor controls:") sc = QLabel("\tholding 'CTRL':\n\t\tshow cursor") mcc = QLabel( "\tleft mouse button click while holding 'CTRL':\n\t\tadding/removing matter at cursors position" ) mwc = QLabel( "\tscrolling while holding 'CTRL':\n\t\tmoving the cursor in the relative z-direction" ) scontrols = QLabel("\nsimulation controls:") sss = QLabel("\tspacebar:\n\t\tstart / stop the simulation") vbox = QVBoxLayout() vbox.addWidget(vcontrols) vbox.addWidget(lmd) vbox.addWidget(rmd) vbox.addWidget(mw) vbox.addWidget(ccontrols) vbox.addWidget(sc) vbox.addWidget(mcc) vbox.addWidget(mwc) vbox.addWidget(scontrols) vbox.addWidget(sss) vbox.addStretch(0) tabbar = QTabBar() tabbar.setLayout(vbox) return tabbar
def __init__(self, QWidget_parent=None): super(XTabWidget, self).__init__(QWidget_parent) # setup self frame self.setFrameShadow(QFrame.Raised) # self.setFrameShape(QFrame.StyledPanel) self.setFrameShape(QFrame.NoFrame) # layouts self._layout = QVBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(2) self._layout_top = QHBoxLayout() self._layout_top.setContentsMargins(0, 0, 0, 0) # stacked widget self._stack = QStackedWidget(self) # tab bar self._tabbar = QTabBar(self) self._tabbar.setTabsClosable(True) self._tabbar.setMovable(False) self._tabbar.setExpanding(False) self._tabbar.setShape(QTabBar.RoundedNorth) self._tabbar.currentChanged.connect(self.on_tab_current_changed) self._tabbar.tabCloseRequested.connect(self.on_tab_close_requested) # button "add" self._btn_add = QPushButton('+', self) self._btn_add.setMaximumSize(QSize(22, 22)) self._btn_add.clicked.connect(self.on_btn_add_clicked) # complete layout self._layout_top.addWidget(self._btn_add, 0, Qt.AlignVCenter) self._layout_top.addWidget(self._tabbar, 1, Qt.AlignVCenter) self._layout.addLayout(self._layout_top) self._layout.addWidget(self._stack) self.setLayout(self._layout)
def buttons(self): self.armorbox = QComboBox() self.wpnbox = QComboBox() self.mapbox = QComboBox() self.markettab = QTabBar() self.markettab.setShape(1) self.marketbox = QComboBox() self.markettab.addTab('Weapons') self.markettab.addTab('Armor') self.buybtn = QPushButton('Buy') buttons_names = [ 'Start', 'Load', 'Attack', 'Escape', 'Inventory', 'Save', 'Search for a treasure', 'Opponent', 'Map', 'Change weapon', 'Leave inventory', 'Change armor', 'Change location', 'Exit Map', 'Buy', 'Market', 'Exit Market', 'Sell garbage' ] self.buttons_dict = [ 'startbtn', 'loadbtn', 'atkbtn', 'escbtn', 'invbtn', 'savebtn', 'srbtn', 'fndbtn', 'mapbtn', 'cngwpnbtn', 'extinvbtn', 'cngarmorbtn', 'cnglocbtn', 'extmapbtn', 'buybtn', 'marketbtn', 'extmarket', 'sellbtn' ] for x, y in zip_longest(self.buttons_dict, buttons_names): exec('self.%s = QPushButton("%s")' % (x, y))
def make_tab_bar(self): self.tab_bar = QTabBar() #Uses self.tab_names self.ind_tab_0 = self.tab_bar.addTab(self.tab_names[0]) self.ind_tab_1 = self.tab_bar.addTab(self.tab_names[1]) self.tab_bar.setTabTextColor(self.ind_tab_0, QColor('magenta')) self.tab_bar.setTabTextColor(self.ind_tab_1, QColor('magenta')) self.tab_bar.setShape(QTabBar.RoundedNorth) #self.tab_bar.setTabsClosable(True) #self.tab_bar.setMovable(True) #self.tab_bar.setTabEnabled(1, False) #self.tab_bar.setTabEnabled(2, False) tab_index = self.tab_names.index(cp.current_config_tab.value()) #try : # tab_index = self.tab_names.index(cp.current_config_tab.value()) #except : # tab_index = 1 # cp.current_config_tab.setValue(self.tab_names[tab_index]) self.tab_bar.setCurrentIndex(tab_index) logger.debug(' make_tab_bar - set tab: ' + cp.current_config_tab.value()) #self.connect(self.tab_bar, QtCore.SIGNAL('currentChanged(int)'), self.on_tab_bar) self.tab_bar.currentChanged[int].connect(self.on_tab_bar)
def CreateApp(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) # Create tabs self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CloseTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) self.tabbar.setDrawBase(False) # Keep track of tabs self.tabCount = 0 self.tabs = [] # Create AddressBar self.Toolbar = QWidget() self.ToolbarLayout = QHBoxLayout() self.addressbar = AddressBar() self.addressbar.returnPressed.connect(self.BrowseTo) # Set Toolbar buttons self.BackButton = QPushButton("<") self.BackButton.clicked.connect(self.GoBack) self.ForwardButton = QPushButton(">") self.ForwardButton.clicked.connect(self.GoForward) self.ReloadButton = QPushButton("R") self.ReloadButton.clicked.connect(self.ReloadPage) self.Toolbar.setLayout(self.ToolbarLayout) self.ToolbarLayout.addWidget(self.BackButton) self.ToolbarLayout.addWidget(self.ForwardButton) self.ToolbarLayout.addWidget(self.ReloadButton) self.ToolbarLayout.addWidget(self.addressbar) # New tab button self.AddTabButton = QPushButton("+") self.AddTabButton.clicked.connect(self.AddTab) self.ToolbarLayout.addWidget(self.AddTabButton) # Set main view self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) self.AddTab() self.show()
def __init__(self, parent=None): super().__init__(parent) self.tabs = [] self.shutting_down = False self._qtabbar = QTabBar() self.index_of = None self.current_index = None self.opened_url = None
def __init__(self, parent=None): super().__init__(parent) self.tabs = [] self._qtabbar = QTabBar() self.index_of = None self.current_index = None self._window = None self.current_widget = None
def matter_tab(): tab = QTabBar() layout = QVBoxLayout() layout.addLayout(get_scaler(MatterType.AGENT)) layout.addLayout(get_scaler(MatterType.ITEM)) layout.addLayout(get_scaler(MatterType.LOCATION)) layout.addStretch(1) tab.setLayout(layout) return tab
def CreateApp(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) # create tabs self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CloseTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) # keep track of all tabs self.tabCount = 0 self.tabs = [] # create address bar self.Toolbar = QWidget() self.ToolbarLayout = QHBoxLayout() self.AddressBar = AddressBar() self.AddressBar.returnPressed.connect(self.BrowseTo) # create new tab button self.AddTabButton = QPushButton("+") self.AddTabButton.clicked.connect(self.AddTab) # create functional buttons - back, forward and reload self.BackButton = QPushButton("<") self.BackButton.clicked.connect(self.GoBack) self.ForwardButton = QPushButton(">") self.ForwardButton.clicked.connect(self.GoForward) self.ReloadButton = QPushButton("R") self.ReloadButton.clicked.connect(self.ReloadPage) # append toolbar and buttons self.Toolbar.setLayout(self.ToolbarLayout) self.ToolbarLayout.addWidget(self.BackButton) self.ToolbarLayout.addWidget(self.ForwardButton) self.ToolbarLayout.addWidget(self.ReloadButton) self.ToolbarLayout.addWidget(self.AddressBar) self.ToolbarLayout.addWidget(self.AddTabButton) # set main view self.Container = QWidget() self.Container.Layout = QStackedLayout() self.Container.setLayout(self.Container.Layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.Container) self.setLayout(self.layout) self.show()
def CreateApp(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CloseTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) self.tabbar.setDrawBase(False) self.shortcutNewTab = QShortcut(QKeySequence("Ctrl+T"), self) self.shortcutNewTab.activated.connect(self.AddTab) self.shortcutReload = QShortcut(QKeySequence("Ctrl+R"), self) self.shortcutReload.activated.connect(self.ReloadPage) self.tabCount = 0 self.tabs = [] self.addressbar = AddressBar() self.Toolbar = QWidget() self.Toolbar.setObjectName("Toolbar") self.ToolbarLayout = QHBoxLayout() self.Toolbar.setLayout(self.ToolbarLayout) self.BackButton = QPushButton("<") self.BackButton.clicked.connect(self.GoBack) self.ForwardButton = QPushButton(">") self.ForwardButton.clicked.connect(self.GoForward) self.ToolbarLayout.addWidget(self.BackButton) self.ToolbarLayout.addWidget(self.ForwardButton) self.ReloadButton = QPushButton("R") self.ReloadButton.clicked.connect(self.ReloadPage) self.ToolbarLayout.addWidget(self.ReloadButton) self.ToolbarLayout.addWidget(self.addressbar) self.AddTabButton = QPushButton("+") self.addressbar.returnPressed.connect(self.BrowseTo) self.AddTabButton.clicked.connect(self.AddTab) self.ToolbarLayout.addWidget(self.AddTabButton) self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) self.AddTab() self.show()
def generateDragPixmap ( self, toolWindows ): ''' 生成一个QTabBar的快照 ''' widget = QTabBar () widget.setDocumentMode (True) for toolWindow in toolWindows: widget.addTab (toolWindow.windowIcon (), toolWindow.windowTitle ()) #if QT_VERSION >= 0x050000 # Qt5 return widget.grab ()
def grid_tab(): tab = QTabBar() layout = QVBoxLayout() layout.addLayout(get_grid_lines_scale_slider()) layout.addLayout(get_grid_coordinates_scale_slider()) layout.addLayout(get_show_checkboxes()) layout.addLayout(recalculate_grid()) layout.addLayout(get_color_picker()) layout.addStretch(0) tab.setLayout(layout) return tab
def initUi(self): self.tabBar = QTabBar() self.consoleView = ConsoleWindow() self.tabBar.tabBarClicked.connect(self.status) self.tabBar.setExpanding(False) self.setTabBar(self.tabBar) self.addTab(self.consoleView,IconTool.buildQIcon('logcat.png'), "Logcat") self.consoleView.setVisible(False) self.setFixedHeight(Utils.getItemHeight()) self.setTabPosition(QTabWidget.South) self.setStyleSheet("QTabBar::tab {border: none; height: "+str(Utils.getItemHeight())+"px; width:100px;color:black;}" "QTabBar::tab:selected { border: none;background: lightgray; } ")
def mysubwindow(self): self.mdi = QMdiArea() self.setCentralWidget(self.mdi) self.sub = QMdiSubWindow() self.sub.setGeometry(10, 10, width - 30, height - 100) self.tabbar = QTabBar() self.sub.setWidget(self.tabbar) self.tabbar.addTab("Test1") self.tabbar.addTab("Test2") self.sub.setWindowTitle("subwindow") self.mdi.addSubWindow(self.sub) self.sub.show()
def setup_ui(self): w = QWidget() self.layout = QGridLayout() w.setLayout(self.layout) self.setCentralWidget(w) self.tab = QTabWidget(w) qtabBAR = QTabBar() self.tab.setTabBar(qtabBAR) # 允许tab点击关闭 self.tab.setTabsClosable(True) self.tab.tabCloseRequested.connect(self.tab_close) self.tab.currentChanged.connect(self.tab_changed)
def CreateApplication(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) #Create Tabs self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CloseTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) self.tabbar.setDrawBase(False) self.tabbar.setLayoutDirection(Qt.LeftToRight) self.tabbar.setElideMode(Qt.ElideLeft) # Keep Track at Tabs self.tabCount = 0 self.tabs = [] #Create AddressBar self.Toolbar = QWidget() self.Toolbar.setObjectName("Toolbar") self.Toolbarlayout = QHBoxLayout() self.addressb = AdressB() self.AddTabButton = QPushButton("🞢") #Connect addressbar + button signals self.addressb.returnPressed.connect(self.Browse) self.AddTabButton.clicked.connect(self.AddTab) #Set toolbar buttons self.BackButton = QPushButton("🠜") self.BackButton.clicked.connect(self.GoBack) self.ForwardButton = QPushButton("🠞") self.ForwardButton.clicked.connect(self.GoForward) self.ReloadButton = QPushButton("â®") self.ReloadButton.clicked.connect(self.ReloadPage) #Build a toolbar self.Toolbar.setLayout(self.Toolbarlayout) self.Toolbarlayout.addWidget(self.BackButton) self.Toolbarlayout.addWidget(self.ForwardButton) self.Toolbarlayout.addWidget(self.ReloadButton) self.Toolbarlayout.addWidget(self.addressb) self.Toolbarlayout.addWidget(self.AddTabButton) # Set Main View self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) self.AddTab() self.show()
def setupUi(self, MainWindow): super().setupUi(MainWindow) # chrome init self.qwebView = QWebEngineView(self.groupBox_4) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.qwebView.sizePolicy().hasHeightForWidth()) self.qwebView.setSizePolicy(sizePolicy) self.qwebView.setObjectName("qwebView") self.verticalLayout_8.addWidget(self.qwebView) # tabbar init self.tabBar = QTabBar(self.groupBox_6) self.tabBar.setObjectName("tabBar") self.verticalLayout_5.insertWidget(1, self.tabBar)
def _setupUi(self): self.setWindowTitle(tr("Import")) self.resize(557, 407) self.verticalLayout = QVBoxLayout(self) self.tabView = QTabBar(self) self.tabView.setMinimumSize(QtCore.QSize(0, 20)) self.verticalLayout.addWidget(self.tabView) self.targetAccountLayout = QHBoxLayout() self.targetAccountLabel = QLabel(tr("Target Account:")) self.targetAccountLayout.addWidget(self.targetAccountLabel) self.targetAccountComboBox = QComboBox(self) self.targetAccountComboBox.setMinimumSize(QtCore.QSize(150, 0)) self.targetAccountLayout.addWidget(self.targetAccountComboBox) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.targetAccountLayout.addItem(spacerItem) self.groupBox = QGroupBox(tr("Are some fields wrong? Fix them!")) self.gridLayout = QGridLayout(self.groupBox) self.swapOptionsComboBoxView = QComboBox(self.groupBox) self.gridLayout.addWidget(self.swapOptionsComboBoxView, 0, 0, 1, 2) self.applyToAllCheckBox = QCheckBox(tr("Apply to all accounts")) self.gridLayout.addWidget(self.applyToAllCheckBox, 1, 0, 1, 1) self.swapButton = QPushButton(tr("Fix")) self.gridLayout.addWidget(self.swapButton, 1, 1, 1, 1) self.targetAccountLayout.addWidget(self.groupBox) self.verticalLayout.addLayout(self.targetAccountLayout) self.tableView = TableView(self) self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers) self.tableView.setDragEnabled(True) self.tableView.setDragDropMode(QAbstractItemView.InternalMove) self.tableView.setSelectionMode(QAbstractItemView.ExtendedSelection) self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.horizontalHeader().setHighlightSections(False) self.tableView.horizontalHeader().setMinimumSectionSize(18) self.tableView.verticalHeader().setVisible(False) self.tableView.verticalHeader().setDefaultSectionSize(18) self.verticalLayout.addWidget(self.tableView) self.horizontalLayout = QHBoxLayout() spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.importButton = QPushButton(tr("Import")) self.horizontalLayout.addWidget(self.importButton) self.verticalLayout.addLayout(self.horizontalLayout) self.tabView.setTabsClosable(True) self.tabView.setDrawBase(False) self.tabView.setDocumentMode(True) self.tabView.setUsesScrollButtons(True)
def CrearApp(self): # CreateApp() self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) #- crear pestañas self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CerrarTab) self.tabbar.tabBarClicked.connect(self.CambiarTab) self.tabbar.setCurrentIndex(0) #- seguimiento de pestañas self.cuentaTab = 0 #tabCount self.tabs = [] #- crear barra de direcciones self.Toolbar = QWidget() self.ToolbarLayout = QHBoxLayout() self.addressbar = BarraDirecciones() self.Toolbar.setLayout(self.ToolbarLayout) self.ToolbarLayout.addWidget(self.addressbar) #- boton nueva pestaña self.botonAgregarTab = QPushButton('+') # AddTabButton self.addressbar.returnPressed.connect(self.IrA) self.botonAgregarTab.clicked.connect(self.AgregarTab) self.ToolbarLayout.addWidget(self.botonAgregarTab) #- establecer vista principal self.contenedor = QWidget() # container self.contenedor.layout = QStackedLayout() self.contenedor.setLayout(self.contenedor.layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.contenedor) self.setLayout(self.layout) self.AgregarTab() self.show()
def create_app(self): print("create app") self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0,0,0,0) # Create Tabs self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.close_tab) self.tabbar.tabBarClicked.connect(self.SwitchTab) self.tabbar.setCurrentIndex(0) # Keep track of tabs self.tabCount = 0 self.tabs =[] # Create AddressBar self.Toolbar = QWidget() self.ToolbarLayout = QHBoxLayout() self.addressbar = AddressBar() self.AddTabButton = QPushButton("+") self.addressbar.returnPressed.connect(self.BrowseTo) self.AddTabButton.clicked.connect(self.AddTab) self.Toolbar.setLayout(self.ToolbarLayout) self.ToolbarLayout.addWidget(self.addressbar) self.ToolbarLayout.addWidget(self.AddTabButton) # set main view self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) print("run show") self.AddTab() self.show()
def _MakeTabBar(self, shap, text, icons, fancy): ''' @param: shap QTabBar::Shap @param: text bool @param: icons bool @param: fancy bool ''' bar = QTabBar(self) bar.setShape(shap) bar.setDocumentMode(True) bar.setUsesScrollButtons(True) if shap == QTabBar.RoundedWest: bar.setIconSize(QSize(22, 22)) if fancy: bar.setStyle(self._proxy_style) if shap == QTabBar.RoundedNorth: self._top_layout.insertWidget(0, bar) else: self._side_layout.insertWidget(0, bar) # Item for item in self._items: if item.type != self.Item.Type_Tab: continue label = item.tab_label if shap == QTabBar.RoundedWest: label = QFontMetrics(self.font()).elidedText( label, Qt.ElideMiddle, 100) tab_id = -1 if icons and text: tab_id = bar.addTab(item.tab_icon, label) elif icons: tab_id = bar.addTab(item.tab_icon, '') elif text: tab_id = bar.addTab(label) bar.setTabToolTip(tab_id, item.tab_label) bar.setCurrentIndex(self._stack.currentIndex()) bar.currentChanged.connect(self._ShowWidget) self._tab_bar = bar
def make_tab_bar(self, start_tab_name): self.tab_bar = QTabBar() for tab_name in self.tab_names: tab_ind = self.tab_bar.addTab(tab_name) self.tab_bar.setTabTextColor(tab_ind, QColor('blue')) #gray, red, grayblue self.tab_bar.setShape(QTabBar.RoundedNorth) tab_index = self.tab_names.index(start_tab_name) self.tab_bar.setCurrentIndex(tab_index) logger.debug('make_tab_bar - set tab index: %d' % tab_index) self.tab_bar.currentChanged['int'].connect(self.on_tab_bar) self.tab_bar.tabCloseRequested.connect(self.on_tab_close_request) self.tab_bar.tabMoved[int, int].connect(self.on_tab_moved)
def CreateApp(self): self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) # Create Tabs self.tabbar = QTabBar(movable=True, tabsClosable=True) self.tabbar.tabCloseRequested.connect(self.CloseTab) self.tabbar.tabBarClicked.connect(self.SwitchTab) # self.tabbar.addTab("Tab 1") # self.tabbar.addTab("Tab 2") self.tabbar.setCurrentIndex(0) # Keep Track Of Tabs self.tabCount = 0 self.tabs = [] # Create Address Bar self.Toolbar = QWidget() self.ToolbarLayout = QHBoxLayout() self.addressbar = AddressBar() self.Toolbar.setLayout(self.ToolbarLayout) self.ToolbarLayout.addWidget(self.addressbar) self.AddTabButton = QPushButton("+") self.addressbar.returnPressed.connect(self.BrowseTo) self.AddTabButton.clicked.connect(self.AddTab) self.ToolbarLayout.addWidget(self.AddTabButton) self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) self.layout.addWidget(self.tabbar) self.layout.addWidget(self.Toolbar) self.layout.addWidget(self.container) self.setLayout(self.layout) self.AddTab() self.show()
def create_app(self): #main layout self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0,0,0,0) #tag self.qtbar = QTabBar(movable=True,tabsClosable=True) self.qtbar.tabCloseRequested.connect(self.closeTab) #tag plus self.addButton = QPushButton("+") self.addButton.clicked.connect(self.addtag) #addressbar -> search bar self.addressbar = addressBar() self.toolbar = QWidget() self.toolbarLayout = QHBoxLayout() self.toolbar.setLayout(self.toolbarLayout) self.toolbarLayout.addWidget(self.addressbar) self.toolbarLayout.addWidget(self.addButton) #To store tab and its content self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) #show the main app's image self.layout.addWidget(self.qtbar) self.layout.addWidget(self.toolbar) self.layout.addWidget(self.container) #record the tag self.tagcount = 0 self.tagObject = [] #initialize first tag self.addtag() self.setLayout(self.layout) self.show()
def make_tab_bar(self): self.tab_bar = QTabBar() self.ind_tab_0 = self.tab_bar.addTab(self.tab_names[0]) self.ind_tab_1 = self.tab_bar.addTab(self.tab_names[1]) self.tab_bar.setTabTextColor(self.ind_tab_0, QColor('magenta')) self.tab_bar.setTabTextColor(self.ind_tab_1, QColor('magenta')) self.tab_bar.setShape(QTabBar.RoundedNorth) tab_index = self.tab_names.index(cp.current_config_tab.value()) self.tab_bar.setCurrentIndex(tab_index) logger.debug(' make_tab_bar - set tab: ' + cp.current_config_tab.value()) #self.connect(self.tab_bar, QtCore.SIGNAL('currentChanged(int)'), self.on_tab_bar) self.tab_bar.currentChanged[int].connect(self.on_tab_bar)
def createEditor(self): self.tab_bar = QTabBar(movable=True, tabsClosable=True) self.tab_bar.tabCloseRequested.connect(self.CloseTab) self.tab_bar.tabBarClicked.connect(self.SwitchTab) self.tab_bar.setCurrentIndex(0) self.tab_bar.setLayoutDirection(Qt.LeftToRight) self.tab_bar.setElideMode(Qt.ElideLeft) self.tabCount = 0 self.activeTabs = 0 self.tabs = [] self.container = QWidget() self.container.layout = QStackedLayout() self.container.setLayout(self.container.layout) self.AddNewTab() self.layout.addWidget(self.tab_bar) self.layout.addWidget(self.container)
def populate_childs(self): # Add items, then sort them for mod in self.mod_doc_dict.keys(): self.mod_name_listbox.addItem(mod) self.mod_name_listbox.sortItems() # Set the size of the list boxes self.mod_name_listbox.setFixedSize(350, 500) self.attr_name_listbox.setFixedSize(350, 500) self.doc_str_textbox.setFixedSize(500, 500) # Create buttons self.favButton = QPushButton('Favorite') self.popButton = QPushButton('POP!') self.editButton = QPushButton('Save Edit') self.exitButton = QPushButton('Exit') # Create Search Bar self.search_line = QLineEdit('Search') self.tabs = QTabBar() self.tabs.addTab('All') self.tabs.addTab('Favorites') self.doc_checkbox = QCheckBox('Include Doc Strings in search')