#user-interfaces
1 messages Β· Page 78 of 1
just need to wait two seconds for it to update
Looks fine to me, though it would be better if doesnt have that empty space
Yeah
Title of the app, more data on when the reminder expires, bla bla
I worked on a to do list app, not same, but same idea I guess https://github.com/nihaalnz/ToDoApp
yeah, the functionality is being done by him
im just doing the UI
LOLLL
I delete line time.sleep(2)
I wish I had someone to design UI for me π
and it work!
:(
nice
Where was time.sleep().
in first code version
Always wanted to ask someone, what is the character after your name, after the ' | ': α‘αα’
it is quite large it is problematic to rake it out the main thing is that everything works
Ok ok
Happy/Confused to know it helped π
Hm
Well its part of the Cat Cult
A lot of people over here have it, thats why I asked
Those who do joined the Cat Cult
What is that though
to be honest, ProgramWindow. update () apparently this line helped
A community which is revolved around helping and getting help
When you add the Cats symbol in your name, you are acknowledging yourself as part of the Cult
Your job is to help and ask help frequently
And as a member of the Cat Cult it is your job, to never remove the symbol
Basically
Its just a cat symbol lol
πoh okay
it is clear that this did not block the editing of the size but the very fact of clicking on the button(expand window)
ππ
Name easiest library for ui
Hey I didn't know how to google this. (Tkinter)
How do I change to a different "window" as in like a settings menu. I don't want to have 2 windows open.
So in a menu I click on Settings for example then I see all my settings and when I click back I'm back to my main menu.
I want to stay in the same window not have settings as a popup extra window. But Menu and Settings have 2 completly differnt sets of buttons/backgrounds ....
Idk if this is understandable π
tkinter
Use frames, like said in here: https://stackoverflow.com/a/68124161/13382000
Thanks π
is there any way to change the colours of the buttons? (using tkinter)
and like, the style too
it just looks so boring
and doesnt fit the windows 11 style lmfao, probably hard to do with it but its all i know π€·
Styles and Themes: Part of a Modern Tk Tutorial for Python, Tcl, Ruby, and Perl
thanks!
How do i center the +
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(60, 60, 151, 141))
font = QtGui.QFont()
font.setPointSize(110)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Create New Project"))
self.pushButton.setText(_translate("Dialog", "+"))
apollo/plugins/app_theme/mainwindow_apollo.css line 1154
/* footer_PSB_prev */```
any one tkinter expert here?
Widgets Change position on enable other frame..
When I want to make a graph by enter submit button.. It shows me graph but my entry labels make spaces in y-axis... Changes it own postion
NOtebook, 4 frames columns wise.. Grid layout system.. Can share my code on demand.. very much lines of code I cannot take screenshot..
Code is here.. https://paste.pythondiscord.com/hahulafajo.coffeescript
can you do me a help?
Can you try ttk widgets with W11 and tell me if it gives the W11 style or if it is still W10 type. Not much of hope because W11 uses the same kernel as W10
I am not much of help here as I cannot understand the code or run it, or even used matplotlib plots before, but anyway, I am 99% confident that it can be fixed by adding rowspan to whatever the frame/canvas that has the plot in
If you still cannot figure it out, give me a zip file with all the files that are needed to run your code exactly like you are able to run. I'll take a look
I have a problem with Pyside6
ModuleNotFoundError: No module named 'PySide6'``` I've had this error for days.
Can someone explain it to me?
I have it installed already.
Sure?
Yes
Requirement already satisfied: PySide6 in c:\users\raxos zero\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (6.1.2)
Requirement already satisfied: shiboken6==6.1.2 in c:\users\raxos zero\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from PySide6) (6.1.2)```
Do you use any kind of IDE?
Hmm. Just VS Code.
3.9
Make sure to inherit the global package from Python root directory
Which python does VSC run
How do I do that?
I'm guessing you're using venv?
What does it say on the bottom corner of VSC
Send a screenshot of your Visual studio code window
I dunno...
Python 3.9.5
Hey @plush stream I used one your repo for an answer here: https://stackoverflow.com/a/68272760/13382000 π
Okay where do you do pip install stuff
I dunno.
I just typed pip install on my cmd.
Okay cool, type in python in the cmd and tell me what version you see there
That's awesome
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.```
Pretty sure it will also work on tkinter if there's a way to make the window translucent/transparent and get the winId inside tkinter
See there are two version of python and pip install .... uses 3.9.6 while your visual studio uses 3.6.5
Oh ummmm I think winfo_id might get the win id? Do you want to test it out?
Well there is no real way to make window transparent but, you can make certain colors of it transparent, also the entire window can be made invisible, but idt thats what you mean
My VS is using 3.9.6 on the bottom bar, tho.
but you said.
Transparent color? Like RGBA?
No i mean it can make a certain region of the window, like any part that has green will be transparent. Like green screen effect π
Anyway to confirm, try saying pip freeze in the terminal of VSC, then you will see the list of modules installed in your python version
Sorry, I meant 3.9.5. You typed 3.6.5. I was trying to correct. My bad.
Alright
aiohttp==3.7.4.post0
appdirs==1.4.4
async-timeout==3.0.1
attrs==21.2.0
certifi==2021.5.30
chardet==4.0.0
discord.py==1.7.3
distlib==0.3.2
filelock==3.0.12
idna==2.10
Jinja2==3.0.1
MarkupSafe==2.0.1
multidict==5.1.0
PyQt5==5.15.4
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.0
PyQt6==6.1.1
PyQt6-Qt6==6.1.2
PyQt6-sip==13.1.0
PySide6==6.1.2
qt-material==2.8.8
requests==2.25.1
shiboken6==6.1.2
six==1.16.0
typing-extensions==3.10.0.0
urllib3==1.26.6
virtualenv==20.4.7```
Hmmmm it shows that it is installed
Okay do one thing, click on that python version thingy and change your version to what was shown in the cmd
then try the code again
Yeah, that's what I went to do...
But
File "c:\Users\Raxos Zero\Documents\GitHub\VeryHarassiveAndKinkyStalkApp\src\main.py", line 35, in <module>
window = MainWindow()
File "c:\Users\Raxos Zero\Documents\GitHub\VeryHarassiveAndKinkyStalkApp\src\main.py", line 11, in __init__
self.init_config()
File "c:\Users\Raxos Zero\Documents\GitHub\VeryHarassiveAndKinkyStalkApp\src\main.py", line 21, in init_config
self.settings = self.init_settings()
File "c:\Users\Raxos Zero\Documents\GitHub\VeryHarassiveAndKinkyStalkApp\src\main.py", line 17, in init_settings
with open("config.json", "r", encoding="utf-8") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'config.json'```
Is there a file called config.json at the path C:/Users/Raxos Zero/config.json?
You dont have to check, there isnt, thats why the error appears
There is, apparently
Then the code should work tbh
I can see that the py file is inside a folder called src, why dont you move the terminal to that location and also copy the config to that location
Anyway you got rid of the error about PySide6
Yes, we did. Thanks, man.
Let me try that
Here is a tip on how I use VSC, because file path and locations are VERY IMPORTANT or they will raise such errors. I create a project folder, then I put all the required files inside that, and I open cmd IN THAT LOCATION, then I type code ., this will open VSC in that folder. So now the terminal will also belong to that folder
How to open VSC in that folder easily? Go to the folder and Shift + Right click, open powershell, then type code .. But if you have an option called 'open with code' then just click on it, this option has to be enabled during VSC installation
I got it.
Great
Yea there are two types of paths, absolute and relative, absolute is actually easy to use but can be LONG, relative can be short but not relatively easy to configure/find.
If you don't mind, can you explain that more in my DM?
Done
How would i go about making it such that
When a user re sizes window
the widgets also change position
pyQt
would i have to implement this in the styleSheet(css)?
Joe Mama
:/
No, I believe it is done with layouts
Not very helpful
Oh i see
thats how it was with kivy but
it was sorta weird with gridLayout
i am learning python man i dont know what i that
HBox, VBox, Form, Grid, these are all there is with PyQt
im doing it in pyQt now hoping it will be easier
Which one would you recommend for something like this?
it looks perfect ey?
Not but i wasnt resizing
:(
If i resized the widget positions remain the same
i want them to either contrast the padding, or sorta fit into the number of rows present
i tried with kivy, but orientation(left-right, top-bottom) was ruining everything
So i decided to use pyQt
Hmmmm, I am not sure, I dont use these because I dont like it, too hard for me :P. I always disable resizing of my app
:0
Modern solution π
modern problems require modern solutions
modern problems require modern solutions
Hello, so I am creating an application where you can create photo albums and put pictures in them
but there is a problem, to locate all the albums created I list all the subfolders in the "gallery" folder and create a group of widgets with a button above and the name of the album below; for each sub-folder containing a "properties.json" file, I therefore add a new group of widgets. The command executed when clicking on a button calls the "openGallery" function and gives as parameter the name of the gallery to open. except that no matter which gallery you click, it will always open the same one and I think this problem is due to the fact that the widgets created have the same name. So there would be a way to create same widgets with differents name in a loop ?
command=lambda i=i: self.openGallery(i)
wow this work.. thanks
but what do the i=i do ?
Basically speaking, you are storing i, which is looping, into a function(lambda) that calls self.openGallery. Without that, each i is being overwritten by the old i and at the end, the last item will be the value of i.
Beginner mistakes, nothing serious π
Ohhhh, thanks you ! :D
Hello - I am working with pyqt6 (using pyside6 module). It looks like we can add widgets to a UI using the QBoxLayout class or by creating the widget with the parent UI as an arg. Wondering which is better, if there might be pitfalls? I've been using the QBoxLayout class and using setLayout() so far
could anyone offer some ideas in #help-pineapple ?
ModuleNotFoundError: No module named 'kivy.speedmeter'
how can i fix this error??
from kivy_garden.speedmeter import SpeedMeter
have a look at the examples: https://github.com/kivy-garden/speedmeter/tree/master/demos
Python does have some good GUI libraries, what are you looking to make
If your looking for something simple, tkinter can do it
If your looking for something complex and modern, PyQt can do it
Well, I don't know what you mean by cross language, but Qt is originally from C++, PyQt is the python version of the C++ Qt
Help me please, window.mainloop() is constantly getting in the way by conflicting with other lines of code how to separate it?
example?
it's just that the code is not executed without errors even
I an example I can't provide everything is confused there
I dont understand what you mean, then how can I help
need some condition or something that could separate the mainloop from the main code
How many mainloops do you have, normally only one is required, all you code runs from the one mainloop so it should not conflict with other code, when the mainloop ends the program is finished.
The code will be called by events from the GUI for example a click of a button.
As @tawdry mulch stated, without showing an example of your code, it is difficult to known how to help.
this will never get old
can someone help?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
I will create a page in pyqt5. The page will be constantly updated. that is, the data displayed on the screen will be constantly updated. how can I do that???
Many ways to do this, what do you mean by page
an interface for the vehicle
Thats qml
pages? which widget? QStackedWidget?
what? i dont umderstand?
Which widget do you use for your pages, what is the code.
Is Pyqt and qtdesigner better than tkinter?
yes imo
obv
Hello there. I am making a project with pyqt5. but i have a problem. The data on the screen needs to be constantly updated. How do I do this?
I am writing two functions in klass but the other one is not working?
hmmm the error is in line 54...:P
AttributeError: type object 'Ui_Form' has no attribute 'setObjectName'
Getting this error in PyQt5
Trying to change from Main window screen to a form
can provide code
Provide pls
Index:
https://hastebin.com/icedanirel.rb
Main (GUI:
https://hastebin.com/bomipuveru.rb
Form (GUI):
https://hastebin.com/emimorekip.rb
Where is the error, also inclde entire error code
Traceback (most recent call last):
File "d:\stuff\Work\Python\Applications\App\index.py", line 25, in loginpage
self.login = Login()
File "d:\stuff\Work\Python\Applications\App\index.py", line 14, in init
self.ui.setupUi(Ui_Form)
File "d:\stuff\Work\Python\Applications\App\login.py", line 6, in setupUi
Form.setObjectName("Form")
AttributeError: type object 'Ui_Form' has no attribute 'setObjectName'
!code
File "d:\stuff\Work\Python\Applications\App\index.py", line 25, in loginpage
self.login = Login()
File "d:\stuff\Work\Python\Applications\App\index.py", line 14, in __init__
self.ui.setupUi(Ui_Form)
File "d:\stuff\Work\Python\Applications\App\login.py", line 6, in setupUi
Form.setObjectName("Form")
AttributeError: type object 'Ui_Form' has no attribute 'setObjectName'
Shouldnt it be self.setObjectName("Form") ?
nope
I don't understand why are you passing in the same object to something that is being called from the same object?
Wdym
Which widget are you trying to name. What are you trying to do
Im trying to make it so when u press a button on main it opens up the login page
@tawdry mulch
Yea understood, what are you trying to do with Form.setObjectName(..)..
Nothing but if i remove it the error goes down to the resize line
and says that has no attribute
Hmmm I am not sure, i'll let someone else here help
@ivory ember Please take a look the above issue please
Using PySide6, how would I be able to remove the stuff behind the QTableWidget scrollbars? the light grey background and what looks like a border
import sys
from PyQt5.QtWidgets import *
class App(QWidget):
def __init__(self):
super().__init__()
self.title = 'AI'
self.left = 100
self.top = 100
self.width = 640
self.height = 480
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.openFileNameDialog()
self.result()
def openFileNameDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
sound, _ = QFileDialog.getOpenFileName(self,
"QFileDialog.getOpenFileName()", "","Files(*.mp3)", options=options)
if sound == "":
cancel = QMessageBox()
cancel.setText("\nCancel selection")
return_value = cancel.exec()
return
name = QMessageBox()
name.setText(sound)
return_value = name.exec()
def result(self):
resultbox = QMessageBox()
resultbox.setText('''this is the pump sound. ''')
return_value = resultbox.exec()
if __name__ == '__main__':
app = QApplication(sys.argv)
button = QPushButton('Start')
ex = App()
button.clicked.connect(ex.initUI)
button.show()
sys.exit(app.exec_())
here is my code, i am stuck in how to make the sound's QMessageBox do not have the path
@torpid cipherwdum buddy
if i open a mp3 file called "test.mp3", i want to have an output which is
'file : test
this is the pump sound'
like this
You would use some css styling
ok
since when does PySide6 use CSS? could you link to any docs about this?
Hey @digital rose!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Source Code and UI file!
https://github.com/ClarityCoders/PyQt5_examples
Today we are going to style your PyQt5 APP using CSS. We will walk you through everything you need to style a PyQt5 application. We do this using PyQt5 set style and a variable with CSS code.
See our first video in this playlist if you need to install any of the tools! ...
that is in fact not CSS, its css-like but decidedly not actually CSS
Im pretty sure its CSS mate
Isnt this called QSS?
This is valid CSS
Well its just CSS for Qt
QWidget{
background: #000000;
}
QLabel{
color: #fff;
}
QLabel#round_count_label, QLabel#highscore_count_label{
border: 1px solid #fff;
border-radius: 8px;
padding: 2px;
}
QPushButton
{
color : rgba(0, 0, 0, 100);
background: rgba(100, 100, 100, 50);
border: 1px #DADADA solid;
padding: 5px 10px;
border-radius: 15px;
font-size: 110pt;
outline: none;
}
QPushButton#pushButton_2
{
color : rgba(255, 255 255, 100);
background: rgba(200, 200, 200, 100);
border: 1px #DADADA solid;
padding: 5px 10px;
border-radius: 1px;
font-size: 15pt;
outline: none;
}
QPushButton#pushButton_3
{
color : rgba(255, 255 255, 100);
background: rgba(200, 200, 200, 100);
border: 1px #DADADA solid;
padding: 5px 10px;
border-radius: 1px;
font-size: 15pt;
outline: none;
}
QPushButton#pushButton_4
{
color : rgba(255, 255 255, 100);
background: rgba(200, 200, 200, 100);
border: 1px #DADADA solid;
padding: 5px 10px;
border-radius: 1px;
font-size: 15pt;
outline: none;
}
QPushButton:hover{
color : rgba(0, 0, 0, 100);
background: rgba(200, 200,200, 50);
border: 1px #DADADA solid;
padding: 5px 10px;
border-radius: 15px;
outline: none;
}
QPushButton#pushButton_2:hover{
color : rgba(0, 0, 0, 100);
background: rgba(255, 255, 255, 50);
border: 1px #DADADA solid;
padding: 5px 10px;
}
QPushButton#pushButton_3:hover{
color : rgba(0, 0, 0, 100);
background: rgba(255, 255, 255, 50);
border: 1px #DADADA solid;
padding: 5px 10px;
}
QPushButton#pushButton_4:hover{
color : rgba(0, 0, 0, 100);
background: rgba(255, 255, 255, 50);
border: 1px #DADADA solid;
padding: 5px 10px;
}
QLineEdit {
padding: 1px;
color: #fff;
border-style: solid;
border: 2px solid #fff;
border-radius: 8px;
}
its
CSS
:)
yep, its Qt Style Sheets
which are not Cascading Style Sheets
"Qt Style Sheet terminology and syntactic rules are almost identical to those of HTML CSS. If you already know CSS, you can probably skim quickly through this section." so It is not clearly CSS but almost like CSS
yep
its css-like but not really css. more complex css things like animations wont work.
Yea like CSS animations, etc wont work
I get you π
Sorry if this is not the place to ask but i'm learning kivy and for some reason when i right click in an empty app a red dot appears. Why does it do that? Can i change it?
anyone likes simple "terminal" user interface ?
For programmers, I think CLI are the most efficient to use. But when you want to have a simple buffer for your eyes or when making apps for the public, UI is the way to go.
someone know how to export images (tkinter background) with pyinstaller to my exe? The users obviously dont have the images in the directory so yea how can i share a exe with images?
only works on my device (the pictures on my window)
I will link you to one of my top answers https://stackoverflow.com/a/63371506/13382000
yeah thats true
Did you even open the link I gave?
but being a linux user i usually prefer terminal CLIs
yes what has it to do with background image and logo?
Makes sense as linux is more customizable. They do not have time to code a UI for each feature the user can tweak.
Put the image on the same folder as the exe(or wherever the path is valid) and then follow the answer to make setup wizard
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
Could not create pixmap from :/newPrefix/test.jpg
"QFormBuilder was unable to create a custom widget of the class 'QwtCompass'; defaulting to base class 'QwtDial'."
"QFormBuilder was unable to create a custom widget of the class 'QwtDial'; defaulting to base class 'QWidget'."
Could not create pixmap from :/newPrefix/test.jpg
Could not create pixmap from :/newPrefix/test.jpg
so the setup creates a folder with the images inside?
hello, what is the reason for this error?
Yes, just like installing an application
but i would need to change the path right for the 2 images in my script right?
which method
i would need to change that to the installation path where he puts the images then right?
Yea, put it where your script is @digital rose and change the path accordingly
ok
Hey, I need some help!
I am build a UI program! I want that when the button gets clicked it browses a folder and its address gets inserted in the entry field! And that same address should be temporarily save in the json file too! Once the program is closed the json entry will also be deleted!! How do I do that?
hm i never did that, what are the first steps? It "just" needs to create a folder with 2 images inside when you run the exe
so i need these 2 files and add them to the NSIS?
alright works
the setup creates now a folder now how can i make the images work again because they have no path?
i would like to have the EXE installed on the desktop and the image folder placed in the dokuments folder or something like that
The thing is you have 2 opt, 1 is to use pyinstaller and bundle it 2nd is to make an installer
yea i'd like to have an installer
What is your pyinstaller code
the one i used for my exe?
pyinstaller.exe --onefile --icon=C:/Users/Philipp/Pictures/anno.ico --windowed plop.py
i need to change the ico path too then
Use pyinstaller.exe --onedir --icon=C:/Users/Philipp/Pictures/anno.ico --windowed plop.py
do my images work then?
Wait, make a folder and COPY ALL THE FILES YOU NEED INSIDE IT
Could not create pixmap from :/newPrefix/test.jpg
Could not create pixmap from :/newPrefix/test.jpg
??
i need the exe and the images
First do this, put your python script and then the images inside a folder
okay
Then now change path
file='slap.png' and file=logo.jpg'
Forget the exe for now
Now check if script works, try running the app
Follow this
ah kk sry
works
pyinstaller.exe --onedir --icon=C:/Users/Philipp/Pictures/anno.ico --windowed plop.py
so now this?
i need to tell pyinstaller the path of .plop
pyinstaller.exe --onedir --icon=C:/Users/Philipp/Pictures/anno.ico --windowed C:\Users\Philipp\PycharmProjects\TestProject\AnnoChain\plop.py
like this?
You know the addressbar on top of windows explorer?
so it created a exe now but i cant run it
Why
Copy the images onto this folder
then it works
but its not userfriendly if they have to put the exe to the images π
No, you will use Inno Setup now and make an setup file
or Inno setup
Choose 'Create a new script file using script wizard...'
Now just fill in the information
'Add folder...' and then choose your entire folder with the exe
Yes proceed
Do as you wish
so the installer places the folder somewhere and automaticly adds a shortcut to the desktop?
yes
No this is where the installer will be saved, not where the installation will be saved
can i leave this empty?
You cannot control that because in the users PC there will be folders that You dont know about
No just choose some location, that is where the installer will b save
yes
Okay? does it work?
See these options show the installer logo
then
its somehow not adding my exe
i always get this fail
but i want a shortcut of my exe
when i run the weird Anno Chain with the fire it just opens a hello message
what am i doing wrong
@tawdry mulch
Bro here you did not choose the correct exe
Yes now it should be ok
is this the exe that comes from installer?
no
why on desktop it worked
now i cant even run it anymore on desktop
that makes no sense
You are doing something wrong
when i run it on my script it works
wtf
why is the exe now broken
i even created a new one, same error
can you try to do this for me.. i sent you the source code in pm :
π¦
Fine, make a zip file with all the script's and send me
thank you π
Error in input file: not well-formed (invalid token): line 1, column 0
What
Can anyone explain tkinter styling to me?
I really don't get it, are the names set?
Like I do:
style = ttk.Style()
style.configure("BW.TLabel", foreground="black", background="white")
self.root = root
ttk.Label(self.root, text=bot.tool).grid()
ttk.Button(
self.root,
text="CALL",
padding=3,
command=partial(bot.createOrder, 12, "call"),
style="BW.TLabel",
).grid()
And it works but switch BW.TLabel to BW.Call and it doesn't
Yes it should be TLabel or if it was a button, then TButton.
And what if I need to style more than 1 button?
You mean different style?
Like, I need a button to be Green and the other one red
I don't know, you could do First.TButton and then Second.TButton and then apply those individually to the buttons
My html/css brain doesn't like set names like this lol
But thanks
I'll give it a try
Yea well this isnt HTML/CSS, so....π€·ββοΈπ
I know, but having set names like that seems a bit odd
Might be because I'm used to the "class" flexibility in that regard
It's just ways so that tkinter can identify these styles, also like group them up(I guess). To understand more about this, you have to look into TCL
Will do, thanks
Style Names
Every style has a name. If you're going to modify a style, create a new one, or use a style for a widget, you need to know its name.How do you know what the names of the styles are? If you have a particular widget, and you want to know what style it is currently using, you can first check the value of its style configuration option. If that is empty, it means the widget is using the default style for the widget. You can retrieve that via the widget's class. For example:
>>> b = ttk.Button()
>>> b['style']
''
>>> b.winfo_class()
'TButton'```
> In this case, the style that is being used is TButton. The default styles for other themed widgets are named similarly, e.g., TEntry, TLabel, etc.
> Beyond the default styles, though, styles can be named pretty much anything. You might create your own style (or use a theme that has a style) named FunButton, NuclearReactorButton, or even GuessWhatIAm (not a smart choice).
>
> More often, you'll find names like Fun.TButton or NuclearReactor.TButton, which suggest variations of a base style; as you'll see, this is something Tk supports for creating and modifying styles.
Above taken from https://tkdocs.com/tutorial/styles.html
Styles and Themes: Part of a Modern Tk Tutorial for Python, Tcl, Ruby, and Perl
Hi, Could I get some quick assistance without making a ticket?
I am using tkinter and have made a tk.toplevel. But at the moment I can spam the button and make endless windows... how do I make it check first to see if one is already open?
The stuff I have tried has not worked
def softwareversion():
def close():
root.destroy()
root = tk.Toplevel(self)
root.title("Software Version")
label2 = ttk.Label(root, text="You are running xyz version 1.8.9 BETA", font=Information_Font,) #background="red")
label2.pack(pady=0,padx=50)
no = tk.Button(root, text = "Close", width = "8", command = close)
no.pack(pady=4,padx=50)
You will have to use some flag
Kay, no issue https://stackoverflow.com/q/29233029/13382000
Okay, I think that answer is terrible, perhaps you need to use flags. I do not have python now, but let me see if I can build up an example
I got that answer to work, but it just stops everything else :/
I'll google flags
Ty for helping me
from tkinter import *
root = Tk()
new = None # Pre define the variable first
def opener():
global new
if new is None: # Check if the window is None like said before
new = Toplevel() # Then make a window
# All your other code related to the window below.....
else:
new.protocol('WM_DELETE_WINDOW',close) # What should be done if window is closed
def close():
global new
new.destroy() # Close the window
new = None # Make it back to None so the if statement can be triggered again
Button(root,text='Open new',command=opener).pack()
root.mainloop()
This cannot be exactly called as flag, but this is one way of doing things
hmn ok
Okay this is using flags:
from tkinter import *
root = Tk()
opened = False # Define a flag to check if the window is opened
def opener():
global new, opened
if not opened: # If window is not opened
new = Toplevel() # Open
new.protocol('WM_DELETE_WINDOW',close) # Call close() if window is closed
opened = True # Now since it is opened, make it True
# All your other code below...
def close():
global new, opened
new.destroy() # Close the window
opened = False # Since the window is now closed, make it back to True
Button(root,text='Open new',command=opener).pack()
root.mainloop()
Maybe something like this
import tkinter as tk
from tkinter import ttk
class TkApp(tk.Tk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.entry = tk.Entry(self)
self.entry.pack(padx=5, pady=5)
self.button = tk.Button(self, text='Print', command=self.on_button)
self.button.pack(pady=5)
self.software_version_frame = None
def on_button(self):
try:
self.software_version_frame.tkraise()
except (AttributeError, tk.TclError):
self.software_version_frame = SoftwareVersionFrame(self)
class SoftwareVersionFrame(tk.Toplevel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Software Version")
label2 = ttk.Label(
self, text="You are running xyz version 1.8.9 BETA", )
label2.pack(pady=0, padx=50)
btn = tk.Button(self, text="Close", width="8", command=self.destroy)
btn.pack(pady=4, padx=50)
if __name__ == '__main__':
app = TkApp()
app.mainloop()```
Is it the classes which makes it work?
I have already used self and classes for the different frames in my program π¦
Classes organise the code together.
its this part that is only creating a new frame if one does not exist
self.software_version_frame = None
def on_button(self):
try:
self.software_version_frame.tkraise()
except (AttributeError, tk.TclError):
self.software_version_frame = SoftwareVersionFrame(self)```
it is a separate window is a tk.Toplevel
class SoftwareVersionFrame(tk.Toplevel):```
Which class
Guys
guys
import tkinter as tk
win = tk.Tk()
button1 = tk.Button(win, text = "Hi")
button1.pack()
if win.winfo_exists() !=None:
print("the window is open")
else:
print("The window does not exist")
tk.mainloop()
rip that doesn't work either π¦
There is no default way to do it
What was wrong with the code we gave?
CoolClouds version and my version both work
Did you know root is also a global variable... If you want to avoid them, use class
I'm using Self in mine
we're not suppose to do your homework
Okay implement the example given into a class. Yoriz already gave an example in OOP
I'm unable to create a button using the tkinter module, can somebody send me an example of the code
i've seen many, but they aren't working
i've also imported the correct modules
im new btw
pls help
im new
I've been wondering for ages
Also if you know a better module than tkinter please tell me
thx
I also installed another module, it keeps on telling me there is no such module when i import it. The module is in the correct folder though
what could be the issue
?
please send the error log
and use Pyside6 as it is a new release and also backward compatable
@split coyote
Traceback (most recent call last):
File "C:\Users\rorop\Desktop\haha\main.py", line 3, in <module>
import vlc
ModuleNotFoundError: No module named 'vlc'
then u shoul check ur interpreter that u use to run code
im new and don't know what that is
what IDE ur using
i think it's IDLE Shell
ohh u need to run it using the interpreter that has vlc
ok
thank you
sorry im asking too much but do you know any interpreters that have vlc?
its a module lol u install it
im so confused rn lmao I installed vlc is that what u mean?
no look up on google python package installuing
ok
u will understand whats the difference
ok thx
ok so basically u install packages with pip in cmd right?
actually nvm thx for the help
i think i know what to do
whenever i finish with an error another appears lol
It highlights the bracket after the appostrophe following the path of a file, what should i do?
im sorry im asking too much but pls help
nevermind got it all fixed!
Code please
If you are a beginner, PyQt wont be easy yo follow, start with tkinter.
Yea it is usually when you copy the code from a code editor that uses shit method to paste their code.
Hey
QWidget{
background: rgb(2,0,36);
background: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(110,5,139,1) 76%, rgba(0,212,255,1) 100%);
}
QPushButton{
background: rgba(100, 100, 100, 0);
}
Why wont this work, pyQt: QSS

im tryna make a gradient background
:(
What u trynna do
Is there anyway to make tabs in Qt without layouts?
hi
Could not create pixmap from :/newPrefix/background.jpg
what is the reason for this error
is it possible to make 2 things happen at once? For example, a stream of numbers is running, increasing by one each time and you click a button which makes a noise. This would cause the numbers to stop increasing by 1 until the noise ends. Is there a way to keep the stream running while the sound is being played?
I'm using ursina module, i want a sound to play when a box is destroyed, but the entire thing freezes in order to play that noise
pls answer when you see this message
this would be a better question to ask in #game-development
You can run code in a separate thread to not block the gui event loop
hello, everyone. I want to know that if i want to make a good layout like "photo , button, version"
is it possible?
def initUI(self):
layout = QVBoxLayout()
self.setWindowTitle('Title')
self.logo=QLabel('logo')
pname = QPixmap('icon.png')
self.logo.setPixmap(pname)
layout.addWidget(self.logo)
self.startbutton = QPushButton('Start')
self.startbutton.clicked.connect(self.openFileNameDialog)
layout.addWidget(self.startbutton)
I cannot show anything in this page
btw, i am using pyqt5
Please help. TT
I think you have to set parent to those widgets first to show them.
def initUI(self):
layout = QVBoxLayout(self)
self.setWindowTitle('Title')
self.logo=QLabel('logo', self)
pname = QPixmap('icon.png', self)
self.logo.setPixmap(pname)
layout.addWidget(self.logo)
self.startbutton = QPushButton('Start', self)
self.startbutton.clicked.connect(self.openFileNameDialog)
layout.addWidget(self.startbutton)β```
does anyone know how to make the title bar background transparent? pyQT
I want that whitish part at the top to be transparent
Ummm are you looking for this? https://github.com/nihaalnz/PassLost/blob/694a17b6e5c2e5e983398ff5733c192032504d0c/main/main.py#L15
main/main.py line 15
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)```
well that removes resizing and full/min/max screen options
Isnt that the title bar?
i dont want that greyish background of the title bar to be shown
I still cannot understand, can you highlight for me?
Okay one second
@tawdry mulch the red part is what i dont want, the green part is what i want
You want to change the color of it?
Doesnt this code remove it
what happens when you run that is, it completely removes the title bar
which means you cant resize
use min/max/full buttons
or change the position of the window
which is pointless
it just becomes a picture stuck to your screen then
anyways i tried that method
and came up with this
the ones at the right corner are the min max and full buttons
you can change the position of the window as well
but
it took a LOT of implementation
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowMinimizeButtonHint)
self.resize(800, 600)
AllWidget = QWidget()
# AllWidget.setStyleSheet("background-color:red")
Alllayout = QVBoxLayout()
Alllayout.setSpacing(0)
Alllayout.setContentsMargins(0, 0, 0, 0)
AllWidget.setLayout(Alllayout)
self.title = TitleWidget()
self.title.setFixedWidth(self.width())
self.title.setFixedHeight(TITLE_HEIGHT)
self.title.ButtonMin.clicked.connect(self.ButtonMinSlot)
self.title.ButtonMax.clicked.connect(self.ButtonMaxSlot)
self.title.ButtonRestore.clicked.connect(self.ButtonRestoreSlot)
self.title.ButtonClose.clicked.connect(self.ButtonCloseSlot)
centerWidget = QWidget()
# centerWidget can add any control you want to use
# centerWidget.setStyleSheet("background-color:red")
Qss = '''
QMainWindow{
background:qlineargradient(spread:pad,x1:1,y1:0,x2:0,y2:1,stop:0 rgba(51,146,255,255),stop:1 rgba(255,255,255,255));
}
'''
Alllayout.addWidget(self.title)
Alllayout.addWidget(centerWidget)
self.setCentralWidget(AllWidget)
self.setStyleSheet(Qss)
def ButtonMinSlot(self):
self.showMinimized()
def ButtonMaxSlot(self):
self.title.ButtonMax.setVisible(False)
self.title.ButtonRestore.setVisible(True)
self.title.saveRestoreInfo(self.pos(), QSize(self.width(), self.height()))
desktopRect = QApplication.desktop().availableGeometry()
FactRect = QRect(desktopRect.x() - 3, desktopRect.y() - 3, desktopRect.width() + 6, desktopRect.height() + 6)
print(FactRect)
self.setGeometry(FactRect)
self.setFixedSize(desktopRect.width() + 6, desktopRect.height() + 6)
def ButtonRestoreSlot(self):
self.title.ButtonMax.setVisible(True)
self.title.ButtonRestore.setVisible(False)
windowPos, windowSize = self.title.getRestoreInfo()
# print(windowPos,windowSize.width(),windowSize.height())
self.setGeometry(windowPos.x(), windowPos.y(), windowSize.width(), windowSize.height())
self.setFixedSize(windowSize.width(), windowSize.height())
def ButtonCloseSlot(self):
self.close()
def paintEvent(self, event):
self.title.setFixedWidth(self.width())
def mousePressEvent(self, event):
if event.button()==Qt.LeftButton:
self.m_flag=True
self.m_Position=event.globalPos()-self.pos() #Get the position of the mouse relative to the window
event.accept()
self.setCursor(QCursor(Qt.OpenHandCursor)) #Change the mouse icon
def mouseMoveEvent(self, QMouseEvent):
if Qt.LeftButton and self.m_flag:
self.move(QMouseEvent.globalPos()-self.m_Position)#Change window position
QMouseEvent.accept()
def mouseReleaseEvent(self, QMouseEvent):
self.m_flag=False
self.setCursor(QCursor(Qt.ArrowCursor))
this is half of it
and its just not very worth it
so i was thinking of a way to just make the title bar background transparent
Yea that is how you do it
It is how people do it, you remove the title bar and put your own drag, resize bla bla functions
Hey,
I have used tkinter library in python
I want the function associated with each individual checkbox to be executed only when its checked and when i click the start button!! how do i do it? please help
In the event handler of clicking the start button, check the state of each checkbox and react accordingly.
How do I do that??
Thanks Alot brother!!! It's done! ππ
I'm writing a gui which has a plot which should refresh at 30fps. The way I'm doing it is that a thread emits "refresh" signals at 30fps, which update the gui in the main loop, but this is freezing the gui because the main loop is swamped. Is there a way to fix this?
Ok, I think I've found a solution to the issue: Instead of using a thread, I'll use a timer which calls the refresh method at 30fps... seems to work
Can anyone explain why these two threads are not working at the same time?
import sys
import time
from PyQt5 import QtWidgets
from PyQt5.QtCore import QObject, QThread, pyqtSignal
class Worker(QObject):
def run(self, str):
while True:
print(str)
class ThreadController():
def __init__(self):
# Thread 1
self.thread = QThread()
self.worker = Worker()
self.worker.moveToThread(self.thread)
self.thread.started.connect(lambda:self.worker.run('worker1'))
self.thread.start()
# Thread 2
self.thread2 = QThread()
self.worker2 = Worker()
self.worker2.moveToThread(self.thread2)
self.thread2.started.connect(lambda:self.worker2.run('worker2'))
self.thread2.start()
if __name__=='__main__':
app = QtWidgets.QApplication(sys.argv)
thread = ThreadController()
sys.exit(app.exec_())
The output is just "worker1"
Instead of doing that, use QThreadPool and QRunnable
Ok, I could do that. But is there a way to fix the above code using QThread?
Also, I don't understand why the above doesn't work in the first place.
I got a weird question
Has anyone here used the property decorator to tell a class to return pysimplegui controls rather than just the flat value when accessed by a rendered application?
And if so, have you tried to pin down the memory cost of doing such a thing? I did a thing and I dont know if its like, so stupid that people know not to do it or if just everyone doing it is charging for it or what
That sort of thing
Teaching myself databinding in python so confidence is not unshakeabke, but I like how the code looks
The self.render bit is a placeholder for what will be the signature of the container making the request which will give the class its various formatting data, so that things running without a gui dont ideally need to carry the extra baggage and it saves me the time of writing things around the class rather than into
there are obvious datatype concerns since the same property can return various types, but in practice that wasnt too bad and if the signature thing I said earlier works half as good as my imagination I dont see major issues
the example is from an odbc assembler that is the entry to the actual application, so the properties and classes are the simplified version and can share the whole class if needed
I am sorry to reply to you for that long time. But it really solves the 'not popping out anything' problem. Thank you very much.
It doesn't have to be that complicated to move frameless window in qt. All you need is:
def mousePressEvent (self, e):
self.window().windowHandle().startSystemMove()
With the above method, the move event of the window will be handled by the os.
Bro, just tried that out and it surprisingly works. I used another, less accurate and more complicated method for my app. Now it works better and the code is cleaner. If you do not mind my asking, where did you find/learn about that code?
Someone from the qt discord server
there's a server?
shoot, can u dm me an invite
Sure
me too please
Alr

let me try that
yeah so
that works
but
i still cant resize
You could use QSizeGrip
can you show me an example
like how u did for the func
rn i tried this
Alright gimme a sec
def mousePressEvent(self, e):
self.window().windowHandle().startSystemMove()
self.window().windowHandle().startSystemResize(self, Union[Qt.Edges, Qt.Edge])
but Union isnt defined ig
π

class BaseWindow(QtWidgets.QWidget):
def __init__(self):
super(BaseWindow, self).__init__()
self.sizegrip = QtWidgets.QSizeGrip(self)
def resizeEvent(self, event) -> None:
self.sizegrip.move(self.width() - 15, self.height() - 15) # keep the qsizegrip at the bottom right corner when resizing
that's roughly the code. it could still be improved by using layout instead of manually updating the qsizegrip position per resize event.
so
i added it at the end
but
it doesnt work

it doesnt throw any errors
but it doesnt work
bear in mind that you can only resize from one point, which is the bottom right corner
if you want to resize from all direction, then you have to implement qsizegrip for every direction
you put qsizegrip in the class BaseWindow but you initialize the MainWindow class instead
that's why it doesn't work
oh
welp
anyways
ill just work with that border thing
its fine
ill figuere itout
thanks!
hello
Hi
sup
That looks great!
Thanks! I'm trying to copy all uwp design, I've already published the window blur on pypi with the name 'BlurWindow', when I have more widgets I'll publish this one too
BlurWindow works with pyside,pyqt,etc too
Ah, great
Like windows 10
my question actually is, will anyone use? I'll make new widgets too, like a table for displaying sqlite results or a dict
Qt has sqlite table model
Yes, but the project is for tkinter, why not? Lol
tkinter?
How did you manage to blur the bg
I published a package in pypi called BlurWindow
That can be used with tkinter?
Ye
Look
idk i only work withh Qt
Just a min, let me test it out
Warning: Just work in windows
Examples%20MUST%20SEE/tkinter%20BLUR.py line 12
global HWND```
Only in windows and mac it is possible to make a transparent window in tkinter
Ye
Variables defined in the main block are global by default?
Oops, confused it with pyside code, it doesn't even need
Ctrl c ctrl v lol
Lol
Worked? You are the first to test it lol
It does work, but while dragging windows, it lags the drag
on the applyacrylic the lag is just so much, but the other seems to be compensable.
Windows 10 has acrylic blur lag due to mouse polling issue. But it seems to be fixed in Windows 11
But the library is nice, figured you had to mess around with ctypes to get something like this.
Thats dope!
Very similar to mine. But mine only target PySide/PyQt π
I don't even understand what's going on in this library anymore lol
But I want to add Mac support too
Thanks! But there is still a lot to improve
See you could have released this earlier if you listened to me π ππ
Release it to where? Pypi?
Jus joking, I mean figured it out
Oh lmao
LOL IT'S YOU, while I was doing this I saw your project too, I liked your workaround for fixing the lag
Haha it's the only janky way to fix it
If windows 11 fixes it, its great, I can finally start modernizing tkinter.
What I'm doing now is while dragging use the normal blur, when it stops, use acrylic
Yup, obvious from the attachment shown
I've had that idea in the back of my head for a while but I'm too lazy to implement it. I'm glad there's someone else did it haha.
def initUI(self):
layout = QVBoxLayout(self)
self.setWindowTitle('title')
self.resize(450,350)
photo=QLabel(self)
photo.setGeometry(20, 0, 411, 100)
photo.setPixmap(QPixmap('logo.png'))
self.startbutton = QPushButton('Start',self)
self.startbutton.clicked.connect(self.openFileNameDialog)
#self.startbutton.resize(100,50)
#self.startbutton.move(0,150)
layout.addWidget(self.startbutton)
self.version = QLabel('''
Version 0.13.b
''')
self.version.setAlignment(QtCore.Qt.AlignRight)
layout.addWidget(self.version)
i am adding more thing in the code
however, i found out that the move is not working
the start button and the logo and the word(version) is overlap
i want the layout is the top part is just logo, second in start button and the bottom is the version
if you want to test tkinter from gif https://github.com/Peticali/FluentTkinter
just don't look at the code it's still a mess lol
Hold a sec i'll fire up my pc
i want the soundwave picture is just the photo, not the background
omg , i fix the bug
XDDDD
i miss to addWidget in the photo part
however, I am facing another problem. TT.
I want to select a file and then show the file name of the file in different def.
i cannot bring the thing out / show the file name only (not the path)
global ?
os.path.basename(filepath).
def openFileNameDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
soundfile, _ = QFileDialog.getOpenFileName(self,"Open File", "","Voice Files (*.wav)", options=options)
if soundfile == "":
cancel = QMessageBox()
cancel.setText("\nCancel selection")
return_value = cancel.exec()
return
else:
name = QMessageBox()
name.setText(soundfile)
return_value = name.exec()
self.output()
def output(self):
result = QMessageBox()
result.setText(βheading. ')
result.setInformativeText(βwordβ)
return_value = result.exec()
File name : ___________
Result: _________
i want to print sth like this. the ____ is a variable that in different def.
if you want to access a variable from different methods/function then make it class attribute so you can access it via the keyword self
hey guys! Any suggestions to make design of this calculator better ?
then , how to solve the path thing ?
i can print the 'c:/downloads/test.wav'
you want it to show the filename only?
but i just want 'test'
Try os.path.basename('c:/downloads/test.wav').split('.')[0]
Blur the background HEHEHE -the guy obsessed with blur
i am sorry, can you tell me the exact code? i am a newbie and i dont know where should i put the code.
okay I will try bluring background
Which function do you want it to be shown?
i want to print the 'soundfile'
CoolCloud's solution is simpler but this also works:
import os
path = "C:/Users/JohnDoe/hello world.txt"
converted = os.path.split(os.path.splitext(path)[0])[1]
print(converted)
import os
def openFileNameDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
soundfile, _ = QFileDialog.getOpenFileName(self,"Open File", "","Voice Files (*.wav)", options=options)
if soundfile == "":
cancel = QMessageBox()
cancel.setText("\nCancel selection")
return_value = cancel.exec()
return
else:
name = QMessageBox()
self.file = os.path.basename(soundfile).split('.')[0] # SHOW THE FILE IN THE MESSAGEBOX
name.setText(self.file)
return_value = name.exec()
self.output()
def output(self):
result = QMessageBox()
result.setText(βheading. ')
result.setInformativeText(βwordβ)
return_value = result.exec()
NameError: name 'soundfile' is not defined
it works.
!!
i forgot to put all 'self. '
for the output def. , can i use QVBoxLayout / Nesting Layout ? if then, can i make the same thing like the initUI ?
obviously wrong
furthermore, i want to make the start button become smalled (which i did it) and Center Alignment (which i CANNOT). Do you have any idea? Based on what i found, the QVBoxLayout do not have a code like AlignCenter. So what should i do?
layout.addWidget(YourWidget, alignment=QtCore.Qt.AlignCenter)
or if you want to center the whole layout:
layout.setAlignment(QtCore.Qt.AlignCenter)
i solve it. ^^ thank you
i am creating a gui from base level. how can i render screen properly by taking input, showing animations, all at the same time?
What do you mean exactly by "base level"? Are you creating gui from scratch?
yeah
just give me the idea, how to get input,show animations, and render the screen all at the same time? should i thread the rendering process, input process and animations?
how should i setup the system of these?
dunno much abt creating gui from scratch but concurrency should be a good way to do many things at once so yeah. i guess threads would work
ok then, thanks
Hi people. Hope you're all doing great
I don't know whether this is the right channel to seek code feedback or not. If not please redirect me to the right chnnel.
I' ve built a simple music player with Tkinter and pygame. Could you please review my code. I am open to all levels of criticism π§ .
Repo : https://github.com/omazdev/simple-music-player
I am sorry to ask question again. But how can I have two Layout in the code but in different def. ? because i am making the result thing, and i cannot make the layout of result appear. It can change the icon and the title only.
Great, if you want some reference take a look at https://github.com/nihaalnz/MPlayer
Having some trouble getting a basic UI to update a QMainWindow from a QThread using signals/slots. Anyone free to help?
Hey all, sorry if this has been discussed before. I have gotten into a discussion with someone on a different coding board about the use of lamda in a PyQt program.
He was not a fan, saying it was a bad practice. I couldn't find a work around for my use case. Depicted below.
(Action = is a menu button from a QMainWindow class.)
self.ui.action.triggered.connect(lambda: self.some_function('arguement'))
self.ui.action.triggered.connect(lambda: self.some_function('differentArguement'))
Thoughts? Without the need to seperate the above function into two seperate functions.
How else does he suggest
So he hasn't actually made a suggestion on how to fix the issue. He was trying to explain something with a dictionary, but it always fell back to the same problem.
That's interesting, going to have to review that documentation more. My cursory read it looks like you making a function container to remove the need for the argument.
Though, wouldn't that require you to essentially make a variable for each possible argument?
It would look something like this
self.ui.action.triggered.connect(partial(self.some_function, your_parameter_here='arguement'))```
Okay, that is an interesting approach. I am curious if that would work. Though I fear it would run into the same issue. As it appears PyQt prefers
self.ui.action.triggered.connect(self.some_function)
Everything else appears to fail.
partial should work but you could try a helper method something like
self.ui.action.triggered.connect(self.helper_func1)
self.ui.action.triggered.connect(self.helper_func2)
def helper_func1(self):
self.some_function('arguement')
def helper_func2(self):
self.some_function('differentArguement')```
hmm they the same event
I will aim to try the partial tonight to see how it responds. I am curious.
I know the helper functions would work. However, in my current use case would require 14 helper functions compared to the use of the lambda.
if they the same event do two things
self.ui.action.triggered.connect(self.helper_func)
self.ui.action.triggered.connect(self.helper_func)
def helper_func(self):
self.some_function('arguement')
self.some_function('differentArguement')```
lambdas can be used, ask your friend to find a reliable source that speaks otherwise
Will do, I mean I was more curious if other methods exist.
Yea, so far: functools.partial and helper functions can be used.
Hi guys I just found a library that gives a modern, Bootstrap inspired look to Tkinter.
https://github.com/israel-dryer/ttkbootstrap
Looks good π
bigger fonts π
What does this error mean:
||TypeError: arguments did not match any overloaded call:
addWidget(self, QWidget): argument 1 has unexpected type 'int'
addWidget(self, QWidget, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 1 has unexpected type 'int'
addWidget(self, QWidget, int, int, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 1 has unexpected type 'int'||
in the line:
lay.addWidget(tab.addTab(QWidget(), str('Tab')),1,0)
Can someone using pyqt5 help me
Any kivy expert here?
it seems like tab.addTab returns an int
what is tab?
Which is it gui library
Looks cool
PyQt5
Itβs pretty intermediate but youβll get the hang of it
The hard coding part is fairly difficult whereas the basic gui design can be done with qt designer and/or creator. which is basically an ide for guis
It's solved now
btw, what's the license of pyqt, I see mentions that it is not a free for commercial usage?
550 dollars per dev
I believe they dual license it with some commercial license and GPL.
GPL absolutely allows for commercial usage, but you have to keep it open source. If you don't want to open source your product, then you need the commercial license instead. Though that may not be the only reason for using the commercial license. I never bothered to read it.
Pyside on the other hand is licensed under LGPL. I don't think I'd be able to explain the differences between GPL and LGPL well, so that's for you to research.
Can someone help
I have an issue, i cannot use modules unless i take them to the same directory/folder as the python file, is there a way to fix that? Because otherwise it would say "No module named..."
"Syntax Error: Unicode error, can't decode bytes in position
" what could the reason for this error be? here's my code : `import time
import tkinter
import flask
from flask import Flask
from flask import request, jsonify
import flask
app = flask.Flask(name)
app.config["DEBUG"] = False
@app.route('/')
def home():
return "<h1>my 1st api!!!</h1><p> my 1st api</p><img src>'C:\Users\rorop\Desktop\1stAPI\IMG.jpg'</src>"
app.run(host='0.0.0.0')`
the error is somewhere in "<img src>'C:\Users\rorop\Desktop\1stAPI\IMG.jpg'</src>"
Is there any good video or book recommendation for qt creator with Python? (Pls ping me)
Feels like the heading can be pushed down, btw nice GUI
Hey, how can I go from an interface to another by a call
Let me explain more:
File 1 ----> Gui1
File 2 ----> Gui2
Method_in_file1():
This method will call the file2 to show the GUI2
----------All this with tkinter -----------
two different files and then import the other file?
looks like a lot of empty space
which framework u used ?
PyQt5
sure, share the code
Yea ok, share the code.
how is this signup page please suggest me improvement
Colors look good, I would add a little more whitespace between the form and the image and add some whitespace between Password and First Name to make the form easier to read.
You have quite a lot of free space on the sides so I would make use of that. Also, in my opinion you don't need another logo inside the form, which will give you a bit more vertical space to work with.
okay thanks sir
In terms of color and contrast it looks good, but maybe you could make the "Sign up..." text a bit darker.
Nice work, anyway take a look at instagram.com too?π
Depends on your main colors of course
yes π
Hello! Im trying to get a python GUI framework that's like electron but doesn't use a bzillion resources for nothing. I've tried countless but some were weird or too restrictive, others were just not documented at all... I've seen eel is a good option, I discarded it because I couldn't find how to eliminate the window frame (so I could make my own) but maybe I missed it. Is there a way to make eel remove the window frame?
This one
Basically make a borderless window
like vs code
i use web appπ
but apple will not allowed it π
PyQt will allow it, so will tkinter
Yeah but I hated those, Im looking for an HTML/CSS framework
I think I'll end up using neutralinojs and do it in javascript instead
with python?
Yeah
eel and flaskwebgui were good options, the only thing is the borderless window problem
Seems like better, I do not think there is anything else with python
Maybe I should just not base my language option because of a borderless feature tbh
You know what I'll just go with flaskwebgui
Im quite used to flask and jinja
lol all the best
Thanks
thats pretty sick but
just found out the creator of a popular point of sale program has sold it for 350-million two months ago; i got work to do
Ohh coool
Any improvement please suggest me
Sorry it's is html CSS Page I am building web application with Django
You cannot, an entry widget with height is called Text widget
but then how can i take multi line input?is it not possible
Use the Text widget?
i can take input from that?
Sure
oh , thanks
i have another question,
2)how can i trigger a function or some piece of code whenever a new letter is added in the Text widget by user
bind it to <Key>
bind the function to a specific key?
Not a specific key, <KeyRelease> means all keys
it only applies to a single Text object?
Yes?
yup same thing
yo i have a problem
Textbox.get() doesn't return latest character
for eg if i have written "qwerty" it will only return "qwert"
get(0,'end') ?
am doing get(0.0,'end')
i can add the last letter myself as it gives it to me as an argument in the function, but i don't understand the cause of the problem
Hmmmm try get('1.0','end')
Well, did you make sure you binded to <KeyRelease>
Binding to <Key> would cause a delay
Yup....that simple
sorry for disturbing you
I am here for tkinter, all you need π
hehe thanks
If you are interested it getting just the last letter you can bind to the <key> event and get the key from event.char
import tkinter as tk
class TkApp(tk.Tk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.txt = tk.Text(self)
self.txt.pack(padx=5, pady=5)
self.txt.bind('<Key>', self.on_txt_key)
def on_txt_key(self, event):
print(event.char)
if __name__ == '__main__':
app = TkApp()
app.mainloop()```
Thanks, but i actually want to use the whole text
so i am working on a UI on raspberry pi 4 and it included changing pages so i am using classes to create and change pages.
my question is how do i change the size of the frame in a frame class and how can i use .place function to place widgets in it ?
What is wrong about it?
i wanted to change the background color of frame and its size
and also use .place function to place widgets in it
Okay? You know what to do, then what is wrong?
how do i paste code in here ?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
class page_run(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent, bg = "white")
self.parent = parent
self.parent.geomerty("500x500")
this code is not changing color or size of the frame
because the frame has to be big
big how ?
i have defined the main window geometry to be 610x976 and is set to not-resizable
it still doesnt work if i set the frame size equal to the main window size
Can you give your entire code?
import tkinter as tk
class MainWindow(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.title("hello")
self.geometry("610x976")
container = tk.Frame(self)
container.place(x=0, y=0)
self.frames = {}
for F in (page_run, page_program):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(page_run)
def show_frame(self, name):
frame = self.frames[name]
frame.tkraise()
class page_run(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent, bg = "white")
self.parent = parent
self.parent.geomerty("500x500")
label = tk.Label(self, text = "page run\n\n\n\n", fg = "red", bg = "white", font = ("veranda", 20, "bold"))
label.grid(column = 0, row = 0, sticky = "nsew")
button1 = tk.Button(self, text="Visit Page program", command=lambda : controller.show_frame(page_program))
button1.grid(column = 1, row = 1, sticky="nsew")
class page_program(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text = "page program", font = ("veranda", 12, "bold"))
label.pack()
button1 = tk.Button(self, text="Visit Page run", command=lambda : controller.show_frame(page_run))
button1.pack()
if __name__ == '__main__':
app = MainWindow()
app.mainloop()
how do i remove this
root.overrideredirect(1)
is there way to add things to it and change things to it and change its BG color
nope, nothing that i am aware of
are you sure you are doing it correct? page_run is a class, you did not instantiate it
Maybe checkout this answer https://stackoverflow.com/a/68124161/13382000
https://loctv.wordpress.com/2016/09/28/python-tkinter-multiple-windowsframes/
i modified this refrence code to suit my needs and everything works. i just wanna know how can i implement frame command like background colors, frame size, .place function etc.
@tawdry mulch
thanks for your help
@tawdry mulch
Here is the code
class home(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self. filename = ''
self.create_widgets()
def create_widgets():
pass
def analyze(self):
if(self.filename != ''):
analyzer(self.filename).main()
results()
else:
pass
if __name__ == "__main__":
win = home()
win.resizable(False, False)
win.title("Sperm analyzer version 0.1")
win.mainloop()
|-----------------------------|
| The seconde class code |
|---|
class results(Tk):
def __init__(self):
Tk.__init__(self)
self.widgets_creator()
def widgets_creator():
pass
if __name__ == '__main__':
win2 = results()
win2.resizable(False, False)
win2.title("Sperm analyzer version 0.1")
win2.geometry("1024x768")
win2.mainloop()
@tawdry mulch any other method how i can change bg color and size etc ?
@warm rampart are u using tkinter ?
ok thanks
im not sure, sorry
I dunno, hope someone can help you out
i want the left touch the bottom
but for some reason i cant
##Making the terimnal
bo= Frame(root,height=20,width=width,bg=colors[1])
bo.pack(side="bottom")
bol=Frame(root,height=200,width=100,bg=colors[1])
bol.pack(side="left",pady=(height-89,25))
what
I would recommend using grid().
am not really good at grid can you write code for me? theres not problem if you decline this order
But I do not know what you want. It is better you start learning grid, it is more of a neat system of arrangement
Sorry I do not know
ty for help
Can someone using pyqt5 help me
How to color a certain word inside inside an entry
are you using QStackedWidget, try adding animation between the pages
Hmmmm I do not think that is possible, might be possible with Text though
With that said, you can make a Text be like an Entry, but not an Entry be like a Text.
thats a thing!?
Lol, then which widget do you use to switch between pages?
QtWidgets.QWidget
Hmmm? That is not what I mean, is this a public project? github repo?
what do you mean by that
Like is the source code available to see
i created it myself, but i can send the code for the main file here
Well I would like to see a gist of it....
Ah you are manually using show() and hide(), behind the hood, QStackedWidget does the same....Check it out
main/main.py line 46
self.ui.back2_btn2.clicked.connect(lambda: self.ui.stacked_wid.setCurrentIndex(0))```
....to change pages
help
how do i make entry inside scroll bar
scrollbar = Scrollbar(root,bg="#1C1C1C")
scrollbar.pack(side = "right",fill =X)
mylist = Listbox(root, yscrollcommand = scrollbar.set,bg="yellow",fg="black",bd=0,width=10)
for line in range(100):
mylist.insert(END,str(line))
mylist.pack(side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )
line = Frame(root,bg="white")
line.pack(side="left",fill=Y)
############
scrollbar = Scrollbar(root,bg="#1C1C1C")
scrollbar.pack(side = "bottom", fill = BOTH)
mylist = Entry(scrollbar)
mylist.pack(side = "left",fill=Y)```
oh am making new scroll bar
i will try to solve it
and still
i will keep trying
untill some one comes and helps me
whaaat?
https://paste.pythondiscord.com/tenetuxike.py
This is someone's tkinter program. In the button_clicked function, we figured out that if the repr of item.cget("textvariable") isn't accessed then it returns something like <string object: '0'>, which it says is the type <class '_tkinter.Tcl_Obj'>, but if the repr is accessed then it returns a str. That's why the first line in the loop is repr(item.cget("textvariable")), to force it to only append str because that's what he wanted.
Why does it work like this, and is there a better way to deal with this? I ask because I don't have much experience with tkinter, so it might not be a very good way to solve this.
Hello! I hope you are all doing well. This is my first time using this server and I was wondering if I can get some help with the GUI I am working on. My class Graph() creates a basic pyqtgraph plot which I want to be set as the central widget in my main window. Currently, when it is initialized it pops up as a separate window. How do I fix this?
""" This class creates the real-time plot in the GUI
Main methods:
initializeSpace - creates a layout for Graph GUI
"""
def __init__ (self):
super(Graph, self).__init__()
self.initializeSpace()
def initializeSpace(self):
# Make Widget that will hold everything
self.widget = QtGui.QWidget()
# Create basic buttons next to graph
start = QtGui.QPushButton("Start")
stop = QtGui.QPushButton("Stop")
# Create plot
self.plot = pg.PlotWidget()
# Add grid
self.plot.showGrid(x = True, y = True)
# Create Layout
self.layout = QtGui.QGridLayout()
# Add widgets to layout
self.layout.addWidget(start, 0, 0)
self.layout.addWidget(stop, 1, 0)
self.layout.addWidget(plot, 0, 1, 3, 1)
# Set layout
self.widget.setLayout(self.layout)
#return self.widget
self.widget.show()```
""" This class creates the Main Window
"""
def __init__(self):
super().__init__()
self.initializeUI()
def initializeUI(self):
# Setting Up Geometry of Main Window
self.setWindowTitle("Menu...In Progress")
self.setGeometry(100, 100, 800, 500)
self.createActions()
self.createMenuBar()
self.createStatusBar()
# Place graph into mainwindow
self.graph_widget = Graph()
self.setCentralWidget(self.graph_widget)```
Thanks in advance!
What do you expect the cget("textvariable") to return? The actual object reference?
I guess Iβd expect it to return the same value whether its repr was accessed or not. Iβm just wondering why accessing the repr changes the methodβs return value, that seems really weird
And if the solution is good or not
Hmmhmm, why are you passing in an integer as textvariable
textvariable should be tkinter variables
