#user-interfaces
1 messages ยท Page 74 of 1
๐
very true
Worth a try IG
i have tried vim. i respect it, but not a fan
Took me almost 3 months to get used to the million keybinds
Its quite decent when you spend the time to fully learn it.
Mm hmm. But you can always use a second editor alongside, when you need to do important work, and switch to Vim when you're free.
In any case, it's better to go with what you are best with.
maybe. between work and home life, i barely get time to do what i want.
i have a cnc router 60% built that has been sitting on my desk for months just waiting to be put together
gotta find time
I guess this is getting off topic now ๐
I barely have time to manage both discord and stackoverflow too, and school works. It is just all a mess
Lol yea
trying. with a 10yo and a 1yo, time is a luxury i do not have.
But yea, we are off topic
so the best suggestions are pyqt or tkinter?
the world
i was having issues when trying out remi, but found that was an IDE issue
Now i am just asking in general. basic desktop GUI apps.
whats your fav Mark?
I don't think it's fair to ask me that because I
have only properly tried Pyside (pretty much same as pyqt)
i would prefer pyside myself, but it always breaks when i install it
i dunno why. i just gave up
But I do like it. I think its biggest downsides are a steep learning curve and being fairly bulky since it's a very batteries-included type of library. That can have its benefits, but it isn't beneficial to simpler apps.
agreed. and it is almost like pyqt without the screwy licensing crap
Another downside is poor Python documentation, but that's steadily improving. Since the API very very closely follows the original C++ library, I just look at the C++ docs.
Some docs for Python still use C++ code examples, etc.
And there's a bigger community around the original C++ library, so you'd find more online resources for that.
i have dabled in pyqt, pyside, appjar, tkinter, pysimplegui, flask (poorly), pyforms, kivy, remi and a few others but am always on the hunt.
Its not that i dont like any of them or like one more than the other. I just like testing out different stuff to see if it offers something i didnt have before
Yeah, that's the best approach. Some libs do things quite differently (Kivy comes to mind), which is really divisive.
kivy is interesting. i will give it that
I think Qt has something sort of similar with QtQuick. In fact, some users complain that the direction of development is far too focused on QtQuick these days.
if a portable python could be made to make pyinstaller files smaller and faster, life would be good
off topic a bit but my desktop apps need to be "compiled" so i try to get some lightweight UI frameworks
As much as I do like Python, I think I would look to other languages for desktop GUI app development
the apps i have written for work
I'm kind of excited where .NET 6 is heading with MAUI https://github.com/dotnet/maui
Nice icons .
thanks
Yeah.
I'd be fine with Python for some simpler apps though.
Depends on the scope and scale of the project.
i have been dabbling in C#. lots of new libs to learn
Packaging and distributing Python nicely is indeed an issue for Desktop apps.
How
theme?
yeah
and my IT dept at work will not let me have everyone install python on their computers
that looks so cool
if i could, life would be simple
What is their excuse
Synthwave x Flouromachie
Thank you!!
security
hmmhmmhm
im sure there was a vulnerability at one point at some time in the past on one of the versions, so they must all be bad
i will say, my IT dept is not the smartest. i got one guy who fights for me and is knowledgeable, but he aint the manager
It's probably just a lack of motivation to invest time to look into giving it security clearance. Also, any additional 3rd party app increases the attack surface of the machines.
i even considered java because of the swing lib, but i found out the IT dept removed java from all of the computers
SIKE
agreed. personally, i think it is laziness
Hello, so my UI looks like this:
How can i center on the top of the screen the random letter (scramble) and the timer on the actual center of the screen?
How do you place the widgets
Scramble
self.scramble = Label(self.app, text=self.scramble_output, bg = '#232931', fg = 'white', font =('Overpass Mono Light', 12), anchor = NW)
Timer (display)
self.display = Label(self.app, text='0.00', bg = '#232931', fg = 'white', font = ('DS-DIGITAL', 64), pady=100)
I meant, grid or pack or place
Oh, grid
show that code please
self.display.grid(row=1, column=0)
self.start_button.grid(row = 2, column=0)
self.scramble.grid(row=0, column = 0)
Is there column 2? anywhere
No
Ok then try adding sticky='ew'
In all of them?
Yeah
Can you give the code
And this is what im trying to make
Ok
then its better you use grid() itself
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.
Ok
Well tkinter apps are not responsive by default
So i have to code how the UI looks when maximized?
That would make sense too.
Maybe @digital rose knows any better way
Basically you could use something like root.grid_columnconfigure(0,weight=1) @versed vessel
What does weight does?
Basically makes it like responsive, but that is not what you exactly want here
Ok, Imma focus first that the UI works on 800x500
Then I'll make it responsive
Or should i make it responsive instantly?
Responsive is not the best idea with tkinter. I usually just make my windows non resizable
I think the app looks cute, in small dimension ๐
the window?
Yeah but i googled it already
cool
root.resizable(False, False)
or 0, 0 but yeah
Ok
I found a way to initialize my window as maximized
Sure, share it with us
root.state('zoomed')
That would set full screen only right?
Looks good, but it hides the taskbar
It looks as fullscreen, but the minimze and exit buttons show on the top
But it hides the taskbar
It opens it as fullscreen
What about these
No taskbar
Don't see why you would need the taskbar
Guess I'll leave it like that
Hmmmm whatever suits you
I'll leave it like that
When i get to post the timer, I'll ask for feedback if i rather choose 800x500, fullscreen or leave it as it is
Sure ๐
hello i am trying to put a messagebox.showwarning if there is no value entered
but it does not work
can someone help?
Show the code @hoary venture
print(
from tkinter import*
def calculate_due():
intxt = float(Amount_Entry.get())
txt=float(Tax_Entry.get())
if intxt !="":
Totaldue= round(intxt*(txt/100),2)
Due_Entry = Label(window,text=Totaldue, fg = "black", bg = "white", font = "Calibri")
Due_Entry.place(x=150, y=120)
else:
messagebox.showwarning(" Stop!","Please enter a value")
return
window=Tk()
window.title("Windows TaxApp")
window.configure(bg="black")
window.geometry("300x200")
Total=StringVar()
Percent=StringVar()
lbl1=Label(window,text="TAX CALCULATOR",fg="white",bg="black",font="bold")
lbl1.place(x=80,y=5)
lbl2= Label(window, text="Total Amount: $",fg="white",bg="black",font="Calibri")
lbl2.place(x=25,y=40)
Amount_Entry= Entry(window,textvariable=Total)
Amount_Entry.place(x=160,y=40,width=50)
lbl3= Label(window,text="Tax Percentage: ",fg="white",bg="black",font="Calibri")
lbl3.place(x=25,y=80)
Tax_Entry= Entry(window,textvariable="Percent")
Tax_Entry.place(x=150,y=80,width=50)
lbl4= Label(window,text="Total Due: ",fg="white",bg="black",font="Calibri")
lbl4.place(x=25,y=120)
# Due_Entry= Label (window)
# Due_Entry.place(x=150,y=120,width=70)
btn1= Button(window,text="COMPUTE",bg="white",fg="black",command= calculate_due)
btn1.place(x=100,y=160)
window.mainloop()
You should understand that if the boxes are empty float() will give an error @hoary venture
So you should put that inside the if.
ok
did u get it?
it says intxt is not defined
Use if Amount_Entry.get()!="": then
At the end it should look like: @hoary venture
def calculate_due():
if Amount_Entry.get() !="":
intxt = float(Amount_Entry.get())
txt=float(Tax_Entry.get())
Totaldue= round(intxt*(txt/100),2)
Due_Entry = Label(window,text=Totaldue, fg = "black", bg = "white", font = "Calibri")
Due_Entry.place(x=150, y=120)
else:
messagebox.showwarning(" Stop!","Please enter a value")
Is it better to name your labels lbl1, lbl2 or not? I name it as what they are/do
For example on my timer, the time, is called display, the algorithm to scrable the cube is called scramble, the Running... text is called state
Name it the purpose they serve
Ok ok
Hello, any idea how to make a timeline using PyQt, like the one in the picture, thanks.
I'd think the best way to do something like that would be to use QGraphicsView/Items to build the tick line, track area, and the slider.
The controls in the bar at the top could be part of the widget holding the view or create a toolbar in the scene
hey, im planning on building a cryptocurrency (full nodes written in Python) but have mobile and desktop apps for making transactions
if there a way i can have the app without going via apple app store?
i dont wanna have to do go via apple dev stuff (getting it accepted onto the app store)
and also dont wannna pay alot of money to be an apple developer
because its just a project for me and a smallish group of friends/classmates to use at school. im not gonna make any money out of it, so it'll just be a huge money pit
of what?
Did u pinged me?
hi, i'm trying to compile a script from python to exe using pyinstaller, i've already compiled some stuff whit it but now i want to compile a gui software, i'm using pygubu for ui objects but when i compile the code and execute i get py ModuleNotFoundError: No module named 'pygubu.builder.tkstdwidgets'executing the code from idle works whit no problems, what i'm missing?
ping me to call my attention.
Are you trying to fit widgets completely on the screen on window resize?
I read a bit about your problem yesterday.
indeed it is
Some question that was mentioned above
Yeah, but i decided to initialize window as fullscreen and make it non resizable
@stable folio extend labeland use a painter to paint in a scrolling pattern
how to get a permission to speak in voice chat?
ping me on reply
???????????????????????????????????
There was no stream matching the given resolution for the call to get_by_resolution so it returns None, you cant call download on None.
https://pytube.io/en/latest/api.html#pytube.query.StreamQuery.get_by_resolution
Not, like that at least. That's how you get banned :P
but in youtube there is
sry im a beginner in tkinter so :P
Test
what
It is not tkinter that is raising an error its pytube
okay but i dont understand i tried in another quality and i got it
okay
yea im generally saying
what do u say here
ok now its only downloading in 360p
no other quality is moving on
You might want to do something like
stream = youtube.streams.get_by_resolution(k)
if stream:
stream.dowload(path)
else:
# give feed back that no stream was found```
yeah but that would only give me the reply that no such quality is found like if i print it, but actually i cant get any other quality other than 360p and (720p, in some videos) even though its on yt in real
Any idea of how to make a side panel on tkinter?
self.sidepanel = Frame(self.app, bg = 'red', width = 200, height = 800) I created a frame and put it on the first column of the app
self.sidepanel.grid(row=1, column=0, sticky=NW)
I don'y know I've never used pytube , i can only go by what the documents say
But i don't know why it moves my other widgets out of the screen
aah
if you manually increase/decrease a pyqt window is there a way to get the geometry of that window to dynamically adjust button locations?
class mainWindow(QtWidgets.QTabWidget):
def __init__(self,Abs, parent=None):
#doing stuff
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
main = mainWindow(Abs)
main.resize(1400,900)
main.show()
sys.exit(app.exec_())
I cant locate where the geometry is stored within "mainWindow"
Should i center stuff panning them?
@hybrid spindle u need to actually use layouts they suto scale
oof. That'll be for another day then
yeah, I learned about designer nearing the "completion" of what I was making
uhh QTabWidget is not a window
use QDialog or QMainWindow or QWidget
Ok so i got this code right now, which basically tells the timer is running.
def start(self):
# Unshow last time or starting time
self.display.grid_remove()
# Start counting time
self.start_time = timer.start()
# Create widgets to show the timer is running and finish butto
self.state = Label(self.app, text='Running...', bg='#232931',
fg='white', font=('Overpass Mono Light', 32))
self.state.grid(row=1, column=1, sticky = EW, padx=560, pady=300)
self.finish_button = Button(
self.app, text='FINISH', fg='white', bg='#4ecca3', command=self.finish)
self.finish_button.grid(row=2, column=1, columnspan=2, padx=275, sticky=N, ipadx=20)
# Unshow start button and scramble widgets
self.start_button.grid_remove()
self.scramble.grid_remove()
What can i do so i can show the current time and not Running...?
What I thinked about is a while loop but I guess that's not the correct aproach
Basically im trying to find a way to update state to the current time - self.start_time without stopping/messing the whole code
Example of using an after call to update a time display every second
import time
import tkinter as tk
class App(tk.Tk):
def __init__(self):
super().__init__()
self.time_label = tk.Label(self)
self.time_label.pack()
self.timer()
def timer(self):
self.time_label.configure(text=time.strftime("%H:%M:%S"))
self.after(1000, self.timer)
if __name__ == '__main__':
app = App()
app.mainloop()
Not sure where to ask this....Does anyone know any nice augmented reality libraries for Android?
Is it a good idea to inherit from Tk? ๐ค
How can i make so when i hit the spacebar my app detects if i hitted a button?
bind
It is much ordered bc you know when you are refering to a Tkinter thing
self.start_button.bind('<Key>', self.spacebar)
And my spacebar func is:
def spacebar(self, event):
print('Clicked' + event.char)
But nothing happens
buttons wont have focus by default. Only if it has focus, it can read those binds
Ohhh
I would say root.bind('<Key>', self.spacebar).
So my mouse has to be on top of the button?
No, your focus has to be on the button
Ok what i want also another function have the same bind
Press tab and u will see a highligting around widgets, that has to be on the button
So when one function runs, unbind it from the one it just ran and bind it to the next one, that's my guess
Seems like a XY problem
The XY problem is a communication problem encountered in help desk and similar situations in which the person asking for help obscures the real issue, X, because instead of asking directly about issue X, they ask how to solve a secondary issue, Y, which they believe will allow them to resolve issue X.
However, resolving issue Y often does not r...
So what is your main aim here
When i hit spacebar, my timer should start counting the time, when i hit spacebar again, it should stop
Okay, use a flag then
flag?
Hmmm let me try to give you an example
OK
Mmmm seems like it is taking more time than usual. I am not in my senses :p @versed vessel
Lol, no worries
I've done it before, dk whats happend to me now :p
Probably you need some rest, who knows
import time
import tkinter as tk
class App(tk.Tk):
def __init__(self):
super().__init__()
self.time_label = tk.Label(self)
self.time_label.pack()
self._update_timer = True
self.timer()
self.bind('<space>', self.on_space)
def timer(self):
if self._update_timer:
self.time_label.configure(text=time.strftime("%H:%M:%S"))
self.after(1000, self.timer)
def on_space(self, event):
self._update_timer = not self._update_timer
if __name__ == '__main__':
app = App()
app.mainloop()```
I've dont this before but not using after(). Multiple calls to after will repeat the function at a faster rate
Something like this cud work too
So procedural example would be:
from tkinter import *
root = Tk()
time = 0
started = False # This is a flag
def start_timer():
global time, started, rep
if not started:
time += 1
lbl.config(text=time)
root.after(1000,start_timer)
def stop(e):
global started
started = not started
lbl = Label(root,font=('',20))
lbl.pack()
root.bind('<space>',stop)
start_timer()
root.mainloop()
how would that be if um using classes?
It removes the need to use global, and helps organise things together
What? Inheriting from Tk?
The example given by @lime monolith shows in classes
I've tried using it on classes:
class Application():
def __init__(self, app):
self.app = app
self.started = False
#More stuff
def start(self):
self.started = True
if self.started == True:
# Unshow last time or starting time
self.display.grid_remove()
#has_finished = False
# Start counting time
self.start_time = timer.start()
# Create widgets to show the timer is running and finish button
self.state = Label(self.app, text='.', bg='#232931',
fg='white', font=('DS-DIGITAL', 32))
self.state.grid(row=1, column=1, sticky=EW, padx=560, pady=300)
self.finish_button = Button(
self.app, text='FINISH', fg='white', bg='#4ecca3', command=self.finish)
self.finish_button.grid(
row=2, column=1, columnspan=2, padx=275, sticky=N, ipadx=20)
# Unshow start button and scramble widgets
self.start_button.grid_remove()
self.scramble.grid_remove()
self.app.after(1000, start)
# Make so timer updates elapsed time
#timer.update_time(self.start_time, self.state, self.app)
The indentation is wrong, pls fix it
create another method called updater and then assign the oppt of whatever is self.start.
wrong that it would not run or that is not supossed to be indented like that?
I dont usually indent like that autopep8 does
def updater(self,e):
self.start = not self.start
This code is unrunnable, start should be on same level as __init__.
Well both the example here assumes that the timer starts from first. I think you want the timer to start only when pressed spacebar right. @versed vessel
Yes
On start, what should happen (for now) is to put on on screen a scramble and the time at 0.00 and the start button
I am out of ideas, and very sleepy. Perhaps @lime monolith can help now
e stands for event?
Alright, good night
anything, basically event that is passed by tkinter when using bind.
You need to bind to updater and not start
Ok ok
And whenever updater runs just make self.started = False
And on def start(self): should i make a while loop?
This whole concept would work, but after running twice is not going to help.
why
Yea, because it will grid again all widgets and probably crash
No widgets cannot be gridded more than once
Oh then an error
No errors would come, its simple not possible
from tkinter import *
root = Tk()
l = Label(root,text='Hi',font=('',20))
for i in range(100):
l.grid(row=i,column=0)
root.mainloop()
l is not created 100 times
one widget can only be placed once
Ok
If you want, move l inside the loop and see
So back again what i was trying to do, i got my bind set to updater, which makes self.started = False and in start class, it makes self.started = True
In __init__ call self.start().
I know. That is the problem with this method.
So I have to find another way
Ya... Better to ask in stackoverflow
Haven't used it ๐ how should i make my question?
If you want to recieve a proper answer, then show them what you have done so far
otherwise, all its gonna get is downvotes
Ok
Link it here once your done too, maybe Ill try to get some help @versed vessel
Ok ok
Sure, what did you do
On __init__ i putted this
#Bind spacebar to start timer
self.app.bind('<Key>', self.updater_start)
And created 2 functions.
def updater_start(self, e):
if e.keysym=='space':
print('Hitted spacebar')
self.start()
def updater_stop(self, e):
if e.keysym=='space':
print('Hitted spacebar')
self.finish()
The problem is the time starts and stops and for some reason the elapsed time adds to the last time
This is the reason
I deleted them
when timer starts, i save a time.time() variable, when it finishes, it subtract the current time from the time.time variable and that its the elapsed time
def finish(start_time):
# Calculate elapsed time and round it
output = time.time() - start_time
output = round(output, 2)
# Check if its neccessary to format time with hours and minutes
if output > 60:
mins = round(output // 60)
sec = round(output % 60, 2)
hours = round(mins // 60, 2)
# Format as minutes
if mins >= 1 and hours < 0:
# Format time as minutes:seconds and return it
message = f'{mins}:{sec}'
return message
# Format as hours
elif hours >= 1:
# Format time as hours:minutes:seconds and display message
message = f'{hours}:{mins}:{sec}'
return message
else:
# Return just the seconds, there are no minutes or hours to format.
return output
I got this code on another file
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.
Oof im dumb that's not the one
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.
Hmmmm, hopefully someone can help you soon
Yeah, I'll post this problem now.
so I'm trying to make a timer (like cstimer.net) and I got this problem
I have binded the spacebar to start the timer, and then, once you started the timer, hitting it again would stop it. The prob...
Noted, lets see
You got an answer, but its kinda the same I tried here but did no good. Anyway give it a shot again
Okay cool ๐
#My version
def space_press(self, e):
if e.keysym=='space':
if self.space_presses == 0:
self.space_presses += 1
self.start()
else:
self.finish()
self.space_presses = 0
else:
pass
You did not use his concept of even nd odd?
Not really, guess its easier with 0 and 1
Take a look at new answers, they are more experienced ones
Or is it more helpful with even and odd?
Remove the tick mark, take ur time to try out answers, wait a day to get some suggestions and then mark one
In the comments ask acw for an example of what he meant, he usually makes good point.
Ok ok
The new one?
In the question one about resetting
Ok ok
Hello
GrabIt Image Color Picker
place your cursor Anywhere
press ctrl+shift+g and get hexcode copied automatically
#python #imageprocessing #opencv #windows #1hourbuild
GrabIt version 1.0
https://youtu.be/EEq6DdcapE4
Good job ๐
Thank you
hello, i want to make an gui for my application that can be access via web. but i'm never do this before. any good suggestion?
GUI is a desktop application. What do you mean "that can be access via web"? @fresh raptor
via browser. the app main target is to installed on vps.
Idk, try Remi python @fresh raptor
ohh god. thanks, this is what i'm looking for
๐
I've added a reply to your stack overflow question
OMG, you solved another of my problems
To update the time
def update_time(self):
if self.timer_running:
#Format elapsed time
output = timer.finish(self.start_time)
self.state.configure(text=output)
self.app.after(1, self.update_time)
Did some small changes but it does work!
Setting the after value to 1 is a bit overkill, having it as 1 makes it happen every millisecond, in my example i had it as 100 which will be every 0.1 of a second which should be plenty.
isnt there a feature in cube timers to have yellow flag ? @versed vessel
How like yellow flag?
Hmmm, definitely will try that
what the hell is JSON really ?
you press space, then itll not start but show that it is about to start, and when you release space, it starts
Just like cube timers
Ohh
I just added that
I asked my cubing friends if they could try it but when they download it, it triggers a false positive
A virus
@sudden coral hey, can you DM me that C# GUI module you told me about a few days ago when you have a chance?
Maui
thank you sir
gonna try to remake one of my simple python apps in C# and see how the performance difference is
it doesnt look like it is officially released yet
I need code for SignUp page with python TKinter
Sort of User registration page, Could someone able to code the above instructions for a simple registration form using python tKinter?
All the fields like, (name, username, roll number, password etc.,) should be be entered by the the user and needs to be validated. And that details must be stored in python sqlite3 Database!
Could anyone able to do it, and send it?
we're not going to write the code for you.
lol
@warm sinew https://www.fiverr.com/ is a great start
alright 1 sec
Did you got any?
Sry, I'm only asking for the existing code like if you guys have any sort of thing which I've mentioned above!
This is annoying to fix, so either decrease wx.Bitmap() size. I have trouble figuring that out. I can also stop using wx.Frame.CreateToolBar since I can't figure out to resize it and make wx.Toolbar class myself where I specify the size
Resized the images with PIL and now it's fine
Try looking at GitHub; you may be able to find the source code there.
So, I'm trying to use tkinter on pycharm
and it's not available in packages
I've tried installing it with 'sudo apt install python3-tkinter' and it doesn't show up in pycharm
Do you have the interpreter selected in pycharm that tkinter has been installed to?
Is it normal to plan this much before doing the stuff?
Hi everyone! Im trying to make a gui for my simple python program that calculates the least amount of coins to give a user based on the amount. I would greatly appreciate the any help or advice!
Anyone have any thoughts on how to condense this?
if event.inaxes is not None and ((event.inaxes in self.axesL[0]) or (event.inaxes in self.axesL[1])):
I can have up to 5 axes. It'd be one hell of a line to continue repeating the event.inaxes in self.Laxes[X]
wow
Maybe you could be more specific
How to make Gui for a python program. Like lets say you have a print func, how do you make gui that has the print func on it?
Sorry for my very vague question ๐
def printer(text):
return text
if __name__ == '__main__':
from PySide2.QtWidgets import QApplication, QLabel
app = QApplication()
label_text = printer('Some text from a function')
l = QLabel(label_text)
l.show()
app.exit(app.exec_())
Hey, I'm just getting into GUIs and I know that tkinter is the buitin GUI library but also I've heard that tkinter wasn't made to work with the oop structure of python. Is there a good and easy alternative?
A tkinter example
import tkinter as tk
class Printer(tk.Tk):
def __init__(self, *args, **kwargs) -> None:
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)
def on_button(self):
print(f'Entry contains: {self.entry.get()}')
if __name__ == '__main__':
app = Printer()
app.mainloop()```
A WxPython example
import wx
class Printer(wx.Frame):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.entry = wx.TextCtrl(panel)
sizer.Add(self.entry, flag=wx.ALL, border=5)
self.button = wx.Button(panel, label='Print')
sizer.Add(self.button, flag=wx.LEFT | wx.RIGHT |
wx.BOTTOM | wx.ALIGN_CENTER, border=5)
self.button.Bind(wx.EVT_BUTTON, self.on_button)
panel.SetSizer(sizer)
sizer.Fit(self)
self.Show()
def on_button(self, event):
print(f'Entry contains: {self.entry.GetValue()}')
if __name__ == '__main__':
app = wx.App()
Printer(None)
app.MainLoop()```
oh wow thanks
I think the structure of any GUI framework code is down to how you structure the GUI code.
always use classes if you're building an app
In PySide6 Status bar becomes invincible if we disable Maximize button and show it in maximized form. How to solve this issue?
do you have code that can reproduce the issue?
@meager spoke show the UI i=like in images
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QMainWindow, QWidget, QGridLayout, QStatusBar
class Base(QMainWindow):
def __init__(self):
super(Base, self).__init__()
self.__main_widget = QWidget(parent=self)
self.__main_layout = QGridLayout(self.__main_widget)
self.__status_bar = QStatusBar(self)
self.__setup()
def __setup(self):
self.__setup_main_layout()
self.__setup_main_widget()
self.__setup_status_bar()
self.__setup_base()
def __setup_base(self):
self.setObjectName("base")
self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)
self.showMaximized()
def __setup_main_widget(self):
self.__main_widget.setObjectName('main_widget')
self.setCentralWidget(self.__main_widget)
def __setup_main_layout(self):
self.__main_layout.setObjectName('main_layout')
def __setup_status_bar(self):
self.__status_bar.setObjectName('status_bar')
self.__status_bar.showMessage("Testing 123")
@meager spoke its better to use designer because u never code the UI Patt
i know but it don't looks good. code generated by designer is mess
@meager spoke lol nope
@meager spoke the UI code isnt worked on in puthon its mostly worked on in designer
So what are you doing to affect the status bar?
disabling Maximize button
the code generated by uic
What are you trying to do with the status bar anyhow?
I can't reproduce on mac btw. maximize button is never disabled
i know i am disabling in the code.
i am doing nothing with status bar. The Status bar disappear if i disable maximize button through code
okay.. so how are you disabling the maximize button?
self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)```
okay well the maximize button is working for me is what I meant
Is this the code you're running exactly?
because this isn't how you use a status bar
@eager beacon moslty UI ineed to be filled to see the status bar
yes
show ur UI dude
I'm not sure what you expect to be able to tell from looking at the UI that you can't from the code
self.__status_bar = QStatusBar()
self.setStatusBar(self.__status_bar)
@eager beacon
@eager beacon check in this two pics if maximize button is not disabled it show status bar
set your status bar properly and tell me if it still happens
can you share code to set status bar properly
here
can you share code?
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:/Users/AppData/Local/Temp/designervlgcnY.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self) -> None:
super().__init__()
self.setupUi()
def setupUi(self):
self.setObjectName("self")
self.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(self)
self.centralwidget.setObjectName("centralwidget")
self.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(self)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
self.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(self)
self.statusbar.setObjectName("statusbar")
self.setStatusBar(self.statusbar)
self.statusbar.setStyleSheet("background-color: blue")
self.setStyleSheet("background-color: black")
self.setObjectName("base")
self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint)
self.showMaximized()
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self):
_translate = QtCore.QCoreApplication.translate
self.setWindowTitle(_translate("MainWindow", "MainWindow"))
APP = QtWidgets.QApplication([])
APP.setStyle("Fusion")
INST = Ui_MainWindow()
INST.show()
APP.exec()
no it is not showing in my pc
show UI
i dont have any idea about that bug
try checkin the ui using the Alt tab view
somwtimes windows maxes out of bounds
thats what is going on
idk about that i mostly use bothe buttons and just go eith 800, 600 size
hi, i asked a question here a while back, and it kind of got swamped, would anyone care to have a look at it, please? ๐
I need help with my Python Tkinter program Can I post it here?
Yes you can post here
I am trying to build a Tkinter GUI for my code that returns the least amount of coins needed given an
amount. I used a lambda function for my code because I know you cant pass arguments with Tkinter.
Here is the error Im getting:
NameError: name 'stack' is not defined```
Here is my code
Hey @trail stirrup!
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:
When the program gets to that line stack has not yet been defined.
Should i use place() or grid()
Can anyone help me .....
I want to append and show the txt file data in tkinter .....I tried it but when I append the show the data the loop again start from the zero and shows the previous data with add on of new line which cause the redundacy of data instead of just showing the last line by the keeping the old data same
Like:-
A
A
B
A
B
C
But I want it like :-
A
B
C
Use acc to ur needs
K
anyone know a good tutorial for QSyntaxHighligher in PyQt5? I dont want anything that uses the qt editor, just pure python
been having a lot of difficulty over the past few weeks finding any information, I only recently discovered this class existed when trawling through the docs and library files
just a quick search, is that what you were looking for?
i found that one aswell, unfortunately pyqt5 changed a lot of things and this code throws me error after error once I try to implement it into my pyqt5 project
Is there a way I can put a widget anywhere i want without moving the rest of the widgets?
I padded this entry on y, and my side panel moved along with it
that depends
although place would be good if u want a certain object to be at the exact place
hey all
i got problem with tkinter, i have 3 buttons, each clicked button have 3 variables for example a =1, b =0, c = 0, when second is clicked it changes a = 0, b=1,c=0 etc.
however i have other button which calls function with if statment checks if a = 1 , hwoever i get error
if a = 1:
^
SyntaxError: invalid syntax
where is problem?
==
How can I make a simple, square based but appealing tkinter interface
Basically, I have a couple of QMainWindows in my program and all of them are defined in one python file in the following lines of code
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Registration = QtWidgets.QMainWindow()
Registration_ui = Ui_Registration()
Registration_ui.setupUi(Registration)
AlterMenu_2 = QtWidgets.QMainWindow()
ui = Ui_AlterMenu_2()
ui.setupUi(AlterMenu_2)
StaffAddition = QtWidgets.QMainWindow()
StaffAddition_ui = Ui_StaffAddition()
StaffAddition_ui.setupUi(StaffAddition)
ViewStaff = QtWidgets.QMainWindow()
ViewStaff_ui = Ui_ViewStaff()
ViewStaff_ui.setupUi(ViewStaff)
MenuPage = QtWidgets.QMainWindow()
MenuPage_ui = Ui_MenuPage()
MenuPage_ui.setupUi(MenuPage)
OrderManagement = QtWidgets.QMainWindow()
OrderManagement_ui = Ui_OrderManagement()
OrderManagement_ui.setupUi(OrderManagement)
Login = QtWidgets.QMainWindow()
Login_ui = Ui_Login()
Login_ui.setupUi(Login)
Login.show()
sys.exit(app.exec_())
But in this code segment only the Login page is set to be shown
self.window = QtWidgets.QMainWindow()
self.ui = Ui_ViewStaff()
self.ui.setupUi(self.window)
self.window.show()
Login.hide()```
and this is what happens when a button is clicked on the login page, it hides the login page and moves on to the ViewStaff page
```py
self.window = QtWidgets.QMainWindow()
self.ui = Ui_Login()
self.ui.setupUi(self.window)
self.window.show()
ViewStaff.hide()```
and this is what happens when a button is clicked on the ViewStaff page, it opens up the login page again
but this time the ViewStaff page does not get hidden
PyQt
interesting
@digital rose if u can explain ur problem more vividly i can give u a better approach because by my knowledge its not proper
That's alright, I figured it out in the end, I was basically just creating Main windows of the different classes that I had in the program in the classes themselves with self.window= QMainWindow and etc
so they weren't getting hidden because the lines of code to hide them would have to be something like self.self.window.hide()
So I changed it all the format FirstWindow.show(), secondwindow.hide()
since they were all defined here
This would look like py Login.show() ViewStaff.hide()
https://github.com/UGLYclown999/Apollo/blob/master/apollo/app/apollo_TabBindings.py i dont do that i use just a single class to bind all the windows together and i avoide creating a lot of main windows
for example
Yeah that's probably a better approach
but I'm already way too into this way of doing it to restructure everything
fortunately I found a way to make it all work out so it's all good
im restructuring the 4 time
Lol damn
@digital rose gets better each time
Hello people, I'm adapting my script to use a PYQT interface. What's the really best way to use threading to separate interface and code? QApplication.processEvents() is a quick and dirty (and inefficient) way to do it, and I'm struggling to pass arguments with QRunnable... I don't need a full answer just some guidance. Also a good part of guides are outdated ๐ฆ
There's another way to create a worker class to avoid freezing gui using QThread
Thanks ! I'll check it out
https://stackoverflow.com/questions/67558617/python-program-not-responding-when-i-run-it-using-pyqt-5 Hey guys can you view this quetsion, it would be really apprichiated.
Grid system is useful but confusing, my window is not resizable so i think place would be a better option
Because i dont think my elements would be moving around
Hey there so i want that when i click a button, my UI should show a text saying "Attempting to connect to the server" and then connect, and if it fails, show an error box. But the text appears when the error box appears.
Code:
# Remove widgets from screen and disable and enable buttons.
self.app.unbind('<KeyRelease>')
self.scramble.place_forget()
self.display.place_forget()
self.duels_button.configure(state=DISABLED)
self.timer_button.configure(state=NORMAL)
# Show waiting for connection
self.conn_attempt = Label(self.app, text = 'Attempting to connect to the server...', fg='white', bg = self.window_background, font=('Oversized Mono Light', 18, 'bold'))
self.conn_attempt.place(x = 650, y = 250)
#Set up connection to server
time.sleep(15)
try:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
except:
print('Couldn\'t connect to the server.')
self.show_alertbox('servererr')
time.sleep(15)```
blocks the GUI loop from updating anything, just remove it.
Ok
Still only shows after the error message is shown
The error message is only being called in the exception, which means your try is raising an exception, by using a except without a particular exception it can fail for any reason and will give no indication of what it failed on.
Ok ok so I should only show the alert box if the exception is related that it couldnโt connect to the server
The connecting is probably also blocking the GUI loop so would have to be done in a separate thread.
https://python-forum.io/thread-17843.html
rather than using
except:```
check for the particular exception you are expecting to happen
```py
except YourError:```
or
```py
except Exception as exception:```
and output the exception in the error message
K k
Hi! I'm working on a tkinter start up screen, and I would like one button to be green and say start, and one to be red and say quit
I have the red one working but how do I create green one as well?
import time
from tkinter import *
from tkinter.ttk import *
# Create Root Object
root = Tk()
# Root Title
root.title("Soap - RPG")
# Set Geometry(widthXheight)
root.geometry('85x75')
# Create style Object
style = Style()
# Will add style to every available button
# even though we are not passing style
# to every button widget.
style.configure('TButton', font =
('calibri', 10, 'bold', 'underline'),
foreground = 'red')
def start_button():
def quit_button():
myButton = Button(root, text="Start", style = 'TButton', command = start_button)
myButton.grid(row=3, column=2)
myButton2 = Button(root, text="Quit", command = quit_button)
myButton2.grid(row=3, column=1)
text = Label(root, text=" Soap RPG\n\nRAM9-Copyright 2021")
text.grid(row=1, column=2)
root.mainloop()
Thnks!
ping me if u can help
Try this
import time
from tkinter import *
from tkinter.ttk import *
# Create Root Object
root = Tk()
# Root Title
root.title("Soap - RPG")
# Set Geometry(widthXheight)
root.geometry('85x75')
# Create style Object
style = Style()
# Will add style to every available button
# even though we are not passing style
# to every button widget.
style.configure('Red.TButton', font =
('calibri', 10, 'bold', 'underline'),
foreground = 'red')
style.configure('Green.TButton', font =
('calibri', 10, 'bold', 'underline'),
foreground = 'green')
def start_button():
pass
def quit_button():
pass
myButton = Button(root, text="Start", style = 'Green.TButton', command = start_button)
myButton.grid(row=3, column=2)
myButton2 = Button(root, text="Quit", style='Red.TButton', command = quit_button)
myButton2.grid(row=3, column=1)
text = Label(root, text=" Soap RPG\n\nRAM9-Copyright 2021")
text.grid(row=1, column=2)
root.mainloop()
thnks!
So i should make a func to only show that im trying to conenct to the server?
How can I improve this code? I feel like there are a lot of functions and i want to see if there's a way to improve that code because there are tons and tons of lines and it is kinda disordered.
https://github.com/MrFellox/flimsy-timer/blob/main/flimsy-timer/app.py
can someone help teach me how to make a calculation in gui
i want to make an app about area calculation
specifically triangle
``from tkinter import*
root = Tk()
root.geometry("400x400")
root.title("Percobaan")
mylabel = Label(root,text="Luas segitiga")
mylabel.grid(row=0,column=1,padx=125)
def hasil():
luas_segitiga = 1/2 * alas * tinggi
alas = float(alas_box.get())
tinggi = float(tinggi_box.get())
my_label = Label(root,text = luas_segitiga)
my_label.grid(row=4,column=0)
alas_label = Label(root,text = "Alas")
alas_label.grid(row=1,column=0,pady=5)
tinggi_label = Label(root,text = "Tinggi")
tinggi_label.grid(row=2,column=0,pady=5)
alas_box = Entry(root,width=20)
alas_box.grid(row=1,column=1)
tinggi_box = Entry(root,width=20)
tinggi_box.grid(row=2,column=1)
my_button = Button(root,text = "Hitung",command = hasil)
my_button.grid(row=3,column=1,pady=5)
root.mainloop()``
What should i do if i want to make a calculation
luas = area
alas = base
tinggi = height
luas_segitiga = formula for area of the triangle
!codeblock
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.
ya well, using pyinstaller does that
Yeah, my app has to live with that lol
Get a digital signature ๐
Do I have to pay for that?
Well obviously ๐
Lol, imma do it if I ever get some money from the app
Right now I need to order the code
I feel like there are a lot of functions everywhere
Anyway I have not thought about this. I will be making a cube timer soon too
First I have to get sub 30 :p
Noice, my pb is prolly 30 or something but average would be approx 40. But this was like 6 years before, I don't cube now
Fine, wbu
pb 9.8 ๐
Well I have GAN too, or had. I really forget how to do some :p
Sheeeshh
I used to average 40, but I haven't been cubing and now I'm at 1m
I feel like I couldve got sub 10, but then I lost all interest and went into magic ๐
printing text in the center is pretty easy, you can use .center() with a string and run the code in the terminal.
#this string will be shifted a bit to the right hand side of the terminal.
print('hello world!'.center(40))
@icy hare
Yeah same, now im interested in the timer ๐
Basically I'm making it to solve some problems i had with other timers
Find the max character that can be inputted too and then divide it by 2?
which is..
@icy hare if you want further organization of text in the terminal, possibly make a UI out of it:
http://urwid.org/
There are some examples in the right hand side.
I couldn't have my times on every device, so I'll add an option to automatically sync your times with G Drive
And the feature of creating and joining rooms
Hah I see, good luck
Thanks
you can treat that text as a multi line string and then use .center(int) on it.
My question is, a Tkinter app normally looks like this (https://github.com/MrFellox/flimsy-timer/blob/main/flimsy-timer/app.py) with a lot of functions spread out or it is me that I can't slice my code
There are alot of source codes that you can take a look at and find out how 'organized' your code is. Those methods can be accessed outside too
If you want to see unorganized code https://github.com/nihaalnz all of my projs are prolly unorganized
Alright, thanks!
http://urwid.org/
for making a decent terminal UI.
I've not used classes for any of my proj!! shame. But I did use classes for custom widgets.
the import tkinter as tk makes the code to look cleaner, I'll add that
It is recommended to not cause confusions later. But if you check some documentation, they poorly use from tkinter import *.
gys
Hi
In this step-by-step tutorial, you'll learn the basics of Python programming with the help of a simple and interactive Python library called turtle. If you're a beginner to Python, then this tutorial will definitely help you on your journey as you take your first steps into the world of programming.
So imma do it
cool
tbh, it's a lot of code for just making this grid ๐
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.
I wrote a small GUI in tkinter and mainly used the .place() function. Then I read on Stackoverflow in some comment, that this is not recommended due to strange behaviour on other machines. Is this true? Should I change this?
i mean tkinter in general has strange behavior on other machines
its more of a rapid prototyping
use qtdesigner if you want something that looks professional and you can be guaranteed itll look the same from one machine to the next
Oh, thanks. Never heard of this tool! :)
I made the GUI only with the code, which was a real pain on some points. ^^
you can do that in qt if you prefer as well. qtdesigner is a gui based gui design program.
both will end up giving you the code based output
Already downloaded it ;D
https://stackoverflow.com/questions/67573848/why-isnt-the-button-showing-up-when-i-run-using-pyqt5, Hey guys can you view this quetsion, it would be really apprichiated.
Hello guys, I really want to enhance my digital competences and learn Python. Can you recommend me how to start? I've already watched some tutorials and I found them quite helpful. Is there any other sources or any way how to better understand Python? Thank you.
place() does not scale well on resizing windows
try it yourself
you want to learn GUI in python or python itself?
I mean python, sorry if I put it to the wrong group.
ah this is not the right channel for that
!resources this will help you get started in python
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Well, the window can not be resized, due to the fact that the application is pretty simple.
thank you and I am sorry guys for that.
np!
Qt is a good choice
Yeah, I just downloaded it and tested it a bit, but I think I'll watch a tutorial before I start messing with it. ๐
what is the best library with a good grid system?
Qt has a nice QGridLayout
Ok I shall have a look at that thanks! I didn't really like Tkinter's grid system
np!
Anyone know why when I use pip install pyqt5, I get the following error and any solution:
ERROR: Failed building wheel for PyQt5-sip
Failed to build PyQt5-sip
ERROR: Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed directly
Why
It seemed really bad and unstructured
Structuring it is your duty right!
Try pip install --upgrade pip
Then try again
Where can I find the documentation for python GUI?
which module
PySimpleGui
ah idk sorry
Does all the libraries included in the topic provide Guis?
So not like Windows Form where you can drag and add buttons without code
So where do I install TKinter/what is the command for windows?
tkinter comes builtin with py
on windows at least
if you ticked the Tcl/Tk option in the installer
any ideas on how to make this in tkinter?
or maybe a simple version?
hi, i've asked a question in the cheese channel but no one answered and the channel is now locked so i will ask here. i'm starting to use qt to build ui applications but when i made a script error the app freeze and crash whitout telling me the error, is possible to enable it or at least display something when an error occurs?
are you using pygubu designer?
no
tkinter
pygubu designer is a tkninter expansion and allow to make tkinter apps whit a gui
whitout code the entire gui
i advice to install it to reduce the pain.
oh ok thnks
is similar to the qt designar but more "flat" but allow to do all the basic stuff of tkinter
can someone help me in this?
hello, is anyone know how to make json of manyToMany fields with django pls
@digital rose Can you provide the code.
Sorry, now is too late i'm not on pc. I will ask this question tomorrow (i have to work now).
Ok, sorry for not addresing your problem earlier. @digital rose
Question on tkinter and getting multiple selections in #help-popcorn.
I am encountering a problem, when I press the calculate button. I want to initiate a event or a code when the button is pressed but the program crashes, I do not understand whats happening. Here is the code:https://paste.pythondiscord.com/rololonebi.py
Looks like
btn.clicked.connect(btn.clicked)```
Should be
```py
btn.clicked.connect(btn_clicked)```
and
```py
#Button event
def btn_clicked():
print("Button clicked")```
will need to be moved to before the *btn.clicked.connect(btn_clicked)*
Thank you really, appreciate it. @lime monolith
Hi
I have a tkinter question
I want to have a button that root.destroys the window that is currently open
and open a new window. How would I do that? In a def(): function?
Thnks
no
If you destroy the root, that is the main window, once that is destroyed the GUI mainloop will end.
If you have a TopLevel window that root is not its parent, you can destroy that and open another without the main loop stopping .
import tkinter as tk
class Frame(tk.Toplevel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
button = tk.Button(self, text='Destroy', command=self.on_button)
button.pack()
def on_button(self):
self.destroy()
Frame()
if __name__ == '__main__':
app = tk.Tk()
Frame()
app.lower()
app.mainloop()```
Hello, i have a question, what is the difference between pyqt5 and pyqt6? If they both are same, which one is better?
pyqt6 has new features but the Qt6 API is not fully implemented yet in pyqt6
so for now pyqt5 would be the one to go for
though you can easily switch later on
Hi there, I was wondering how I could make it so that my label in tkinter stays in the middle top of the window even after I change the window size using my mouse? All the labels are using .grid btw
code:
#Imports
from tkinter import *
from tkmacosx import Button
#Root
root = Tk()
root.geometry("700x700")
#Labels
myLabel1= Label(root, text="Hello World!")
myLabel2 = Label(root, text="My Name Is TELEMETRY LINGO!")
myLabel1.grid(row=0, column=0)
myLabel2.grid(row=1, column=0)
#MainLoop For Tkinter
root.mainloop()
You could have a frame that sits on the root window that is packed with anchor set to N which will keep it at the top centre,
the labels then have the frame as their parent see the following modified example of your code.
# Imports
import tkinter as tk
# Root
root = tk.Tk()
root.geometry("700x700")
# Frame
frame = tk.Frame(root)
frame.pack(anchor=tk.N)
# Labels
myLabel1 = tk.Label(frame, text="Hello World!")
myLabel2 = tk.Label(frame, text="My Name Is TELEMETRY LINGO!")
myLabel1.grid(row=0, column=0)
myLabel2.grid(row=1, column=0)
# MainLoop For Tkinter
root.mainloop()```
Oh wow, Thanku so much
๐
IT WORKSSS
Thanks @lime monolith
(i asked that in general but no one answered so imma try here)
I have a question tho. is PyQt5 really worth my time?
I'm looking to do some cool stuff, and for that i need frames to be transparent, blur effects on transparent frames and other stuff, ability to have custom window borders, animations, see-through windows (windows that are transparent but whatever is on the window wont be) and a lot more stuff if i want to go mad with it.
@proud walrus yes https://github.com/UGLYclown999/Apollo is full Qt
yes on everything?
yeah
ok. thanks
blur effects on transparent frames
If you're on windows
im on linux.
well let me know if you figure it out!
aight.
data is only defined as a local variable inside of the function get_column_data ( which you have defined twice btw)
In your btn_clicked event handler function did you mean to call the function get_column_data as it returns data
@lime monolith yes I want to do that
I am encountering a problem, when I press the calculate button. I want to print the list in the terminal, but when I press the button it shows me an empty list, If I entered the data it to the table and then press the button it show me data not defined,I want to call the function get_column_data as it returns data. I do not understand whats happening. Here is the code:https://paste.pythondiscord.com/jocozeculi.py
any way to get desktop notifications with python?
im on linux and i need it to be installed with just a normal pip3 install command
Hi, im currently trying to build a ui with tkinter that can do audio analysing. I have the code where my sound wave and spectrum graph will move if there is a sound. Next, I created a button to run the code for the sound wave and spectrum graph. The problem is that the moment i run my code, the sound wave and spectrum graph runs automatic and the buttons i created disappeared. Can somebody help me with this problem? Please and thank you.
can anyone help me with kivymd
Guys has anyone ever experienced error while installing pyaudio? If so what can be done to correct it?
what's the error?
ft C++ Build Tools"```
What is not clear from this error? ๐
well I have 0 experience with this particular toolset but knowing windows, was the installation completely smoothly? did you restart after installing it?
yes
seems there are certain compatibility issues across versions
C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/
i have a function that generates an list out put that i put into a label. currently my label is inside the function and gets called every time overlaying my current label without overwriting it. is there an elegant solution ?
@granite mason u need to use a wheel
pyaudio in pypi compiles and builds locally so it need portaudio
Are you using tkinter?
sorry yes i am atm using tkinter
I see. Could you show what code you have up until now?
sure but be warned. i basically started 3 days ago. ill just pm
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.
the simplest way however is to not re create the label everytime, but to use .config().
look at this example:
my_label.config(text = 'new text')
@narrow nebula
How do i increase size of label in pyqt5?
do you mean just making the font larger?
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
import time
def window():
app = QApplication(sys.argv)
win = QMainWindow()
win.setGeometry(100, 100, 500, 500)
win.setWindowTitle("Radrider")
label = QtWidgets.QLabel(win)
label.setText("Hello")
label.move(0, 0)
label2 = QtWidgets.QLabel(win) # Working
win.show()
sys.exit(app.exec_())
window()
this is the code so far
label = qtw.QLabel()
label_font = qtg.QFont("Arial", 12, qtg.QFont.Normal, False)
label.setFont(label_font)
So i need to make "Label"'s size bigger
args are as such: <font family/name>, <pointsize>, <style>, <is italic>
alright
from PyQt5 import QtGui as qtg how it was imported if you care
np, feel free to dm me if u need more help
@frozen dagger dude use designer
Hey just trying to get my pandas updated from the command prompt and I'm having issues. I keep getting an incompatibility error when I try to install/update stuff. Is this the right place to diagnose my error?
probably people in #data-science-and-ml can be more appropriate to ask
tho this is a late reply, but what is designer?
How can I make a snappable grid layout in PyQt? (For example, like the grids that 2D CAD programs)
Hi, I am trying to build a video editor with pyqt5. I need to connect the video slider, with the timeline. The ones marked with a red arrow. Does anyone have an idea how to do it?
Whatโs that
What is the optimal resolution for the icon of my app in the window and in the taskbar?
Good night
i wanna visualize a SQLite database in a PySimpleGUI window
anyone know if i can do this with a table element?
or i have to use other element?
self.<video_slider>.sliderMoved.connect(lambda: self.<timeline_widget>.set_pos)
self.<timeline_widget>.<signal here>.connect(self.<video_slider>.setSliderPosition)
would something like that work?
I have a problem with that. Because I have the main window, it adds to the video widget and the timeline widget.
what do you mean?
Do both of the sliders have the same minimum and maximum value, or does the timeline slider have the ability to start at an imaginary negative frame?
If you are allowing a negative offset and the sliders have different widths, you will need to create some sort of positionToValue and ValueToPosition methods that translate the the timeline slider position to the video player slider position and vice versa.
hi! How do I make the font i picked on a font chooser as the default font of the program?
Here's the font picker I'm talking about:
self.master.tk.call('tk', 'fontchooser', 'configure', '-font',
'helvetica 24', '-command', 'command to make default font here')
self.master.tk.call('tk', 'fontchooser', 'show')```
tkinter help needed in #โhelp-coffee
How can I visualize an AST in a PySimpleGUI interface?
I have the AST, but not visually. How would I display it?
It's a tree graph.
I canโt save it into an image file btw.
I'm thinking of treelib, but I want to see if there are any other, better options to display a tree graph in a PySimpleGUI program.
you could try this approach, though im not entirely sure about its working.
from tkinter import *
from tkinter import font
root = Tk()
# TkDefaultFont instance.
default = font.nametofont('TkDefaultFont')
# overriding the already created tkinter defaults with your own font.
default.config(family = 'DejaVu Sans Mono', size = 14, weight = 'italic')
root.mainloop()
it doesn't quite work with the fontchooser dialog, as it returns a str, like {Arial Narrow} 24 bold italic
ah i see. i didnt read the fontchooser part in your question, my bad.
it's fine ๐
@polar wave are you using tkfontchooser?
yes
this one? https://pypi.org/project/tkfontchooser/
also, weight italic doesn't work in config, what is it's replacement???
wait no, i meant the discontinued one in the tkinter module.
that's why it needed to be called using call()
i would recommend using tkfontchooser, its well documented and easier to work with.
it has a built in dialog called askfont().
i actually tried using it bot it doesn't show the font in the dialog. this was tkinter's take on it which for me is better
this is tkfontchooser's
it's just my preference, sorry.
@polar wave i managed to get this working. now from {Arial Narrow} 24 bold italic you get this:
Arial Narrow, 24, bold, italic separately:
from tkinter import *
from tkinter import ttk
root = Tk()
def font_changed(font):
size = int(''.join(i for i in font if i.isdigit())) # get size by iterating over the string.
family_idx = font.index(str(size))
font = font.replace(str(size), '') # remove the size from font string.
# remove curly braces.
font = ''.join(i for i in font if i not in ('{', '}'))
font_family = font[:family_idx-1]
font = font.replace(font_family, '')
attributes = font.split()
print(attributes, size, font_family)
root.tk.call('tk', 'fontchooser', 'configure', '-font', 'helvetica 24', '-command', root.register(font_changed))
root.tk.call('tk', 'fontchooser', 'show')
root.mainloop()
the font_changed function is where i did most of the work. i just kept on iterating over the font string returned by the dialog, and it basically filters out the font family, the font's attributes, and its size separately, namely in these three variables:
attributes, size, font_family.
ok, thank you! how do you put italic to weight tho?
@digital rose this returns
Traceback (most recent call last):
File "c:/Users/it-admin/Documents/Python/tkinttest/main.py", line 6, in <module>
italic = Font(family='Ubuntu Mono', weight='italic')
File "C:\Users\it-admin\AppData\Local\Programs\Python\Python38\lib\tkinter\font.py", line 93, in __init__
tk.call("font", "create", self.name, *font)
_tkinter.TclError: bad -weight value "italic": must be normal, or bold
PS C:\Users\it-admin\Documents\Python>```
oh, my bad again. do this instead:
font_ = font.Font(family = 'Fira Code', slant = 'italic')
weight has only two options :bold, or normal.
@polar wave
oh, ok!
and one thing, that was a question too, was setting a font as default?
now you can apply this approach to the code i linked here 
here, set overstrike = 1 and underline=1.
font_ = Font(family = '10x20-ISO8859-1', overstrike = 1, underline = 1)
oh ok!
if you dont wont overstruck text, or non - underlined text, set them to 0.
so just True or False?
yes.
it worked! thanks so much!
no worries. ๐
hey user-interfaces people i have workaround for wakeup application
have you got some another idea how to do that?
import tkinter as tk
import threading
from pynput.keyboard import Listener as KeyListener
import time
class Example:
def __init__(self):
self.Flag_1 = False
self.thread_1 = threading.Thread(target=self.listener)
self.thread_2 = threading.Thread(target=self.tk_wakeup)
def sillyworkaround(self):
if not self.Flag_1:
self.root.destroy()
else:
self.root.after(200, self.sillyworkaround)
def GUI(self):
self.root = tk.Tk()
s_h = self.root.winfo_screenheight(); h = 70; y = s_h // 2 - h // 2
s_w = self.root.winfo_screenwidth(); w = 200; x = s_w // 2 - w // 2
self.root.geometry('%dx%d+%d+%d' % (w, h, x, y))
tk.Label(self.root, text='Hello World!!!').pack(ipadx=50, ipady=30, fill='both')
self.root.wm_attributes("-topmost", 1)
self.root.overrideredirect(True)
self.root.after(200, self.sillyworkaround)
self.root.mainloop()
def tk_wakeup(self):
while True:
time.sleep(0.2)
if self.Flag_1:
self.GUI()
def set_Flag(self, *args):
if str(args[0]) == '<96>': # NumPad 0
if not self.Flag_1:
self.Flag_1 = True
else:
self.Flag_1 = False
def listener(self):
with KeyListener(on_press=self.set_Flag) as li_stener:
li_stener.join()
def start(self):
self.thread_1.start()
self.thread_2.start()
if __name__ == '__main__':
app = Example()
app.start()
y u keep calling ur application again and again
in the while loop if u can explain the code i can help
those loops take to much from CPU and fan is start to work louder
so i'm looking for another idea how to start gui from binded button
@sleek grotto idk about tkinter
does this question fall into the category: difficult questions :D?
no i work in Qt and in Qt u can launch multiple main windows and dont need an seperate thread creation for it
yeah but in this app is only one window
i don't need multiple windowed mode
anyway in tkinter we can do the same thinks i think ๐คจ
or not
no exp with tkinter so i cant say
i have this wierd issues. Py complains that the Label Pictresult does not have an attribute show. but if i remove it .show() my GUI doesnt display the image even though i have been told i dont need to use .show
As it says, Labels do not have any attribute show(), there is some other issue that causes this, maybe some more code can help.
!paste
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.
https://paste.pythondiscord.com/tafuhevane.yaml its line 115-127. The show shouldnt be needed it was just a relic when i used to open the image in windows image
remove t.show(). t is just an array, it does not have a show attribute either.
Try keeping a reference to img so it is not garbage collected
img = PhotoImage(file= picturestr)
Pictresult = Label(root, image = img)
Pictresult.grid(row = 7, column = 7, padx=5,pady=5)
Pictresult.img = img```
ok that fixed it, but what happened?
img is a local variable to the function get_selected_value so when the function was complete img was garbage collected, by keeping a reference to it on the Label it stops that happening.
and when i had my faulty .show command it kept the function from garbage collecting my variable ?
when you had .show you would be getting an error stopping the function in its tracks.
alright thanks learned something new โค๏ธ
whoops, think I posted my question in the wrong channel so I'll ask here instead
Best GUI framework for someone coming from a webdev background?
or are they all equally very different from frontend webdev
more details: currently using py rich and have a beautiful CLI, but I admit defeat from the limits of running a semi-complex program from a CLI so I will most likely need to find a framework suited for GUIs
@brazen estuary python is not the best programming language for building a production - suited GUI. it cannot compete with what other frameworks in other languages, (most notably JavaScript or C#) can do. Still, the most prominent are PyQT5 and Tkinter. You can try either of them. (Even though tkinter has a reputation for looking old - fashioned, there are many ways to make it look better).
hmm, thanks. that's what I suspected. wanted to double check before diving in. which brings up a great idea for a new framework... web-based GUI for python... powered by a localhosted api?
would that even be possible?
so many great CSS + JS frameworks... obviously not all functions would work
tbh, doubtfully
or may be it is possible, I don't know. The problem is...
Front end frameworks require client side operations
but functions like showing data would definitely be possible
to which only Javascript is ok (or Typescript)
I know nothing capable to do the same in Python
hm
There is also WxPython to try
oh wait a second
are you wishing Desktop Application?
or Web site?
I answered from position of web dev
something like tailwinds < local api < python for a locally hosted software would be awesome
desktop
I think it should not be a problem then
quite possible
never heard of tailwinds though
right, probably not the most efficient, but i dont see why it wouldnt work and im surprsied theres no major projects yet
desktop GUIs is not a problem. especially if it is not for deployment.
it's for deployment for paying subscribers
will eventually incorporate licensing and code obfuscation
tailwinds could cut GUI development time insanely if there was some unified API for devs
i see. what are you trying to build then? it depends on what the purpose is, because with python you will have to take a ton of things into consideration, especially performance, which is a key aspect.
performance, not too demanding. security and privacy, important. the users will not be sending data to the internet
receiving data, maybe for updates
but the api (if made) would be totally local
the API would be generated with data fed from another program that they are already using
its to optimize that program
you could still experiment with either of these - Tkinter, PyQt, or WxWidgets, though there will a be a limit to performance, and that limit could be very small.
that's probably what i'll end up doing, thanks for the input guys!
but im always going to keep in the back of my mind that a web-based gui framework for python is an interesting concept and something maybe worth pursuing
its time to make python sexy
;p
taking a look now ๐
i dont know what type of web based GUI you will be trying to make, though pywebview is a library that allows you to display HTML in a native gui window, it might be helpful!
something that could be used by frameworks like Electron I guess
backend completely python, frontend web-based
or web technologies based*
There is also PySimpleGui and others that wrap the GUI frameworks and also wraps remi that you could try
cool, I'll take a look at that as well.
I just remember using Tkinter 10 years ago in college and shuddering at the GUI
you're not alone :p
then here and there I see some really nicely done apps/software made solely with python and i always wonder if some new frameworks out there that I dont know about hahah
even though there's a lot of ways to make tkinter look better, namely themed widgets.
right, I think I saw some repos with premade themes to use
that should probably help
but from what I remember even those were pretty ugly ๐คฃ
it's probably a bit too "over" to spin up a web server just to use a web-based python gui huh
you're not entirely correct, have a look at this one (that's probably the only that could be used for production)
oOoOoo that is clean
even though it seems like regular Microsoft - styled UI.
yes, it's a new tkinter theme.
its great that you can write entire files with Tcl, and tell tkinter to use them for UI.
damn I'm gonna miss my ascii art in my cli as the header
its sexy in a cool, techy way
hahahah if you know what I mean
I dunno why I like CLIs so much
guess it makes me feel cooler ๐คทโโ๏ธ
probably a hassle for clients though
yes, no one really prefers CLI for an app you're supposed to be using on a regular basis, hard to imagine running discord from a terminal ๐
even though, it's a lot of fun to make them.
it'd mostly be running in the background, but yeah hahah time to ditch that dream
anyways, back to work. thanks guys ๐
appreciate it!
back already ๐ ๐คฃ just took a quick look at .tcl -- maybe the framework im looking for is not a framework for web-based GUIs for python, but rather a framework for converting HTML/CSS into .tcl /other existing gui frameworks themes
makes way more sense
way less headache as well
I was surprised to see so many custom images being used for the templating
it's very easy to write a script that takes each CSS element on a page, have the script take a screenshot of that element/div/section/whatever and recompile it into a big image
reminds me of pre-bootstrap, pre-css days when we used tables with dreamweaver
now this really has me thinking...
anyone want to criticize the idea before I actually consider starting this project?
I love to be shot down, cause then I dont waste time..
so please feel free to call me an idiot if there's something on your mind hahaha
maybe this would be better suited as question for the subreddit huh
sorry for the spammy talking-to-myself rant, but I think I found what I was looking for: https://github.com/ChrisKnott/Eel
Hello, i'm new here, ive read the discussion and it reminds me: https://github.com/wang0618/PyWebIO
that looks great, I'm definitely going to take a look. I knew there had to be something out there!
this is why I love the reddit community~
hm, looks like its heavily flask inspired, which is something I'm sort of familiar with
support for pyinstaller, great. Alright, looks like I'll be doing some research on Eel and PyWebIO tonight.
later guys~
Good luck
I have that value, to transform from one slider to the other, but I don't know how to send that value in real time.
Is there a option in Tkinter to add Webview as in PyQt5
I'm getting 'TypeError' while add window icon in PyQt5. What is TypeError ? How can I solve it ?
ping me on reply
import sys
from PyQt5.QtWidgets import QWidget, QDesktopWidget, QApplication
from PySide2.QtGui import QIcon
class Window(QWidget):
def init(self):
super().init()
self.setIcon()
self.top_left()
self.initUI()
def initUI(self):
self.setWindowTitle('Main Window')
self.setFixedWidth(1920)
self.setFixedHeight(990)
self.show()
def setIcon(self):
appIcon = QIcon('C:/Users/hp/Documents/py properties/i.ico')
self.setWindowIcon(appIcon)
def top_left(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().topLeft()
qr.moveCenter(cp)
self.move(qr.moveTopLeft())
if name == 'main':
app = QApplication(sys.argv)
window = Window()
sys.exit(app.exec_())
!codeblock
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.
what does it say at the bottom of the bot's response: These are backticks, not quotes. Use backticks, click the link if you cannot find the key.
mate, not this " ' " but this " ` " its below esc
!codeblock
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.
how to create your own theme to tkinter? I mean ttk like Azure. I think its html and/or css but idk how to do it.
ok, its tcl. Is there any complete tutorial for it?
Hi, I need to add small pictures to a widget, and then be able to double click on them. What do you recommend? I am using Pyqt5
Hey @coarse mirage!
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:
I'm using PyQt5 and trying to have a gif in my label to change to a different gif on a button click.
But for some reason it doesn't work.
Here's the code I have so far:
"confident": "C:/Users/nomar/Dropbox/Blueprints/Trucy_Confident_Speak1.gif"}
class Main_Window (QWidget):
def __init__(self):
super().__init__()
self.title = "Dice Game"
self.left = 10
self.top = 30
self.width = 420
self.height = 540
self.label = QLabel(self)
self.button_1()
self.mw_attributes()
self.screen()
self.textbox()
self.show()
def mw_attributes(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left,self.top,self.width,self.height)
self.pixmap = QPixmap("C:/Users/nomar/Dropbox/Blueprints/ivc.png")
self.label.setPixmap(self.pixmap)
self.label.resize(self.pixmap.width(),self.pixmap.height())```
def button_1(self):
pybutton = QPushButton(self)
pybutton.clicked.connect(self.button_click)
pybutton.resize(111,53)
pybutton.move(160, 480)
pybutton.setStyleSheet("QPushButton"
"{"
"background:transparent;""background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbutton.png);"
"}"
"QPushButton:hover"
"{"
"background:transparent;""background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbuttonhover.png);"
"}"
"QPushButton:pressed"
"{"
"background:transparent;""background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbuttonpressed1.png);"
"}")
def button_click(self):
score = randint(1,6) + randint(1,6)
self.gif_background.movie = QMovie(animations["confident"])
self.text.setText(f"The roll is {score}.")
def screen(self):
self.gif_background = QLabel(self)
self.gif_background.setGeometry(40, 60, 107, 100)
self.gif_background.setStyleSheet("background-image : url(C:/Users/nomar/Dropbox/Blueprints/Background.jpg);")
self.gif_background.movie = QMovie(animations["normal"])
self.gif_background.setMovie(self.gif_background.movie)
self.gif_background.movie.start()
```
Well a snippet of the code at least.
@stable folio style sheet
I thought: def button_click(self): score = randint(1,6) + randint(1,6) self.gif_background.movie = QMovie(animations["confident"]) self.text.setText(f"The roll is {score}.")
specifically self.gif_background.movie = QMovie(animations["confident"]) would change it but I guess not.
Learn Tcl, for tkinter atleast.
I believe you have to create widget defaults in a Tcl file that you are calling in the tkinter file, and also create images for different widget states, though I'm not sure how to integrate them into the theme.
let me try
mm
@distant swift complete error log please
wait a min
"C:\Users\hp\PycharmProjects\JARVIS Mrk IV\venv\Scripts\python.exe" "C:/Users/hp/PycharmProjects/JARVIS Mrk IV/trash2.py"
Traceback (most recent call last):
File "C:\Users\hp\PycharmProjects\JARVIS Mrk IV\trash2.py", line 31, in <module>
window = Window()
File "C:\Users\hp\PycharmProjects\JARVIS Mrk IV\trash2.py", line 8, in init
self.setIcon()
File "C:\Users\hp\PycharmProjects\JARVIS Mrk IV\trash2.py", line 20, in setIcon
self.setWindowIcon(appIcon)
TypeError: setWindowIcon(self, QIcon): argument 1 has unexpected type 'PySide2.QtGui.QIcon'
Process finished with exit code 1
@distant swift try converting it to pixmap then to icon idk i dont about this way i mostly use QSS to style
let's see what happens
I got error again
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
what does this mean ?
how to solve it
@distant swift ur path l
please explain it
Use backward slashes /
Why aint pyqt5 working well
@digital rose u need some osme background colour or something
You need to upload a css file not an image
but that backslahes give TypeError
Dm me and show me
I just added background-image at the beginning
Now it gave me this
How do I change the size of this image?
(Its in a pushbutton)
This is for labels
Push button
How to link scaling ;-;
Oops nevermind just set image as "Border image" instead of "background image"
My PyQt5 window is appearing after every function is executed
I want my window appear first
then functions
especially
pyttsx3 is
coming first
@digital rose ```py
QPushButton#LBT_PSB_mainsearch{
background-color: #262626;
border-radius: 2px;
background-image: url(':/icon_pack/png/16/volume--up_icon-02.png');
background-position: center;
background-repeat: no-repeat;
color: #78a9ff;
border: 1px solid Transparent;
border-radius: 2px;
}
QPushButton:disabled#LBT_PSB_mainsearch{
background-color: #525252;
color: #6f6f6f;
border: 1px solid Transparent;
padding: 8px;
}
QPushButton:hover#LBT_PSB_mainsearch{
background-color: #525252;
color: #a6c8ff;
border: 1px solid Transparent;
padding: 8px;
}
QPushButton:checked#LBT_PSB_mainsearch,
QPushButton:pressed#LBT_PSB_mainsearch {
background-color: #525252;
color: #a6c8ff;
border: 1px solid #262626;
padding: 8px;
}
@distant swift keep ur show methon under the init
Imma do PyQt5 someday its really complicating ;-;
@digital rose learning curve is hard
@digital rose https://github.com/UGLYclown999/Apollo can use my style sheet
Dang thats in PyQt5??
yup
thats actually good
Also are you able to resize the window?
how did you do that?
(I want to apply it in tkinter)
yeah i havent yet switched to frame less but ave code for that i just dont like the custm scaling ad dragging i have and WM of windows works for me
it only QT
Oh
Linking to help channel, about manipulating windows GUIs #help-cake message
Probably more knowledgeable people here
@edgy kestrel You could try checking the class name with win32.GetClassName on the hwnd, that might be more consistent, not 100% sure though.
Oh rite, i tried it when i was playing around how the module works but disregarded it as i didnt see any use for it
It should be pretty good for this case though
Implemented it and seems to work really well
you could also look into something along these lines which could give you the executable path of the process https://stackoverflow.com/a/42607775
That would probably be better than class name, as i'd reckon quite some processes might share the same class name
thats not how you're supposed to do it
either you set that as a background-image
or you link a qss file
How can I make a button like this one using the Kivy module in Python?
if you're using kivy exclusively, you can also use the kivymd source code
Oh Okey thank you very much
why do people use classes on tkinter
@digital rose because UI is designed in layers adn for testing dependency independence is good
Oh so what is better? using classes or no
Always class
classes fit in perfectly for creating neat and structured code. it is always better to use classes, not just for tkinter, but for most programs which have a lot of lines of code.
Oh I see
How do I use "focus_get" in an if statement (I want an event to happen if the entry box is not selected)
