In my "main" class I have this
tabs = Tabs(self.db)
self.setCentralWidget(tabs)
where I create a tab and show it, with Tabs inheriting QTabWidget. On the Tabs class I have this
self.livros = QWidget()
self.pessoas = QWidget()
self.addTab(self.livros, 'Livros')
self.addTab(self.pessoas, 'Pessoas')
tabela = Tabela(self.db)
where I add two tabs to my tabs. In each of them I'd like to exhibit a table. I created one table class (QTableWidget) called Tabela, where I set rows and columns and stuff, but I have no idea of how to add this table to the tabs. If I instead use it on the setCentralWidget on my main screen it works fine, but again, I'd like to exhibit in the tabs. How could I accomplish this (considering QTabWidget can't have a setCentralWidget)? Thanks very much!
I'm finding out this pattern of solving out my problem minutes after posting a question here. Anyways, the solution was pretty simple: The method setParent. On the class Tabs:
self.livros = QWidget()
self.pessoas = QWidget()
tabela = Tabela(self.db)
tabela.setParent(self.livros)
self.addTab(self.livros, 'Livros')
self.addTab(self.pessoas, 'Pessoas')
Hope this helps someone.
Related
I am trying to add information to my Listbox and keeping it the size I state when I configure it. Here is my code for the Listbox with the scrollbar and an image of what it looks like.
Picture of the listbox.
taskList = Listbox(setBox, bg="#1B2834",fg="white")
taskList.configure(width=183,height=39)
taskList.pack(side=LEFT,fill=BOTH)
taskScroll = Scrollbar(setBox)
taskScroll.configure(bg="#1B2834",width=18)
taskScroll.pack(side = RIGHT, fill = BOTH)
taskList.config(yscrollcommand = taskScroll.set)
taskScroll.config(command = taskList.yview)
Now, when i click a button the command is to execute this following code:
def savetasks():
#make tasks
letters = string.ascii_uppercase
result_str = ''.join(random.choice(letters) for i in range(4))
num = str(random.randrange(0,9))
taskIDnum = num+result_str
taskIDLBL = Label(taskList, text=taskIDnum,bg="#1B2834", fg="White")
taskIDLBL.configure(padx=20,pady=10)
taskIDLBL.pack()
This code works fine as well, creating new labels with a random ID but it resizes the listbox to look like this...
Picture of the list box after clicking the button to execute the command.
Lastly, the scroll bar is not scrollable and when I create a lot of id's that end up going off my screen I cannot use the scroll bar to scroll down to see them, is there a way to not let the Listbox be resized and is it possible to set the Listbox with max and min-height?
If there is an easier way to do this without using a Listbox please let know, I just need to able to scroll down to see all the other id's and I didn't see any other way to use a scroll bar, that I NEEDED to use a Listbox
All,
I am trying to build a small UI as a wrapper for a tool I have. I am trying to use ipywidgets in Jupyter notebooks to do this and I am running into a small issue. It is not sufficiently clear by looking at the Read The Docs page as to how it can be addressed, so any guidance would be greatly appreciated.
Here is what I am looking at, this is straight from the documentation:
```
import ipywidgets as widgets
tab_contents = ['P0', 'P1', 'P2', 'P3', 'P4']
children = [widgets.Text(description=name) for name in tab_contents]
tab = widgets.Tab()
tab.children = children
tab.titles = [str(i) for i in range(len(children))]
tab
```
This looks great, except that the tabs do not have a title. The documentation basically says, titles can be set the same way as Accordion container, but even that container doesn't show how to set a title. Would appreciate any help in this matter.
Best
Uday
Yep it's not the most obvious way to do it. Here is an alternative that avoids a list comprehension.
for title, (index, _) in zip(tab_contents, enumerate(tab.children)):
tab.set_title(index, title)
I found an answer here:
from ipywidgets import *
names = ['General', 'Representation', 'Preference', 'Theme', 'Extra', 'Help']
tab = Tab([IntSlider(description='hi') for _ in names])
[tab.set_title(i, title) for i, title in enumerate(names)]
tab
I am making a battleships program, and after i created a list of identical buttons for a grid and inserting them all into one list, i want to be able to choose the button just clicked and delete it. How can i achieve this?
l = []
for i in range (100):
b = Button(battleship.frame, height = 1, width = 3, command = )
l.append(b)
#this is a snippet of what i have now but i am not sure what to do.
I have tried using lambda to give each button something unique to make them all different but i don't think this helps me in selecting the specific button that was just clicked.
Any suggestions?
WinComboBox comboxBox = new WinComboBox();
comboxBox.SearchProperties[WinComboBox.PropertyNames.Name] = "Server:";
comboxBox.WindowTitles.Add("Server Settings");
comboxBox.SearchProperties[WinComboBox.PropertyNames.TechnologyName] = "Server";
comboxBox.SearchProperties[WinComboBox.PropertyNames.ControlName] = "comboBoxPlatforms";
comboxBox.SelectedItem = "Value3";
I used above code for selecting a value in a combo box using Coded UI test.
But I am getting the error
System.NotSupportedException: GetProperty of "SelectedItem" is not supported on control type: Window
Can anyone tell me what I am doing wrong or show me an alternative solution?
Sometimes i add this : comboxBox.TechnologyName = “MSAA”;
I think WindowTitles is not needed.
Try also
Mouse.click (comboBox) and playback.wait(1000); above comboxBox.SelectedItem = "Value3"; To exclude some common problems. If that solves your issue then you can start refactoring.
Ik hope it helps.
As the exception points out, the UITestControl object you have is of ControlType WINDOW, which is why you are not able to do SetProperty on it.
I will specify parent control also while searching.
WinComboBox comboxBox = new WinComboBox(WinWIndow Parent);
If your control is WinCombobox try:
combobox.SetProperty("SelectedItem", "Value3");
Also If you know the index of the item try:
combobox.SetProperty("SelectedIndex", 3);
Let me know if it resolves your issue
With this code:
QtCore.QObject.connect(self.tabWidget, QtCore.SIGNAL("tabCloseRequested(int)"),
self.tabWidget.removeTab)
I can close any tab QTabWidget, and the names of these tabs are:
work_1
work_2
work_3
But I want the tab work_1 never closes.
Use Index did not work for two reasons:
The tabs can be dynamically moved by this code:
self.tabWidget.setMovable (True)
That makes the Index are constantly changing.
The user has the ability to add new tabs.
Tabs can be identified by their widgets, and the widgets can be identified by their objectName (or some other unique attribute):
self.tabWidget.tabCloseRequested.connect(sef.removeTab)
...
def removeTab(self, index):
widget = self.tabWidget.widget(index)
if widget is not None and widget.objectName() != 'work_1':
self.tabWidget.removeTab(index)
or perhaps more simply:
if widget is not None and widget is not self.work_1:
self.tabWidget.removeTab(index)