#user-interfaces
1 messages ยท Page 68 of 1
Haha I'm learning tkinter atm as part of Basic Programming (first year on a bachelor)
you should learn PyQt and Kivy too!
Ye, I like Python. We havent been "allowed" to use a lot of python-specific stuff yet, so would be cool to see what you really can do with python ๐
I just made the worlds shittiest program though. Couldnt figure out how to clear components in time for the deadline, so I just removed the option to search for something twice
PyQt makes your life much easier...
guys how can i get empty string LineEdit value in Qt?
wdym "empty string lineedit value"
line I need to check if a line edit has got some word/character in it? How do I do that?
get its current text with <widget>.text() and do like:
if word in <widget>.text():
#do something
ok thx ๐
np
move up your surface.blit and pygame.display.update()
I would create a class that subclasses tk.Frame and tracks all widgets it creates in internal lists, having methods like clear, setdata, getdata and addrow to make it usable. Basically creates a tkinter frame with a lot more to it.
Also, you only need one mainloop per application, toplevels have a parent, they run with that. If you want toplevels to take the spotlight, call .focus() to focus them and .grab_set() to reroute all events that may show up to them
Yeah I was wondering, I had used it 5 years ago & was surprised people were still using iti
Hey, first of all sorry if this is the wrong chat room.
I was wondering what the best GUI framework for python is atm.
I'm in need of creating an application at work, and because management doesn't enjoy want just a command line application they want some GUI.
Is there an equivalent to something like Electron.js where you can add styling in the form of CSS?
Thanks
@full bolt if you want "stylish" UIs then PyQt is a good option to start with. Not wrong to mention here that Python doesnot have a truly amazing GUI library that has CSS like features in it. Tkinter is easy and quite flexible, yet it has an old school GUI look to it. But you can always start with creating your own little library by modding functions of some already existing libraries.
No way its CSS, but QStyleSheets use QSS, which is pretty similar. PyQt5 in my book as well.
Hey guys, what library would you recommend for terminal based ui's?
I want to do something like this
looks nice!
thx
curses i guess?
i was afraid of this answer
@digital rose what do you need terminal GUIs for? i cant think of any reason as to why you should opt for terminal based GUIs rather than the regular ones.
anyhow, try Urwid. a pretty clean terminal based GUI package, a personal favourite too.
here: http://urwid.org/tutorial/index.html
@digital rose If you're trying to avoid curses check out "rich" https://www.willmcgugan.com/blog/tech/post/building-rich-terminal-dashboards/
Rich has become a popular (20K stars on GH) way of beautifying CLIs, and I'm pleased to see a number of projects using it. Since Rich is mature and battle-tested now, I had considered winding-down development. Until, I saw this tweet: The Tweet Do you want to see something really cool you can do [โฆ]
I really just like the aesthetic ยฏ_(ใ)_/ยฏ
Thanks, i'll check it out
I have a question, how can I change the value in pygame.math.Vector2?
mhm
def delete_input_box(self):
self.label_file_name.destroy()
self.lineup_name_entry.destroy()
def input_box(self):
self.lineup_name_entry = tk.Entry(self.canvas1, bg="black", font=('calibre',10,'normal'))
self.label_file_name = tk.Label(self.canvas1, text="Enter")
self.label_file_name.place(x=305,y=250)
self.lineup_name_entry.place(x=300,y=210)
self.bind('<Return>', self.delete_input_box)
return self.lineup_name_entry.get```
anyone know why this doesn't destroy the entry and label? (tkinter)
You need to destroy lineup_name_entry.master (I am guessing this is actually a root window) because if you do not then you end up with a big box on the screen that is not transparent.
too late
Gotcha. Urwid's going to help a lot then.
It's the one i am currently considering. Do you know any resources beside the documentation?
Not really. I have done all of it from the docs only.
Just start by messing around with the sample programs
Hello, hope PySimpleGUI is the same thing as user interfaces. I'm getting this problem every time.
DUDE I HAD THE SAME PROB FOR HOURS
damn
oop
tas what i was missing and took my hours
really tho
what's gen :D
general
I'll read them then and will play around with it
Thank you!
def delete_input_box(self):
print('test')
self.user_lineup_name = self.lineup_name_entry.get()
self.label_file_name.destroy()
self.lineup_name_entry.destroy()
self.get_click_pos(self.button_text)
return self.user_lineup_name
def input_box(self):
self.lineup_name_entry = tk.Entry(self.canvas1, bg="black", font=('calibre',10,'normal'))
#self.lineup_name_entry.iconbitmap("valorant.ico")
#self.lineup_name_entry.title("Lineup Creation")
self.label_file_name = tk.Label(self.canvas1, text="Enter")
self.label_file_name.place(x=305,y=250)
self.lineup_name_entry.place(x=300,y=210)
self.bind('<Return>', self.delete_input_box)```
When I change the last line to self.bind('<Return>', self.delete_input_box()) it works, but runs automatically
but currently it doesnt run when enter is pressed
like doesn't print test either
You called self.delete_input_box, and events in tkinter also pass in an event param for the function you put, for the first issue, you would just remove the parentheses, but an easier one (if you aren't using the event), is to do lambda e: function().
so i decided to do a little project in python as practice and for fun and i also decided to make it a gui application but i dont know anything about guis in python so how do i get started?
bit harder than the default lib, tkinter, but I'd recommend PyQt5. You get a lot more features and the UIs look more modern.
alright then so should i start reading the docs for that then?
i read the packt book
has literally everything
but yea, the docs should be good too
dm me if u need help
aight thanks dude
np
Anyone have a good way to do something like tabs for pysimpleguiweb?
anytime!
@lapis scarab
ive been onto tkinter for 5 years now. its far more flexible and powerful than most people who expect it to be. i have never used PyQt5 because i never felt the need to. I dont use any ide from the internet too, just made my custom ide in tkinter. The point is, tkinter is more user-friendly, and has even more customisable Widgets. if you want stylish UI in tkinter you can use Themed Tkinter widgets (TTK).
i would recommend pyqt than tkinter even if its a bit hard to learn compared to tkinter
this is what happens when you comment on something you dont know about.
sigh
How would I go about making a drag-and-drop block-based interface in Qt? Kinda like the Lego NXT software, but instead of being side by side, allow every block to have inputs/outputs where you can drag lines between them
Image of Lego NXT:
I've seen some examples of how to do drag-and-drop in Qt, the main thing i have trouble with is how I'll link blocks together with lines and how I can create a block instance when it's being dragged out of the sidebar
Yeah I managed to do some tinkering with it and got it to work, but thanks for the help I just used that information for a different binding, appreciated.
Join Free PyQt5 Course:
https://geekscoders.com/courses/pyqt5-tutorials/
My Affiliate Books:
Beginning PyQt: A Hands-on Approach to GUI Programming
https://amzn.to/3m8hsAZ
Create GUI Applications with PyQt5 & Qt5
https://amzn.to/3jahfLv
Python GUI Development with PyQt5
https://amzn.to/3kfVzPD
In this PyQt5 video i want to show you How To...
Maybe this video will help you
got any text-based sources? not a big fan of videos, especially when on data
also what I'm trying to figure out seems a lot more difficult than a 13 minute video can explain lol
i just looked at it for interest and they have it on their website
take a gander
got a link?
I found QDrag but that seems more related to moving e.g. files to import their data
@ivory ember
I mean I can't watch the video right now
and I can't seem to find anchor points for drawing lines between the dropped blocks
im just helping with "text-based sources" my guy, i duno about drawing lines
Isn't that exactly what I asked for though?
The main thing i have trouble with us how I'll link blocks together with lines
It also doesn't answer my other question:
... and how I can create a block instance (i.e. don't remove the one i dragged from) when it's being dragged out of the sidebar
Hi. I am very new here. I was wondering if I could get some help with my code and if so where should I post it?
@minor dove try #โ๏ฝhow-to-get-help
thank you!
i'm sorry, but i'm just helping u find the source
if i knew how to do it, i would've told you
Qt Designer
nvm
you want to make a drag and drop interface
https://paste.myst.rs/k388rq0p So I am trying to make a custom python window using pyqt5 but it says that the language is not supported or defined. P.S. I am using vs code as my IDE. And I am sure that I installed pyqt5
a powerful website for storing and sharing text and code snippets. completely free and open source.
I am currently placing tkinter image buttons on top of another image, but I want the button images to have transparent backgrounds (to show the image below rather than the white) is this possible?
actual image
whats the error?
Oh I fixed it already ๐
correct
Hi, I'm currently making a program using tkinter, and I can't figure out how to delete a button from inside a function. Can anyone help?
can you post some code for context?
gimme a sec
you might just want to copy paste it.
too many characters
!paste @ionic remnant
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
oh ok
Basically, you press the "start game" button and it's supposed to delete that and replace it with the buttons for the game. Instead, it stays there and gives me an AttributeError
what exactly are you trying to build?
ok i think i get it. when you say self.destroy(game) you are calling the object to destroy the "game"button
yes, exactly
what youre doing wrong is that youre calling object.destroy(*arg) whereas .destroy() is a function designed to destroy tk widgets. just replace that line with game.destroy() wherein, destroy() doesnot take any arguements.
and wait
your class structure is quite messed up. youre calling class (object), whereas you must say class button(Button): wherein Button is a Tkinter object!
oooh
and to create the button, instead of calling game.button() , do this:
class button(Button): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def PACK(self): self.pack() .. .. .. .. .. .. ..
this creates a tkinter button, that takes in default button arguements as *args, **kwargs
ok...
I think I get it
It's getting late here though, so I might just pick this back up tomorrow, if you don't mind
alright
so, i am making an application using pyqt5
i want to close the window when i click a button, so i wrote this for that:
self.login.clicked.connect(self.closewin)
and the close fuction is:
self.close()```
and i am getting this error
```AttributeError: 'Ui_MainWindow' object has no attribute 'close'```
what should i do now?
can you post the full code?
Which library is the easiest and more intuitive to work with? I've tried tkinter, which seems to require less code, but I'm having problems with making the layout responsive, even though it looks like it would work.
Also, is there a less introductory tkinter guide that is less verbose and more of a "this class is for this, these are the most common methods, which do this" guide, with good practices and tips?
I'd personally recommend PyQt5, but I've heard a lot of good stuff about PySide and PySimpleGUI
I've looked at pyqt5, but it seems you have to do more work, so I'm a bit hesitant.
I've found Qt to be very similar to React in the sense that each component is standalone and has its own state
If you want something real simple, go PySimpleGUI
i took a time to learn well pyqt5 and I still don't know 100% pysimplegui is a good one for starting
Any good pyqt5 tutorial that goes straight to the point?
PyQt5 is a lot less work than Tkinter
because of Qt Designer
drag and drop your interface
and convert into code
sadly, no. But I do have some good docs
check this: https://www.learnpyqt.com/
Learn Python GUI programming with hands on tutorials and examples. Build your own apps with PyQt5.
I'll take a look, thank you
Learn to code with our quick and easy to follow videos! Python, Django, Tkinter, Kivy, Node, Ruby on Rails, Ruby, HTML and CSS, Javascript, SQL, Ubuntu and More!
Check out my website Codemy.com for more videos!
i am making a to-do list, is this looking good?
overall layout looks good
might want to change the "done" to complete, at least for the "Done Selected" btn
so it would make more sense to say "Complete Selected"
in short, looks great!, just polish it up a little
good job man
what about this? i added a reminder too which will remind you about your task
wait
this one
nice layout
thanks
The best my interface skills can do is barely make a snake game... AMAZING!!!!
NOICE
(TKINTER)
I have a list containing all the buttons that have been placed, is it possible to iterate through the list with a for loop and do i.config(command = i.destroy) to change the command to delete the button when clicked?
this is my current code:
py def delete_user_lineup(self): print(self.placed_lineups) for self.placed_lineup in self.placed_lineups: self.placed_lineup.configure(command=lambda:[self.placed_lineup.destroy]) self.placed_lineup.forget() self.placed_lineup.place()
The output of print(self.placed_lineups) is:
[<tkinter.Button object .!frame.!activemapgui.!button29>, <tkinter.Button object .!frame.!activemapgui.!button30>, <tkinter.Button object .!frame.!activemapgui.!button31>]
And here is where the original buttons are appended to the list:
def place_lineups(self, default_lineup):
# Iterate through all lineups in the list and set the correct icon for each lineup
self.placed_lineups = []
for i in range(len(self.agent_lineups_list)):
self.lineup_button = tk.Button(self, width='20', height='20')
self.path_to_img = "icon_images\\" + default_lineup["ability_type"] + ".png"
self.pil_icon_image = Image.open(self.path_to_img)
self.pil_icon_image = self.pil_icon_image.resize((20, 20,), Image.LANCZOS)
self.load_image = ImageTk.PhotoImage(self.pil_icon_image)
self.lineup_button.image = self.load_image
self.lineup_button.config(border="0", image=self.load_image, command=lambda: [play_video(default_lineup["lineup_file_loc"])])
# Place lineup to the coordinates specified for the lineup in the config file
self.placed_lineups.append(self.lineup_button)
self.lineup_button.place(x=default_lineup["x_coordinate"], y=default_lineup["y_coordinate"])```
Hello everyone,
making UI form and got problem
got error when trying to open second PyQt window
TypeError: QWidget(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'sip.wrappertype'```
```class Login(QtWidgets.QWidget):
def __init__(self, parent=Client):
super().__init__(parent)
self.lg = Ui_Login_form()
self.lg.setupUi(self)```
its inherited from
```class Client(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)```
Anyone has idea how to make my app nicer?
how did u make that interface? with what?
oh with tkinter
looks cool
i am thinking about changing buttons i have a lot of space on left side
use stylesheets
PyQt5 makes the best UIs imo
Yes
yep
I think you need a relative path for your logo.pngatbe try './logo.png'
It is running if I exclude 5th and 6th lines
i didnt know you could do user-interfaces with python
This is cool ๐
This is actually very easy to fix
You will be want os library to fix
Second
thanks!
also i have a question,
how to close or hide a window in PyQT5?
Ah sorry I don't know in pyqt just tkinter sorry again
window.close() or window.hide()
File "d:\important stuff\JNNSMEE\gui2.py", line 369, in <module>
ui.setupUi(MainWindow)
File "d:\important stuff\JNNSMEE\gui2.py", line 344, in setupUi
self.pushButton.clicked.connect(MainWindow.close())
TypeError: argument 1 has unexpected type 'bool'```
i got this error
you're not supposed to call functions in a connect function
self.pushButton.clicked.connect(self.close)
maybe try this
This will help you @tacit swan
import os
path = 'logo.png'
Image_path = os.path.join(os.path.dirname(__file__), path)
That didn't work
Didn't work
The problem is when I execute program it is showing error in init .py file.
Hey @ionic moat, i made a function in which i have to close the main window but when i used your solution it showed me this error
File "d:\important stuff\JNNSMEE\gui2.py", line 241, in find_and_login
MainWindow.hide
AttributeError: 'bool' object has no attribute 'hide'```
this is the function
I think you want self.hide and also, you have to call it there
you don't call functions inside a function call when you're passing it as an argument
but if you wanna run the function 1 time, you call it
oke lemme see
File "d:\important stuff\JNNSMEE\gui2.py", line 241, in find_and_login
self.hide
AttributeError: 'login_ui' object has no attribute 'hide'```
nope
Where is the window object?
wdym?
there are two functions, setupUi and find_and_login
def find_and_login(self):
def setupUi(self, MainWindow):
can you try using hide on it
oke
File "d:\important stuff\JNNSMEE\gui2.py", line 240, in find_and_login
QMainWindow.hide()
NameError: name 'QMainWindow' is not defined```
nope
Remove the Q
nothing happens
Then we can't do it without the window object
self should be the window object though
with self, it says that
File "d:\important stuff\JNNSMEE\gui2.py", line 240, in find_and_login
self.hide()
AttributeError: 'login_ui' object has no attribute 'hide'```
self is the class maybe
because the class name is login_ui
need to trace may through... where are you calling that method?
which method sir?
find_and_login
Hey @spare glen!
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:
what does def find_and_login(self): and MainWindow.hide() do?
def find_and_login(self): finds the name and password entered in the text input in the database and Mainwindow.hide() idk
i removed the MainWindow.hide() coz it does nothing
remove/rename the mainwindow in the def line
readd the MW.hide()
Hey, I'm working in PySide2 and creating an application running inside Autodesk Maya. I'm having some trouble with getting windows to stay on top. My main window has the maya window as it's parent and stays on top of Maya fine. But any subsequent windows I open, won't stay on top unless they're QMainWidgets with maya as a parent. If I try to just keep them QWidget and give them a parent, they get drawn inside the main window I parent them to, instead of opening a new window. And even if I just give it a stay on top window flag hint, it just disregards it completely.
has anyone tried pyside6 or are people still using pyside2?
pyside 6 doesn't have the full feature set pyside 2 has yet, I guess
It's safer to use pyside2
eventually you think?
Yeah
im willing to wait. i use a few different gui modules now. just looking into my pip script and figure i should add pyside
oh i have, years ago
pyqt4 and original pyside
just went a different direction for a while trying out different UIs. remi, flexx, appjar, pysimplegui, wxpython, tkinter (again), flask etc
Ah alright
anybody here able to help me with tkinter stuff?
I have been stuck for soo long in this dumb issue and really need help as im runnign out of time
@modern marsh i take it you are a qt fan? I started moving away from qt because i had some apps i wanted to write for $$ but pyqt caused some issued. and pyside had a hard time working on my computer
i am a fan but not a fanboy per se
i like using tkinter too but imo qt is far superior
which module do you think is the best
@modern marsh can you help me with something in tkinter??
if i know it, sure
ok so
#global variable
PHU_CODE_tk = ''
def Q1comboBoxValue(event):
global PHU_CODE_tk
PHU_CODE_tk = q1DropDown.get()
print(PHU_CODE_tk)
q1DropDown.bind("<<ComboboxSelected>>", Q1comboBoxValue)
all i want is for that global variable to get the updated value of what i select on my combobox
but setting it in the function doesnt work
i have never worked with comboboxes in tkinter so idk how to solve this
ok no worries
are you sure that the event is being called by the bind()?
yes
because if i print out the PHU_CODE_tk inside the function i see it
and i see the updated value each time
the only thing is the global variable is just empty, its not getting teh value
and i think its because im calling it inside of bind() but I need to
My goal is to get the updated value of what I select into that global variable
ah
ive been stuck for soo long its so annoying
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
sure, its really long and messy but the only parts that affect this is at the bottom where I call the function
idk if it will even run because theres files you need
like photos and stuff
@mighty breach so i deleted some code and stuff and the global var is getting updated
yes
i deleted all labels and buttons
then made my own button to print the global var
and it works
doesnt matter
i agree with you on the thinker vs qt. qt is far superior and easier to use.
right now, i have been using appjar. it is a simplified version of tkinter but it had worked out well for me. but i have hit the ceiling on it on one project.
ah i see, so you want to switch back to Qt?
that black thing at the top is the button i made
alright, i gotta go now, if you need help i will be back later on
dunno yet
just like having options
ah alright, good luck :D
i made a few apps in pyqt and enjoyed the coding
but i dont like pyqt due to the license
thus why asking about pyside
i have been playing around with flexx, pyjs and the like to have pure python versions of webapps
yeah pyside doesnt have license issues afaik
yea, pyqt does, pyside doenst
but i have always had issues with pyside actually functioning on my computer
@modern marsh where did i initialize the globla
at the top
and if i made money, i would b happy to pay for a license, but $500/month is steep
going away from pyqt was for the same reason i went away form fusion360. I dont like the idea of being forced to open source my stuff. i usually do, but i dont want to have to
I'm pretty sure you're only supposed to pay for a license if you want to use a Qt app commercially and under your own license agreement and private/closed source
otherwise commercial use for Qt should be free as long as you follow their guidelines such as:
Publishing the source code (making it open source)
Giving it an LGPL v3 license
etc
but don't take my word for it I might not be right
qt is free
pyqt is not
they changed the license to a stricter license with pyqt
pyside kept it the same
i remember looking a short while ago
Pretty sure it still applies for PyQt
when?
it is stupid too
that is why they can charge
pyside you can make money
pyqt you cant
Yeah when?
doesnt matter right now because i havent made a dime on my apps
i dont remember when
but i was looking at it about a year ago
i just dont like the forced open source
i am fine with sharing my apps, but not always my source code
what if i want to keep it to myself??
I remember it saying you must pay for a commercial license or make it open source & propitiatory under their list of conditions with their chosen license
yea
"must make is open source" is what gets me
i tend to open source most of my shit, but i like to have the option of not
thus why i moved away from fusion360. i have a design that coudl let me retire by 40
If you don't want to then I think you gotta cough some money
but i hate the idea of it on the cloud
Yeah I agree it's pretty strict
I don't like their terms but there's nothing I can do
ยฏ_(ใ)_/ยฏ
that is why went elsewhere and not with qt based guis
appjar is pretty decent
simple but effective
I wonder what my second option would be after Qt ๐ค
Basically anything else that's dated and has a designer for it
you need a designer?
that is tough then
i also tend to run apps that are a bit more dynamic where the number of items on the gui can change, so i like to code my gui instead
I use tkinter, I find it quite useful! It does have a few things that might not be the best, however it gets the job done well.
You can't really use while loops without breaking some part of it, so it does get annoying.
appjar has done well for me thought
On my last app I settled on pyside. Took some time to learn but eventually got it to work. The problem is that there aren't very good guides for GUIs in python that aren't basic and require threading and such. Especially for PySide/PyQT.
i have an app that dynamically builds 90% of the app from a json file
Can you install appjar with pip? Never heard of it.
none of that pack crap
it's still under development by the looks of it
yea but fully functional
Ok, thanks! Will try it out.
wrote two apps for it for work a two years ago and still going strong
lots of options in there
i have it pulling form network drives, combining pdfs, importing pdfs, exporting pdfs and xlsx docs
Qt docs have everything you need even if its in C++
and you can easily switch between PyQt5 and PySide2 as most of the code is repetitive in both
as far as i have tried
yep
your path to logo.png is wrong
to fix that error keep the logo.png in the same folder as your code
or like loki said enter the correct file path
Oh trust me. I looked a ton at the docs. Still took time to figure out how to thread my program and transfer data from the thread to the main thread. Especially as someone that was doing it his first time with no past experience in other languages.
I made a stock alerting app for my dad (faster than TD Ameritrade's stuff. Pretty sad lol). Definitely a good learning experience but brutal. Threading info in the QT docs was a bit beyond me. Sometimes I just need something explained like I am five ๐
well, thats true lol
did you exe it?
for him yes
pyinstaller to make the exe and Advanced Installer to make the actual installer
check out nuitka
i just did a test with an app tonight
pyinstaller, 12mb 8 seconds to load
nuitka, 600kb, 2 second load time
i am having issues with my pyinstaller exe files that i have hosted on a network drive lately. now that everyone is working from home and using VPNs, loading time can take up to 30 minutes. When at the office where the servers are physically located, 30 seconds is standard
i am now remote so it takes me about 10 minutes to load the exe. luckily, i can just load the py file and it loads super fast
but my IT dept wont let me have others install python on their computers
Are you just making it all into a single exe?
Yeah, onefile is very slow.
not really if it is on your computer
it is tolerable at least
but over the network, shoot me
i discovered nuitka today, so i am looking forward to monday
gonna have a few people test it after i recompile my apps
I will have to play with nuitka. Luckily my app isn't huge as it is.
i was surprised by the load time
i want to get it on the network and test it out
if it loads under 1 minute, i will be happy
i host them on the network so i dont have to make an installer or have people update if i make a change
if they all just create a shortcut from the network, all i have to do it swap the exe and it is updated
is this javascriptj
just ask away and ppl will help
The title says it clearly, rite?
Hi
I have a doubt with tkinter in python
if anyone knows tkniter and could help me pls dm and help me
you can post your query here.
Hi guys! I was wondering if either of you could point me in the right direction as my current project isn't in my area of expertise.
I store my (anime)series' ratings on an online database (and have access to their API) and want to re-rate most of the series on it (my tastes have changed over the last few years)
I wanted to build an web/or any other interface to help me rate these at speed (using my keyboard only). I was initially thinking of doing this using pygame? Since that's the only GUI library that I have somewhat experience with.
But I was wondering if you guys knew of any other "easier" or elegant way I could get this interface setup quickly.
My main area of comfort in Python is data science, so this just feels quite daunting to me :S
First of all, pygame isnt a GUI library, it is a game dev library :P. Try something like Tkinter, which is easy and dynamic. Secondly, what kind of interface d you wish to create? and you also need to choose b/w desktop apps, and web apps, for instance. This is because web and desktop apps have a whole set of differences b/w them.
I don't know how to explain what kind of interface I want to make. I mean ideally. I want something which cycles through series (or skip) with left/right keys. And then press a number (for new rating) and then press enter. And then perform some sort of a 'mass-update' to the server.
And you're right it is a game-dev library ๐
I just realised, I didn't fully specify my problem earlier.
ah i get you. Tkinter has a widget called listbox. Just a widget, with items, through which you can scroll. consider this idea (ill post example code if you want):
- you draw the widget onto the screen.
- you then add the names of all items you wish to rate.
- you then record events, for key press. ( for instance, when the selection is on a particular item, and then you press 1, it assigns 1 star to that item.)
- create a command that creates a table with items in one column and ratings in the second one.
the listbox
Okay! I think I can try giving that a go
this is an example table:
Okay, I'm gonna get the boilerplate from the API setup and I'll give this a shot. Thanks
Anybody here that can help me with tkinter?
Iโve been stuck for so long and I really need to figure out this issue to continue
Ok sorry
I have a combobox and I basically just want to current selected value to be stored in a global variable, I am binding the selection to a function that sets the value to a global variable but itโs not working
im not sure if this is the right channel but how do i put images on my tkinter window
X = tk.PhotoImage(file=โโ)
A = tk.Label(image=x)
thanks
You have pillow module too to do that
Hello guys,
i have a trouble with PyQt5 and Python 3.7.9
thats the code of Login Class:
def __init__(self, parent=None):
super().__init__(parent)
self.lg = Ui_Login_form()
self.lg.setupUi(self)
self.checkThread = CheckThread()
self.lg.btn_login.clicked.connect(self.login)
def login(self):
login = self.lg.line_login.text()
password = self.lg.line_password.text()
# self.checkThread.thread_login(login, password)
self.callMessenger()
def callMessenger(self):
login = Login()
login.lg.setupUi(Login_form.hide())
client = Client()
client.show()```
and UI file
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Login_form(object):
def setupUi(self, Login_form):
Login_form.setObjectName("Login_form")
Login_form.resize(270, 205)
Login_form.setMaximumSize(QtCore.QSize(270, 205))
font = QtGui.QFont()
font.setFamily("Calibri")
font.setPointSize(12)
Login_form.setFont(font)
self.label = QtWidgets.QLabel(Login_form)
self.label.setGeometry(QtCore.QRect(100, 10, 70, 40))
font = QtGui.QFont()
font.setFamily("Calibri")
font.setPointSize(24)
self.label.setFont(font)
and etc.
so i want to call method that opens another UI and closes current with ```hide``` method
i mean i have 1 class with Login form, and with button i want to call another one Form and close current
without closing programm
whats the easiest way to create a hyperlink with tkinter
Does anyone here use Gtk?
The Glib.idle_add(callback, *args, **kwargs) function is supposed to call a callback function when Gtk is idle. From my testing, it seems like the callback is called once, but the documentation seems to hint that the callback is called multiple times. Do you have any idea?
(Please mention me when replying. I won't get a notification otherwise)
figure they show it better than i could
thx
so i am creating an application in python and i want to use pyqt5 to make that app but i dont know anything about guis in python nor do i know anything about pyqt itself so how do i start building with it
Youtube pyqt5 and you will get a list longer than you care for @lapis scarab
alright then thanks
Yesterday I saw a post showing a module of python that makes dark theme GUIs, but I can't find the post and neither I can remeber the name of the module
I think it had something related to dracula in the name, does anyone know what it is?
Remi, appJar, and pysimplegui all make dark themes
Hey, so I'm quite new in Python Tkinter, and I'm currently making a 5-Question Geography Quiz. However; I can't seem to figure out what's going wrong in a certain bit of my code. So basically, the first question, if the user selects the correct answer, I want the program to output a Label saying "Correct", but then I also want a delay in between the Label showing and the window closing and moving onto the next question. When it's ran, I click submit on the first question after selecting the correct answer, and the button stays pressed down for the 2 seconds I set it for, but doesn't show the Label saying "Correct". Here is the code: https://paste.pythondiscord.com/teravoleme.apache
Hey @normal frigate!
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:
fook, the code is too long; how do I post it?
!paste
good evening. I wanted to build a graphical petri net editor, so i can specify my code as a petri net and automagically generate a C++ code template from it for embedded targets. There is a little bit more to it, but it's not important for this particular question.
I need to understand how i can create clickable and draggable graphs in python; I have looked at networkx, it's not really suitable since it's only for the graph part; Then there was qt. But is qt flexible enough to have something like clickable circles without a lot of work (e.g. mouse events, tracking circles and having to calculate distances and things like that.?
it looks something like this:
What would be a good starting point to do things like these? I have thought about managing the data in adjacency matrices (or even networkx!) and certain containers for the T_n things and present it using qt5, but the drawing part is what seems hard to me with these boxes, lots of arrows and lines and circles each clickable and dragable. I have never programmed a single GUI in my life, so literature recommendations are welcome too.
i don't wish to spend a terrible lot of time with GUIs though as I come from the domain of systems and control theory and would rather treat it as a tool for something else, but just enough so that it works.
Hey, that sounds like something comparable. How is your idea going on? Are you progressing and mind you share your insights? I'd be very happy ! ๐
decided to work on the back-end first, UI will come later
turns out doing real-time audio in C++ in a blocking fashion is awful
Would it be OK for you if i dm'd you to ask you more about it?
sure
So whenever I use tkinter, I get these annoying boxes that pop up over the duration of the program. Over the course of the program, they continuously build up until I'm left with an unruly amount littering the screen.
root = tk.Tk() badfits = simpledialog.askstring(title='Bad Fits?', prompt = 'Change Fits? (y/n): ') root.quit()
This is literally all I do for tk. My impression that root.quit() was supposed to close the box.
try root.destroy()
and according to docs, only one instance of Tk() should be present for a program
consider using one Tk() and others can be Toplevel()'s
i am not very sure of this though
Hey! I am hopping that someone could explain how the PyQt5 licensing works? In my particular use case, I developed an gui to visualize some data captured from sensor. If I make the software opensource under MIT licence can I still sell the executable without needing a commercial licence for PyQt5? The software is also tide to the hardware so could I just sell the hardware and then offer the software for free?
Idk PyQt5 license exactly but you can just change the imports to PySide 2 and it will work the same with some small changes needed
please help
This strange
pls?
anyone who knows how to make gui with qtdesigner and use it in a python program dm me need help, might pay
I know how
Im using matplotlib but when i use py plt.show(block=False)
but when i use it , the window crashes as it runs the rest of my program
sweet shit!! i got nuitka to work with appjar today (i hope). will do a final test tomorrow to swee if it works on a computer without python
can someone tell me why this isnt working?
u see the first box
its supposed to be styled to the styling i pu
put
idk why its not working
this is using the pyqt5 designer app
does anyone know how to remove an uninstalled shortcut from the bash source file on linux ubuntu?
does that even matter?
is it QLinearGradient maybe?
it might
no, it works for me when it is all lowercase
oh alright
actually
the problem is you're using border-color
you need to do it like this
border-left: 1px solid qlineargradient(bla bla bla);
border-right: 1px solid qlineargradient(bla bla bla);
border-top: 1px solid qlineargradient(bla bla bla);
border-bottom: 1px solid qlineargradient(bla bla bla);
is that not redundant
ill try it out
yes, but it works
what are the parameters qlinear gadient takes?
is it
just three values
its a gradient
wos
os
so
where do i put the other values
Hello. I was wondering if anyone here could help me with problem i encountered. I'm trying to open multiple (2 atm) windows, but somehow its not working. I tried looking through the stack and docs, but I cant find solution to my problem. If anyone is capable of helping me with my problem, answer. Thanks
(btw im using pyqt5)
sc: https://pastebin.com/GX65K0ah
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@remote ruin have you tried to instantiate the EdupageClientIndex class inside the EdupageClient and then put .show() on that class instance?
Here's an example
def __init__(self):
super(MainWindow, self).__init__()
self.secondWindow = SecondWindow()
self.secondWindow.show()
class SecondWindow(QWidget):
def __init__(self):
super(SecondWindow, self).__init__()
I haven't. I'll try it and let you know
Good day, all! I've got a peculiarity with PyQt 6 I'm working through.
def current_weight_edit(self):
current_weight = QLineEdit(self)
current_weight.setPlaceholderText('Current Weight')
validator = QDoubleValidator(50, 99, 2, current_weight)
current_weight.setValidator(validator)
current_weight.editingFinished.connect(partial(self.user_setup, current_weight=current_weight))
return current_weight
def user_setup(self, username=None, name=None, starting_weight=None, current_weight=None, height=None):
if username != None:
self.user.username = username
print(f'Username is {username}')
if name != None:
self.user.name = name
if starting_weight != None:
self.user.starting_weight = int(starting_weight.text())
print(f'Starting weight is {starting_weight.text()}')
if current_weight != None:
self.user.current_weight = int(current_weight.text())
print(f'Current weight is {current_weight}')
if height != None:
self.user.height = int(height.text())
print(f'Height is {height}')
In the current_weight_edit function, I have the signal to connect to the function below and originally I wanted to just send current_weight=current_weight.text()
but always sends a blank string
The only way I can get it to work is to pass the entire object and then do the text() inside user_setup
does anyone have any example of how to delete some widget after a set amount of time in PyQt5? if so, please link the site/vid to me
thanks :)
Hey, so I'm quite new in Python Tkinter, and I'm currently making a 5-Question Geography Quiz. However; I can't seem to figure out what's going wrong in a certain bit of my code. So basically, the first question, if the user selects the correct answer, I want the program to output a Label saying "Correct", but then I also want a delay in between the Label showing and the window closing and moving onto the next question. When it's ran, I click submit on the first question after selecting the correct answer, and the button stays pressed down for the 2 seconds I set it for, but doesn't show the Label saying "Correct". Here is the code: https://paste.pythondiscord.com/teravoleme.apache
How bad is it to make a 2d game in tkinter instead of pygame?? I'm a beginner but I already think I can do it with just what I know in tkinter
it do be like that sometimes
anybody interested in chrome specific python applications
things like pycharm
wait not that lol
selenium IDE i mean
brain fart lol
widget.config(state = DISABLED) is better practice. sometimes the widget might not update properties when you use widget["option"] = optionvalue
Its not bad really. Tkinter isnt meant for game dev though, but yes you can try out tkinter for "testing", not for making an actual game.
The code practice you displayed here is quite inefficient. If you make separate functions for each question, it will take you hours to make a 10 minute application. instead you can do something like:
questions=["q1","q2"] answers=["a1","a2"]
now, when you wish to display questions, simply create a label, situated at the top of the window, aligned to the center.
qLabel = Label(window,text=questions[0], font=("DejaVu Sans Mono", "12", "bold")) qLabel.place(x = 400,y=0)
just an example, to show how you create a main label for displaying questions.
now, instead of creating a new window everytime, you simply configure the text of the tk label to change to the next question, everytime you either choose the correct option, or the wrong one.
you can record the index of the questions list, so that you just increment the index, and then update label text:
index=0 # at the starting. ... if answer is correct, index+=1 qLabel.configure(text = questions[index])
@normal frigate
it is a quite hard in tkinter, easier in pygame and way better in arcade
use Qt instead ;), way better for your health
Use pygame
How is it better? I think all what I need is movable editable transperant images and tkinter was smooth when I tested it
I just load like 50 images at first xd
Tkinter is used for apps more. Tkinter can be used as a mini game thing but pygame is better for bigger games
I think itโs easier to learn and thereโs more tuts on yt for it
Ahhhh you dont know how that work
Its disabled the active mode after the mouse not over the widget try that and see
I dont know why tkinter library devs do that but may be important sometimes
So make your own bg and fg instead
Tkinter is actually not for high games its for gui apps. Use pygame instead
you can load up to 50 images but not in the same time
I wouldnt deny what @modern marsh said. Definitely tkinter, or any other GUI lib for instance is not a viable choice for creating games. Not the graphics of the game atleast. Still, as i have already mentioned, using tkinter for testing out your stuff, isnt a bad idea!
How can I create an interface that works by buttons? three buttons to be exact. 1 that goes up, another that goes down and one that accepts.
oh wow thank you! I will be sure to try that out ๐
you can use PyQt5
And how do I do the buttons?
why dont you learn PyQt5
Learn Python GUI programming with hands on tutorials and examples. Build your own apps with PyQt5.
It seems like a good method to make the interface, now we only need to know how to program the interface so that it functions by means of three buttons, one that goes down, one that goes up and another that accepts.
did you not check out the website?
yes
@dry moat doesnt matter which library you use. PyQt5 is great, and so is tkinter. but tkinter stands out from the rest because its easier and far more flexible.
As someone who has never worked with Python User Interfaces before(have plenty of experience in other Languages), what is the difference between pyqt and pyside?(aside from the License)
as far as i know, pyqt doesnt allow you to publish an application commercially, but pyside does. and pyside was developed by Nokia, around 2008 or 10, when Nokia was the owner of the QT project(correct me if im wrong). Not much of a difference between the two, but i still recommend you use PyQt.
Reading through their licensing this seems to be false. As long as your commercial use is GPL compatible there seem to be no issue regarding the commercial use.
Unfortunately this does not answer my question why one should choose either pyside or pyqt.
You need to pay to get a commercial license.
Under pyqt
GPL does not forbid commercial use, just proprietary.
PyQT's FAQ says:
Do I need a commercial PyQt license?
It depends entirely on what license you are going to use to distribute your application. If your license is incompatible with the GPL then you need a commercial PyQt license. If your license is also incompatible with the LGPL then you also need a commercial Qt license. (Note that some parts of Qt, QtCharts and Qt Data Visualization for example, are licensed under the GPL rather than the LGPL.)```
If I understood this correctly and I have no reason to believe I didnt then this means that you do not need a commercial license to use pyqt commercially if your commercial use is GPL compliant
Still this all has nothing to do with my Question of what the practical difference between the two is.
you just cant make money with the normal one
the licences are carry forward
Nothing in their License says that. GPL can absolutely be used commercially( https://www.gnu.org/licenses/gpl-faq.html#GPLCommercially )
Example of this would be A paying B to program FizzBuzz. B develops FizzBuzz but uses a GPL Library to do so. To account for that B will release FizzBuzz under the GPL License which means that when distributing it to A, A will receive the source code and is free to redistribute FizzBuzz, but neither A nor B has to distribute FizzBuzz to the world(but are allowed to if they wish to do so).
But all of this has nothing to do with my question:
What is the difference between PyQt and PySide in practical application? Are there any functional differences?
Yes there are
@stuck vine I found this article pretty helpful: https://www.learnpyqt.com/blog/pyqt6-vs-pyside6/
I just swapped from PyQt5 to pyside6 and the conversion of my project was not very painful. As to practical differance pyside allows for example snake_case as shown in the article.
Each has some gaps in their implementations of Qt functions
Official docs have the list
also some different namings in some cases.
PyQT its pyqtSignal, pyqtSlot and pyqtProperty, while pyside its Signal, Slot and Property
I have a Qt question.
How to manage drag and drop when you have multiple QLists, QTrees and QTable widgets?
I need my top table to drag to the bottom Channel Lists.
So dragging "Crow calls" to the bottom left Bird Calls channels QList.
I also need to drag from the scenes Qlist to the groups QTree.
And disallow any other drag and drop behavior, meaning no dragging from the top audio_file_table to the groups_tree.
I assume I could do this by re implementing the dropEvent() and check origin but wondered if there is a simpler way?
in other words I need to disallow drops from certain sources.
Have you tried setting the ItemFlags?
Does that only work globally?
Yeah, probably. I can't think of anything else besides overwriting the event then
Think I might have to get into dropEvent regardless, since want some very specific behavior. Just gonna read up on the docs. .
Learn Python GUI programming with hands on tutorials and examples. Build your own apps with PyQt5.
@fallen forge I also found this tutorial video series very helpful in learning pyqt https://www.youtube.com/channel/UCj7i-mmOjLV17YTPIrCPkog
Learn coding with author and programmer Alan D Moore.
Alan is the author of:
- Python GUI programming with Tkinter: https://www.packtpub.com/application-development/python-gui-programming-tkinter
- Mastering GUI programming with Python: https://www.packtpub.com/application-development/mastering-gui-programming-python
He does both Tkinter and PyQt, but I have only watched his pyqt5 videos and they have been a great resource for me at least
Can someone help me with a gui
c# or python idm
Like this
but obv without the ddos panel part
I'm on iMac
wtf....
no I will not send you a DM
Hello. I'm trying to open multiple windows, but somehow its not working. Show in class EdupageClientIndex is terminating it (at least i think, because when i remove it, app wont exit with code 0). If anyone here knows the solution for my problem, hit me up. Thanks
I'm using pyqt5
sc: https://pastebin.com/hFwp5NSz
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
whats the best thing to use to make a modern design for a gui for py
what is the best way to create a UI for a python program
Qt Designer definetely
oops replied to wrong person
lol
Xd
What do you think about pygame?
I mean, for doing simple UI
That can interactuate with gpio ports from a Raspberry Pi and some Shell commands
I just want a UI with some text and rectangles, nothing very complex
TkInter is very easy to use for a simple GUI and is a built-in module
Tkinter is not easy at all!
It's very frustrating to use, and it looks like the 1990s
and the stylesheets are not as advanced as Qt to make it look modern
oh ok
take a look at the qt_material themes
@proper oar what's this for?
pyqt5 pyside2 and pyside6
what's it for though
I was talking about how Tkinter has bad stylesheets compared to PyQt
ohh my bad i must have read that wrong
I didn't say PyQt had bad stylesheets, I said it had good stylesheets!
thanks anyway
no worries
How do I add the properties to a button, like it changing colour while hovering on it , etc without using QSS or QtQuick?
That is, just the PyQt5 module
In my opinion, "PyQT5" and their series aren't a good UI making software.
Oh, why so
Because there are better options.
Like?
I have my own UI interface module, which I think is the best UI making software to make desktop applications.
The module?
Ye
Only for Equant Engineers.
Oh alright
I can show you some examples.
Any alternative to Qt that is also Available for the public
?
I have seen your UI's
Yes
Not really, I recommend to not use a designer, like "PyQT5" and start from code.
Because from there, you can start learning advanced graphics, and learn how to use advanced shading.
Code??
I made my module in C++, since it's much more fluent in algorithms.
Qt is in C++ too
I don't recommend it.
My module for C++ will be public, how ever, Equant will be making our own coding language to make desktop applications, which the module will be released there.
Nice
Anyone know if matplotlib and PyQt6 play well together?
My tkinter gui window isn't responding once I press a button
is there a blocking process going on in the background?
I'm accessing website and downloading media using requests
yeah , try using threading to solve the problem
im trying to make a ui with pyqt and want to know why the dialog is immediately called instead of there being a login button to call it
class MyWindow(QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
self.setWindowTitle("Chat Application")
self.setGeometry(0, 0, 400, 400)
self.name = ""
self.LOGIN = False
self.initUI()
def initUI(self):
while True:
self.label = QtWidgets.QLabel(self)
self.label.setText("A Label")
self.label.move(100, 100)
if not self.LOGIN:
self.dialogbtn = QtWidgets.QPushButton(self)
self.dialogbtn.setText("Login")
self.dialogbtn.clicked.connect(self.showDialog())
def showDialog(self):
text, ok = QtWidgets.QInputDialog.getText(self, "Username", "Please enter a username here")
if ok:
self.LOGIN = True
self.name = text
you are calling it in connect(self.showDialog())
what you should do is - connect(self.showDialog)
Pygame is a game library.
Tkinter is easier than any other lib, especially QT.
Not that im being biased or anything, its just the best for beginners, or atleast for people who wish to make simpler UI.
It might look old-fashioned, but theres a lot of stuff you can do to make modern styled spreadsheets.
Its just that no one wishes to look into it, its their ego that stops them ๐
@modern marsh you should stick with Qt
I disagree, it is very frustrating to use, and looks like the 1990s, because the stylesheets aren't as good as Qt's own QSS
also, Qt has Qt Designer and Qt Creator for easy drag and drop UIs
eh?
yeah Qt is better than tkinter ofc
py devs in their talks themselves say about limitations that tkinter has
the only good thing that i can find about tkinter is that it comes with py therefore, no extra dependencies
and about tkinter being easier than Qt, yes, for simpler GUI's
but hell na, for complex stuff
Do I have to use sleep in command or start I'm new to threading
Yes
there is a tkinter_object.after() for that
Hey @digital rose!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
the code is here
What is better and why (to for example, change the text of a Label in tkinter)
import tkinter as tk
root = tk.Tk()
label = tk.Label(master=root, text="Hello World!")
label.pack()
root.after(0, lambda: [label.configure(text='Hi')])
root.mainloop()
Or
import threading as t
import tkinter as tk
root = tk.Tk()
label = tk.Label(master=root, text="Hello World!")
label.pack()
update_thread = t.Thread(func=lambda: [label.configure(text='Hi')], daemon=True)
update_thread.start()
root.mainloop()
@lost dragon Definitely the after method; accessing widgets from other threads has a chance of causing very unexpected behavior and errors. If you are working on thread communication, I recommend a queue a self-rescheduling after method checks repeatedly and a thread writing into the queue. This way the thread will never access tk widgets.
Oh ok thanks!
If you are working on thread communication, I recommend a queue a self-rescheduling after method checks repeatedly and a thread writing into the queue. This way the thread will never access tk widgets.
Could you simplify/say it in a diff way? Not sure what you mean
is there any way i run threads again and again
Maybe this helps you understand (although the code could certainly be better), the thread only knows of the queue and the queue is checked by the after callback:https://gist.github.com/Square789/46b0fdf0905c229567798ff9f3ebc275
oh ok thanks!
Threads can only be run once, so you'd need to create a new one with the same parameters and start that one again
# IGTV
igtv_window = Toplevel(root)
igtv_window.title("DOWNLOAD IGTV VIDEO")
igtv_window.geometry("1100x600+50+10")
bg = PhotoImage(file="IG.png")
f = ("CALIBRI", 20, "bold")
label4 = Label(igtv_window, image=bg)
label4.place(x=0, y=0)
canvas4 = Canvas(igtv_window, width=400, height=400)
canvas4.pack(fill="both", expand=True)
canvas4.create_image(0, 0, image=bg, anchor="nw")
#canvas4.create_text(400,250,text="Enter URL:",font=("Helvetica", 20), fill="white")
igtv_url_lbl = Label(igtv_window, text="Enter URL :",
width=20, font=f, bg='#8a3ab9')
igtv_url_ent = Entry(igtv_window, width=20, font=f)
igtv_url_lbl_canvas = canvas4.create_window(
350, 100, anchor="nw", window=igtv_url_lbl)
igtv_url_ent_canvas = canvas4.create_window(
350, 200, anchor="nw", window=igtv_url_ent)
button_igtv = Button(igtv_window, font=f, width=20,
text="DOWNLOAD IGTV VIDEO", command=threading.Thread(target=downloadigtv).start)
button_igtv.pack(pady=20)
# button_igtv.after(3000,button_igtv.destroy)
button_igtv_back = Button(igtv_window, font=f, width=20,
text="BACK", command=lambda: back(3))
button_igtv_back.pack(pady=20)
This way the button will be targeted at the start method of a thread that is created together with the button; Wrap it in a lambda (you'll need to call start then), which will cause a thread to be created each time the lambda is run / the button is clicked
okay thanks
How can such a simple library be a source of frustration?
it will be frustrating, unless you dont understand it of course.
it takes so long to position something exactly where you want it
ยฏ_(ใ)_/ยฏ
the only good thing about tkinter is you dont have to download it
Why do you think it doesnt look good? and do you not know how to make it look good?
it looks like the 90s, and the stylesheets aren't good enough to make it look modern
Plus, i dont see a** BIG** difference in how QT's core UI looks and that of tk
style sheets is a whole new topic. Core UI is what I talk of.
I still dont understand how it is "easier". What is your definition of "easier" and "advanced"?
Qt has more features
than tkinter
PyQt is easier because first, it has a drag and drop Designer
That is not related to programming in any sense.
second, PyQt doesnt need to be packed, or putt in a grid, you just make the widget
and it shows up
.
Any recommendations on a graphing library to pair with PyQt? I wanted to use Matplotlib, but they haven't updated for Qt6
Use Qt5 then
Qt5 and Qt6 are pretty much the same
'''```py
button_igtv = Button(igtv_window, font=f, width=20,
text="DOWNLOAD IGTV VIDEO", command=lambda: threading.Thread(target=download(3)).start)
but the windows are freezing
Try putting the command for the button in a separate function, rather than Lambda.
what Viseur said may help too once the lambda gets too long, but the problem probably is that download(3) kicks off a long running function and that the thread isn't even started. to pass arguments to a function in a thread, use args=(3,)
Thanks, Famous8, but I'd rather just stick with 6. I'm open to any library that works with Qt6.
If there aren't any, I'll downgrade, though.
Hey guys, i'd like to make a small UI in terminal with a margin on top and a margin on bottom where some variables values will be show and refreshed every X milliseconds
In the middle of that i'd like to see the standard prints of my program
Do you have any idea on how to achieve that ? I've seen curses library but i'm not sure it's what i'm looking for
Ok so i've almost found wjat i was looking for with https://github.com/willmcgugan/rich
The following code is working well except for the middle part
from rich.layout import Layout
from rich.live import Live
from rich.text import Text
import time
text = Text("Hello, World!")
text.stylize("bold magenta", 0, 6)
layout = Layout()
layout.split_column(
Layout(name="upper"),
Layout(text, name="middle"),
Layout(name="lower")
)
i = 0
with Live(layout, refresh_per_second=10):
while True:
layout["upper"].update(str(i))
text.append("\n"+str(i))
i += 1
time.sleep(0.001)
layout["lower"].update(str(i))
I can't find a way to clear the middle part text so the newer lines can't be displayed
here's the output
in the middle part (from Hello World to 5) we should see something like
1768
1769
1770
1771
1772
1773```
Try out UrWid.
some basic widgets
yeah worked well thanks
finally its solved thanks i learned new concept of threading
nice. even though obfuscated code, something like this:
# getting an array of only odd numbers from 1 to 10 odds = [i for i in range(1, 10) if i%2!=0]
might seem like a good practice but it isnt.
code, that uses obscure language features is something neither meant to be put into production, nor is readable or maintainable.
ah nice I hate arrays
I have made an desktop app in Adobe XD and Iโve made a script in python but now I want to connect those two. Whatโs is the best/easiest way to do this?
You want to run another python file in a python file?
Iโve created a UI in Adobe XD and I have created a webscraping tool in Python but now I want to connect those so if I write a SKU of something in de desktop app it will appear at a soecific place in my script!
why have you created the UI in adobe xd? does it serve a specific purpose?
you might want to get your hands on some utility library that helps you deal with .xd files.
@remote violet
Iโve created it in Adobe XD because Iโm good at it ๐
i dont really get it.
do you wish to get some data from the UI itself?
Like if I have a form in my UI that if I fill that it fills a specific place in my script
Like if you enter information for a mailing list
(Sorry but Iโm not good at explaining things)
"fills a specific place in my script" why are you trying to show data in the python script? that data should be written to something like a txt file.
So that if a user puts his information in a form (like name and email etc) it will fill it in my python script so my script can run with the information of the user
Ahh
I get you
So basically what you need to do is simply grab the data of the form, and write it to a text file, and name it something like userinfo.txt. now, everytime the user opens the form, you can access the text file, and fill in the details from it.
Kind of but it needs to happen automatically
"automatically"?
you can throw in some popup asking the user to save info, like a couple of browsers do.
then only trigger the function that saves information into the text file.
check out xdtools to work with .xd files.
.
why dont you try doing something to get data in XD itself?
I believe there is a way to add a command to buttons?
Maybe just learn a UI lib in Python instead! ๐
Hey, i want to assign multiple functions to a button but the second function doesnt execute when i click the button. It works when i only connect the second function to the button. That's the code snipped:
ui.button_start.clicked.connect(lambda: bot.accept_request(loop=True))
ui.button_start.clicked.connect(lambda: ui.button_start.setText("Stop"))
i already searched on the internet and they say that it should work, but it doesn't :(
I'm happy about every answer! :)
Hi falk,
Try this way:
ui.button_start.clicked.connect(lambda: (bot.accept_request(loop=True), ui.button_start.setText("Stop")))
EDIT: Second function will be executed after first function is executed
@spiral karma stop spamming
thanks, but it executes the function
even when i dont click the button
ah i forgot the brackets
but it still doesnt modify the button
๐ฆ
I just realised, I didnt commented my previous instruction. I added a print as second function:
self.aboutButton.clicked.connect(self.showDialogApp) self.aboutButton.clicked.connect(lambda: (self.showDialogApp, print("Button pressed!")))
Commenting the first line does not really perform both functions ๐ฆ
oh lol i figured it out
it actually changes the button text but it only updates when the second function is finished
is there a way to refresh a button manually?
like
ui.button_start.setText("Stop")
win.refresh()
function_that_takes_long()
So I am looking into writing a generalistic form for pyqt that takes in a SQLAlchemy object renders it in an editable way and then returns the(possibly) changed object when pressing save.
Before I spend a sizable amount of time for that I would be interested whether or not that is already implemented by someone in a convenient to use way
now I don't know much SQL, but PyQt5 has a QtSQL module based on SQLite. You could probably use a QTableWidget to show the data and a save button.
Unfortunately there is no way to not use SQLALchemy and use build ins. Its a desktop frontend for an already existing system. What I am seeking to emulate is djangos ModelForm(https://docs.djangoproject.com/en/3.1/topics/forms/modelforms/) because I am dealing with approx 20 different models and I have 0 Interest in writing forms for each.
How can I make 3 text boxes with each labeled and then whatever you have inputted for the boxes go in their respected variables. Then you press a start button to enter the vars and go with the rest of the code.? Tkinter btw.
hey, I have a GUI that has a button and when i click the button it changes the text to stop and runs a Selenium session, but i want to kill that session when i click the button again, I dont know how i can do that. that's my current code:
# Display gui
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setup_ui(win)
start_btn = ui.button_start
start_btn.clicked.connect(
lambda: (accept_request_thread(), start_btn.setText("STOP" if not start_btn.text() == "STOP" else
"START"))
)
def accept_request_thread():
if start_btn.text() == "START":
bot = Bot()
t = threading.Thread(target=lambda: bot.accept_request(loop=True)).start()
else:
print("Closing driver because text is", start_btn.text())
bot.driver.quit()
win.show()
sys.exit(app.exec_())
Can someone give any opinions regarding PySide vs PyQt? I know Qt itself well and have done a lot with PyQt back in the day. I haven't used Qt nor PyQt that much for a few years and it seems that Qt itself pushes PySide. Does it do something better than PyQt?
when i disable a button in tkinter how can i make it not grey out
As far as i know there's very little difference between pyqt and pyside, both have the same features but pyside have different license and you can use it for commercial use, pyqt is the other way around.
not much of a difference really.
just add a command to the button that just says "pass"
def button_Command():pass
mybutton = Button(.. .. .. .. , command = button_Command) mybutton.pack()
this will make the button not do anything, but is not greyed out at the same time.
Any way to integrate a command line interface in a Python GUI app?
how do you want to integrate them?
Like, I should be able to make a Frame or something in Tkinter, which would act as a placeholder for the cli window, which I can use as a simple command line window
Background color kwarg, if I am right
lemme try
@latent compass works?
dont think so
What did u do?
just add **kw
just vs showed it ๐๏ธ

no i want to make it transparent
yes you can do it. @latent compass
see this:
`# tkinter example, changes window bitmap to a transparent style:
21 July, 2017
from tkinter import *
__window= Tk()
__window.config(bg="white")
__window.wm_attributes("-transparentcolor","white")
__window.mainloop()
`
so now whenever you set the window color to white, it makes the window transparent.
PS: Works only on Windows.
for macOS:
__window.wm_attributes("-transparent",True)
now, to make the widget transparent:
# for windows: __window.wm_atributes("-transparentcolor","white") button=Button(__window,text="click me",bg="white") button.pack()
`
for macOS:
__window.wm_attributes("-transparent",True)
widget.config(bg="systemTransparent")
`
Oh
@digital rose is there a documentation about the list of wm_attributes() kwargs?
Sorry for the ping ^^^
yes there is. https://www.tcl.tk/man/tcl8.4/TkCmd/wm.htm
Oh, ok thanks!
no worries. im always up for help so.
then visit the tk docs
Oh
TkDocs features tutorials and other material for modern Tk GUI development, using Python/Tkinter, Tcl, Ruby, and Perl/Tkx.
Tcl is a scripting language. Tk is a GUI creator for Tcl.
the
yes you can do that.
you can embed windows in tkinter Frame().
you can embed a pygame window in a tkinter frame.
or any other python window atleast.
*** a window**
see how to embed a pygame window in tkinter:
https://stackoverflow.com/questions/23319059/embedding-a-pygame-window-into-a-tkinter-or-wxpython-frame
Oh ok
need help on tkinter in #help-croissant please,
@rugged marsh you can post your query here.
Oh my problem was solved already. Thanks though :)
no problem.
tkinter seems to not want to work with a while true loop
even though i initiate the instance before starting the while true loop
it just doesnt want to open a window up
from tkinter import *
def getchat(file):
file.seek(0,1)
while True:
line = file.readline(0)
if not line:
continue
elif "[Client thread/INFO]: [CHAT] ONLINE:" in line:
getstats(line[49:])
elif "[Client thread/INFO]: [CHAT] Your new API key is" in line:
recieve_api_key(line[61:])
def main():
print('maining') #debug line
getchat(open(os.getenv("APPDATA")+"/.minecraft/logs/blclient/minecraft/latest.log", "r"))
root = Tk()
main()```
when i ran the code before i added in the call to `main()` the gui would launch
after it just doesnt launch
i dont get any errors
it just doesnt launch the gui
well i was planning to do something with the stuff in the text file
and then display it with tkinter
its just that i literally cannot get the little tkinter box to open up no matter how hard i try
with the call to main()
like this:
lines=open("test.txt").read().splitlines()
this gives you a list of lines in the text file.
which box are you talking of? @ripe igloo
this little thing
this is the window.
it must mean that the code before instancing the window doesnt work.
except i dont call any code before instancing it
^^
before you create the root window, you call in some code.
namely the getchat() function.
is that the full code?
ill mystbin the full code
even running it like this doesnt work
it goes right to main
put in root=Tk() before the main() and add root.mainloop() at the very end.
?
didnt work
ah
ok i see the problem
mainloop has some sort of while true loop or smt
because i put mainloop before main and main doesnt run but tkinter does
i put main before mainloop and tkinter doesnt run
so id have to async this somehow huh?
its one or the other
is your code working now?
its either main or tkinter so no
ill try to hack this together somehow
thanks for the help!
it creates it if i put mainloop before main
but then main doesnt run
it's fine, I'll find a way to put it together
^
it needs to be at the end.
doesn't work that way
you cant call something after it.
if I put it after main it doesn't work
it's fine, I'm gonna take a break and come back to it in the morning
thanks!
i wanna ask do i need to install qt from qt.io? I think i can access the designer just by typing "pyside6-designer"
oh wait do i need qt creator
nvm i dont think i do
thanks for the help guys
now how do i package it to a .exe?
all scripts with dependencies
well, there is pyinstaller but i dont think that is recommended