Hello I am 9th grader and i'm trying to create an app which live streams arduino data on to your phone. I am using kivy to create this app but I dont know how to create a bluetooth interface with the app I have alredy figured out how to create a live plot with kivy I just need to get the data from the arduino via bluetooth to the mobile app
#user-interfaces
1 messages · Page 57 of 1
Hey guys, I'm trying to load database entries into a Tkinter window, is there something magic like C# WPF has data binding and MVVM?
interest anyone?
this makes guis sooooo easy man https://github.com/hoffstadt/DearPyGui
Hello im trying to make it so a label prompt will pop up in a tkinter window for only 5 secs (temporary) then it'll disappear, anyone know how to do it? Thanks
@digital rose Just saw this on the subreddit
Im having trouble with PyGui
Im getting stuff like this
instead of just the window
dm me
Okay
@spark crest if youre trying to make a popup/prompt, just use the tkinter.messagebox!
Here's an example:
`from tkinter import *
from tkinter.messagebox import showinfo
def showpop():
popup=showinfo("hey","sup user")
window=Tk()
popupbut=Button(window,text="popup",command=showpop)
popupbut.place(x=0,y=0)
window.mainloop()
`
@spark crest
correct me if im wrong but why use tkinter?
He asked for implementation in tkinter lol
Hello im trying to make it so a label prompt will pop up in a tkinter window for only 5 secs (temporary) then it'll disappear, anyone know how to do it? Thanks
@spark crest
but why
Why not?
you cannot customize the color bg font etc in pygui if im correct
@spark crest if youre trying to make a popup/prompt, just use the tkinter.messagebox!
you can
thanks will try
in fack theres an entire gui that does that built in
oh i see, i didn't know you can customize them
@digital rose every gui has its pros and cons. I will not get into whats better and what not. People use whatever they want to, depending on their needs.
And who said u cant do more in tkinter??
tkinter can set back ground other than that there the same
and there working on adding that
and then some
and its easyer
eh they're both good, maybe pygui is easier for others, and maybe tkinter is easier for others?
haha
hmm @past locust im getting an error saying 'showinfo' is not defined
its a function right
nevermind its fixed i just used pygui instead haha
thanks anyways its still help
@spark crest u can do :
`from tkinter import messagebox
si=messagebox.showerror("hey","there was an error")
`
Instead of using showinfo() @spark crest
Never mind u used pygui
is flaskwebgui good
Thanks anyways :DD
why isn’t my PyQt5 program showing any window? it already has sys.exit(app.exec_()), and printing after window.show() does indeed print, but the GUI doesn’t show.
this is the code: https://paste.gg/p/anonymous/0bac510906ac49489f26a7be586934b9
(there are 2 files)
when I remove the syntax highlighting, it runs perfectly.
nevermind, it’s just some weird things with regex, ^ wasn’t escaped and when it got added to operators, it broke it.
In PyQt5 :
I have a bunch of buttons in a UI that I have set up. when the user clicks any of these buttons it's color changes to yellow. i am using the button.setStyleSheet("color: rgb(255,255,0);') to change the color to yellow.
If the user clicks another button I want the color of that to change to yellow and the previous one to change to white. in order to do that I need to run a loop with an if condition and check which buttons are already yellow. can someone help me with the code to retrieve that earlier set yellow.
according to what I understand, you need to run a loop in a PyQt5 program, for your own events, which stops it.
you can use a ‘thread’ that carries the loop.
here’s an example:
import threading
from PyQt5 import ...
def EventLoop():
while True:
...
thread_instance = threading.Thread(target=EventLoop, daemon=True)
thread_instance.start() # permanent thread
# rest of your app
@fluid tinsel was that for my question ?
I dont understand that answer . Im sorry. I just want a way to retrieve the stylesheet color of a button
how do i make a gui with html and css for python?
you can set a variable with it’s color.
@fluid tinsel was that for my question ?
@teal hearth if you want the loop to be running while the GUI is also running
you have to use multi-threading
cause it will interrupt your main event loop
helloo
im currently designing a gui for an axe throwing game
i just couldnt figure out how you integrate a fullscreen picture
i prepared one for the background
but it has these terrible borders up and down, left and right
i included the prepared picture for the background via tk.Label()
i tried the fill and expand option but they dont apply to images
any ideas on how to get a borderless fullscreen picture?
@nocturne fog u need to use a game library. Tkinter is a GUI module. Use something like pygame, and try asking in #game-development
aight thanks @past locust
@bronze basin not that advanced at all yet. I don't think I can get that working
@teal hearth but if you want a loop that runs all the time while your GUI is also showing
this is what you have to do
maybe you can learn a bit more about PyQt in general and its multi-threading features and come back to it?
Hi, I want to update my current app created with PyQT5/ QT Designer One of the things I want to add is a setting where I can enlarge and decrease the font size of the text inside QLineEdits. How can I do this. Thanks, Famous8
does what I am doing here make sense
from tankui import DeethanizerApp
class loadingapp(wx.App):
def OnInit(self):
self.frame = loadingdlg(None)
self.SetTopWindow(self.frame)
self.frame.Show()
return True
class makeapp():
def __init__(self):
if doload == 0:
if __name__ == "__main__":
app = loadingapp(0)
app.MainLoop()
if doload == 1:
if __name__ == "__main__":
app = DeethanizerApp(0)
app.MainLoop()
makeapp()
basically i want to open up a dialog that selects which all to run with a dropdown menu then close that app and run the slected one
!paste
i am using wxpython by the way
hellow....? anybody here to help?
i want to ask How do you Flash A text in PyQt5?
Just like a warning text but animating after a specific interval of time,
Hi, I want to increase the font size of all text in a PyQT5 UI with a Horizontal Slider, does anyone know how to do this. Thanks, Famous8
@bronze basin . I will do that. Thank you
Which library would you recommend for cross-platform GUI in Python? I'm wondering how well PyObject would compare to PyQt, PySide, etc
@digital rose It's really easy to set up a GUI: https://repl.it/repls/UtterVagueDownloads#main.py
There's probably a REST API, which you can adapt as I was demonstrating with this
hi
like an OK button
i am giving the code
no
oh
or you could use something better
what?
like dearpygui
i only wanna make an OK button and a link
easy
kivy or pyqt5 but htey arew tough tkinter is the easiest
no dear is the easyest
i am a beginner in GUI
it even has a gui to make things easyer
oh ok
ok
so do i pip install it?
yes
then?
but make sure pip and stuff are up to date
they are
good
heres the cmd
updated a week ago ig
from tkinter import *
screen = Tk()
screen.mainloop
whats this?
pip install dearpygui
or
pip3 install dearpygui
then dm me for example code
but tkinter is the easiest
no
it comes by default and it takes 3 lines to create a screen
but this is not popular
tkinter is more popular and easier according to google
google doesnt even know this exists
@digital rose use tkinter more easier faster, and comes by default no need to doanload
do whatever
im not here to argue
@digital rose sry me too
actually both are awesome
we should never disrespect anything
@digital rose
yes
so fight solved
but.. this has built in guis for colors, buttons and text
lets be freinds
ok
yes
tkinter strangely enough isn't often installed by default on Linux distros, and it can't be installed through pip
Obstensibly yes, but there's often this focus on keeping the base OS lean and anything else needed is available in the package manager like so: sudo dnf install python3-tkinter
But I feel that tkinter is one of those packages that should be preinstalled because Python is used everywhere on Linux and tkinter is a de facto standard for the language
lol
from tkinter import *
import time
root = Tk()
root.title("Pomodoro Timer")
root.geometry("300x300")
root.config(background="#45b3e0")
#functions
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r")
time.sleep(1)
t -= 1
seconds.config(text=str(secs))
minutes.config(text=str(mins))
#creating labels
global minutes
minutes = Label(root, text="0", font=('Helvetica Neue', 20), bg="#c9e9f6", fg="#898b8a")
minutes.place(x=60, y=80, width=80, height=80)
minuteLabel = Label(root, text="MINUTES", font=('Helvetica Neue', 10), bg="#c9e9f6", fg="#898b8a")
minuteLabel.place(x=60, y=170, width=80, height=20)
global seconds
seconds = Label(root, text="0", font=('Helvetica Neue', 20), bg="#c9e9f6", fg="#898b8a")
seconds.place(x=150, y=80, width=80, height=80)
secondLabel = Label(root, text="SECONDS", font=('Helvetica Neue', 10), bg="#c9e9f6", fg="#898b8a")
secondLabel.place(x=150, y=170, width=80, height=20)
countdown(5)
root.mainloop()
hey guys, im trying to create a countdown timer but it doesnt seem to be working 😭 please help
hi
def TimeTable():
Button(style='TimeTable.TButton', text="TIMETABLE", command=TT).grid(column=1,row=1)
def loop(): # Time Display
l=Label(text=current_time(), style='Time.TLabel') # Creates a Label with the current time
l.grid(column=0, row=0) # 'pack's the label
Win.update() # Updates the GUI
Win.after(1000, l.destroy()) # Destroys the Time Display Label after 1000ms
loop() # Re-calls this function
TimeTable()
quitBUT = Button(text='QUIT', command=Win.destroy)
quitBUT.grid(column=0,row=1)
loop()
How would I put TIMETABLE right next to QUIT
{PyQt5} Hey guys, i wanna ask How do you use the accept and reject function of QdialogBox?
in my case i want to get the value of Comboboxes whenever the ok button is pressed
i am making a palgiarism checker for uni project
can anyone recommend the best python UI i can use , like user has to upload the file and all
Pyside2
i have learnt tkinter enough to create ok GUI's that serve my purpose
now i am seeking for a GUI that is more aesthetically pleasing
any suggestions?
ping me 🙂
@modern marsh Pyside 2
hmm ok
why is the resolution in the text box so bad?
(PySide2, QPlainTextEdit)
https://media.discordapp.net/attachments/459003825676615691/773882245471404062/image0.png
aaa
@fluid tinsel weird. try increasing the size of the textbox or smth that will make its resolution more detailed
Hey guys
I need help with loading multiple images from different URLs in tkinter GUI
Would anyone know how I could convert this popout menu to a simple dropdown box in PyQt5? I am assuming QComboBox but I don't know to get a grid inside of a QComboBox.
Use a listView in the combo and a QStyledItemDelegate
I will have to do research on both of those lol. No clue what they are
would probably be easier to convert that to a frameless widget and create a label that looks like a combo drop down that when clicked opens the framelessWidget under the label
If that is an actual QMenu you could use a tool button with menuButtonPopup mode and set the menu to the toolbutton
that would be the easiest way to do what you're trying to do
@eager beacon I will give that a shot! thanks for the suggestion
@eager beacon This is what I am trying to do but it doesn't seem to be working like I want it too
any idea how to display Gifs in Tkinter?
def RunGIF(icons,tail,head,ImageNumber,img,panel):
print(ImageNumber)
ind = 0
GifFrame = os.path.join(head,tail)
while True:
if '.gif' in str(tail):
try:
im = Image.open(GifFrame)
resized_im = im.resize((128,128,),Image.ANTIALIAS)
tk_im = ImageTk.PhotoImage(resized_im)
panel = Label(window, image=tk_im)
panel.place(x=400,y=20)
print(ind)
#sleep(0.01)
except:
ind=0
else:
tl.cancel()
break
def showIcon(ImageNumber,icon):
global Iconwidth, Iconheight,Infos,img
gifs = 0
x = icons[ImageNumber]
img = Image.open(x)
Iconwidth, Iconheight = img.size
img = img.resize((128,128), Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, format="gif -index 0")
panel = Label(root, image=img)
panel.image = img
panel.place(x=400,y=20)
test = 0
head, tail = os.path.split(x)
File_size = round(os.stat(os.path.join(a,tail)).st_size/1024, 2)
Infos = Label(root,text=f"Filename: {tail}\nFile Size: {File_size} KB\nDimensions: {Iconwidth} x {Iconheight}\nWidth: {Iconwidth} Height: {Iconheight}")
Infos.place(x=380,y=210)
t1=threading.Thread(target=RunGIF,args=(icons, tail,head,ImageNumber,img,panel))
t1.start()```
this is what i have
but the gif dont move idk why
Stack Overflow
I've been trying to play an animated gif using Tkinter.PhotoImage, but haven't been seeing any success. It displays the image, but not the animation. The following is my code:
root = Tkinter.Tk()
...
#user-interfaces message
the size is screen_x // 1.5, screen_y // 2
it’s not too small
guys so im having a problem, pretty basic
field = Entry(root).insert(0, 'Sample text')
field.pack()
root.mainloop()
and this is the error im getting
Traceback (most recent call last):
File "/home/joshua/PycharmProjects/gui/main.py", line 22, in <module>
field.pack()
AttributeError: 'NoneType' object has no attribute 'pack'
it does work when i do
field = Entry(root)
field.insert(0, 'Sample text')
field.pack()
root.mainloop()
but isnt .insert() a method of Entry()?
Entry has an insert() method @main cedar
maybe you can pack your entry before inserting ?
@main cedar put the thign like sample thing in like this text="brtyyh"
Difference between PyQt and PySide?
Mostly the licensing
What about documentation? I'm a complete beginner
is pyqt5 totally free?
yes
only if you open source your project and use the GPL
like im making this for UNI
@tacit sky PyQT5 is your best bet
also it has QT Designer, which is a drag and drop interface
Difference between PyQt and PySide?
@obtuse pumice Pyside 2 has more flexible licensing
@bronze basin What about quality of documentation?
its good i guess comparatively and both their syntax and features are basically the same
so 99% of the things you learn in Pyqt you can do in Pyside 2 and vice versa
Okay, i will start with pyside then
Hi, I want to increase the font size of all text in a PyQT5 UI with a Horizontal Slider, does anyone know how to do this.
also I want the QLineEdits to expand to the size of its contents. I have multiple QLineEdits, but the output is always different, and I want it to expand to the size of its contents also how can I do this. Thanks, Famous8
anyone around that could help with some basic wxPython stuff?
like what?
so i had an app that was running fine but i wanted to have an interface that opens before the app opens
so you can select which file to use
and now i just cant get things to start
class makeapp():
def __init__(self):
if doload == 0:
if __name__ == "__main__":
app = loadingapp(0)
app.MainLoop()
if doload == 1:
if __name__ == "__main__":
app = DeethanizerApp(0)
app.MainLoop()
makeapp()
basically i cant lauch the Deethanizer app properly now
does it have to do with "name == "main"" because no articles can seem to dumb it down enough for me as to what that does
it means something like
if this is the starting script
so if you run the script directly it's True and if you import the script it's False
this is what it used to be
from tankui import MyApp
import wx.lib.inspection
if __name__ == "__main__":
app = MyApp(0)
#This is its own GUI/application it is used to help debug wxpython and show you various elements of the app
#wx.lib.inspection.InspectionTool().Show()
#Makes the application visible
app.MainLoop()
MyApp renamed to Deethanizer App
You should try to debug it
the vscode debugger has always been pretty confusing to me
yeah i mean hypothetically it runs because i get an error that something down the line isnt found
idk
yeah hold up
oh
!paste
then maybe post the error? xD
(base) C:\Users\Nicks\Desktop\Deethanizer V4\HYSYSapp>C:/Users/Nicks/anaconda3/python.exe "c:/Users/Nicks/Desktop/Deethanizer V4/HYSYSapp/source1/main.py"
Traceback (most recent call last):
File "c:\Users\Nicks\Desktop\Deethanizer V4\HYSYSapp\source1\tankui.py", line 869, in OnInit
self.frame = MyFrame(None, wx.ID_ANY, "")
File "c:\Users\Nicks\Desktop\Deethanizer V4\HYSYSapp\source1\tankui.py", line 300, in __init__
self.hyComAPI = ComAPI()
File "c:\Users\Nicks\Desktop\Deethanizer V4\HYSYSapp\source1\hyComAPI.py", line 26, in __init__
self.simulation = self.hysys.SimulationCases.Open(resource_path(r'deethanizer_ts.hsc'))
File "<COMObject <unknown>>", line 2, in Open
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -1072879842), None)
OnInit returned false, exiting...
like i know sort of what this error means but given that nothing changed in the script there it shouldn't even be an issue
@plain elk i was being silly i forgot you need to be connected to a VPN to run my program requires a connection to validate a license
Oh. Glad you figured it out ^^
still some issues but not a matter of it plin out not working
like its way slower than i would imagine which is odd
not python related but just general - after creating a ui design in figma or adobe, how do you go about implenting it
I am trying to install a package but it is saying"Fatal error in launcher: Unable to create process using '"c:\users\owner\downloads\python.exe" "C:\Users\Owner\Downloads\Scripts\pip.exe" install pyqt5': The system cannot find the file specified. " what do I do
@median ridge Programs like figma are made to prototype and create mockups, it's up to the developer to actually use the visuals, information, and size/spacing to achieve the goal
yeah but from a dev standpoint how do you turn the prototype into reality
any ideas for intermediate gui projects?
Qt library? @median ridge
Hello 👋. What library is better: tkinter or pyqt5? With "better" in this case I mean the library that gives you the more possibilities to create GUIs and "easy" to use
tkinter is easier and pyqt5 gives more possibilities
The answer I was looking for 😅 thank you!
For what application? @weak trout
It's a desktop application. Doesn't involve much graphics, just a small menu with some options. Though I want it to be good-looking
TKinter is easier to use and CAN get you decent menus and GUIs, however TKinter is much more complex, and although it is harder to set up, it might be worth it for good-looking GUIs
Most people use TKinter only for popup windows and error messages, because its functionality is limited
I would prefer PyQT5... it even has a GUI editor that let's you auto-generate PyQt5 code by dragging items on the screen
I'm not really an expert on the "Good Looking" part of it, but I would expect PyQt5 to look better than TKinter
Both are customizable to some degree so it depends on the use, I don't think their difficulty is that different although tkinter will be easier to start with as qt needs some getting used to
I'll consider my decision. Thank you all for your comments, really helped 👍
No Problem 👍
If PyQt5 and PySide2 are about identical, is there any reason to choose the one or the other except for licensing?
I had some problems with pyside2 in one case and they handle a few things differently, so I'd maybe try them both out and go with what suits you and your project more
Anyone familiar with Choropleth maps? I already have a map working using Plotly, I just have a question about presenting my map using Qt UI.
Is there any good tutorials on how to structure a good program in Qt?
@silk basin what happened?
what do you mean?
PyQT5 the best thing
someone please answer this
its about PyQt5
@digital rose did you figure it out? Link is dead
Yes I deleted because I found a duplicate: https://stackoverflow.com/questions/41870727/pyinstaller-adding-data-files
And this solved it for me
resize probably works in place so it would return None
@digital rose why would you want to include the UI file anyhow? seems unnecessary...
ok
?
@uncut pawn what are you talking about?
In Qt, should QStackedWidget be used when a menu bar chooses the displayed info?
I want pushbuttons for menu choices, so when pushing the menu items, the "main" area changes depending on choice
tab widget wouldn't work i think
This is outside of Menu bar
i don't see why it wouldn't work with a tab widget
although the tabs would be visible
I don't understand what you mean 'locked next to each other'
Sorry 😅
it would be easier to go with a tab widget, that way you don't have to worry about highlighting the right button if someone decides to use the tab to navigate instead of the menu buttons
er... i meant it would be easier to go wth a stacked widget
Thinking about something like this
Then the content widget needs to be inside a stacked widget i assume
or the multiple content widgets
yeah, just make some checkable buttons and a stacked widget hooked up to them and you're g2g
I'd probably avoid using a toolbar for it but thats mostly because I hate the behavior of toolbars
Has anyone here ever created a custom calendar with QtWidgets?
Also, is there someway to force user to only enter numbers in something like a line edit?
use a spinbox
Or should i just use spin box?
Can i remove the rightmost side increment and decrement?
you can set set the button symbols to NoButtons to hide the spin/double spin controls
if you disable the wheel event a spinbox would be pretty much the same thing as a lineEdit with a validator and take less effort
Okay, thanks 😄
I started with tKinter module today
So I want to make a upper frame a interface for TV screen , whenever I click on the button channel plus , channel increase by 1
I want to change the current label and not print a new one , I want to change existing label on the screen
Help pleaseee
your_label.config(text='new_text')
It's not working ,wheneve I click the button , nothing happens
Label['text'] = new text
I am doing this inside a function
Button["command"] = function
Why I should use config?
Label['text'] = new text
@digital rose same .
"import tkinter
root=tkinter.Tk()
l1=tkinter.Label(root,text="hello bois").pack(side=tkinter.LEFT)
def kpk():
l1["text"]="changed to bye bois"
btc=tkinter.Button(root,text="button",command=kpk)
btc.pack()
root.mainloop()
"
'''import tkinter
root=tkinter.Tk()
l1=tkinter.Label(root,text="hello bois").pack(side=tkinter.LEFT)
def kpk():
l1["text"]="changed to bye bois"
btc=tkinter.Button(root,text="button",command=kpk)
btc.pack()
root.mainloop()
'''
button isnt doing anything
😭
Why is it so difficult to move a frame in Qt Designer?
its not 🙂
I have 3 frames "top, center, bottom" inside another frame. How can i easily choose the placement of those 3?
send screenshot
When i try to move one to the bottom, it jumps out of the parent frame
yeah, took me about 2 years to figure that one out
Can i lock the size for a frame in Qt Designer?
set the sizePolicy to Fixed
@obtuse pumice just curious.. why did you choose designer over creator?
seems like most people on here are using designer
No reason really, i started follow a youtube tutorial which used designer
So a frame the geometry is grayed out 🤔
I guess i could use the maximumSize to change the size
what are you trying to do that you want to change the geometry?
typically you would just adjust the sizePolicy and the min/max size
and maybe the baseSize if they ever got that working
The upper left frame is to big
set the lower frame size policy to Expanding
and the upper to Preferred
the verticalPolicy that is
the verticalPolicy that is
Now when i try to resize it, it just eats up the bottom frame
Now when i try to resize it, it just eats up the bottom frame
Okay, i will try to put something there first
you can use a vertical spacer to see what it would look like fully expanded
I just looked at your screenshot
looks like you set upper to expanding instead of preferred
Hey does anyone know how to make a window with "X" button only in pyqt? Like this:
create a frameless widget with a widget across the top with that contains a label for the title and a button
connect the button to widget.close()
That's what im trying to avoid actually, is there no way to make something like that without creating frameless window?
why are you trying to avoid it?
it takes like 10 minutes tops
thats a qMessage box
maybe you could hack on that
can anyone tell me what to learn after tkinterr for gui dev
I've never used it
Unless you have a really good reason to want to learn Kivy over Qt i'd strongly suggest learning Qt
Kivy is a pain to work with in my experience
Qt has a learning curve but once you learn just a little bit you have so much more flexibility to do things how you want to do them instead of looking for some tkinter hack
if you haven't noticed a large majority of the questions here are about tkinter
and its not because its mega popular
need help with a gui i've created, i want to restart the GUI with a push of a button, i did some research and found this code snippet ```def restart_program():
try:
p = psutil.Process(os.getpid())
for handler in p.open_files() + p.connections():
os.close(handler.fd)
except Exception as e:
logging.error(e)
python = sys.executable
os.execl(python, python, '\'{}\''.format(sys.argv[0]))```
but i get this error
Process finished with exit code 0
when i push said button
when i research that error, i found info that implies that i'm trying to close the program from outside of it.
what framework?
i'm using pysimplegui if that's what you mean
the gui is opening an excel sheet and modifying certain cells
@dire sinew
import itertools
import sys
import time
import os
i = 0
started = False
print('Open')
def on_close():
python = sys.executable
os.system(f'{python} {__file__}')
global started
started = False
sys.exit()
for i in itertools.count(0):
if i == 20:
print('closing')
started = True
break
i += 1
time.sleep(0.05)
print('closed')
on_close()
that works for me
thanks @eager beacon
did you try it?
curious if it works in an event loop
I just tested with that for loop at the bottom there
copy the on_close stuff to your button press I guess
you don't need started or sys.exit()
is the line with __file__ the file you run to start your gui?
i'm using pycharm and just running the code from that
is it your main file though?
the one that kicks everything off and launches the gui?
you might try printing __file__ to see what its coming up with
ok
you need an absolute path i believe
and assuming you're on 3.4 or newer __file__ should provide that
printing file gave me the correct path to my py file
i have the function def outside of the button press, and i have the for i in itertools code in the button press
you don't need the for loop at all
i was just using that to keep it going to see if it worked
the on_close() function should be what your button connects to
and you only need the _open() function if you want to kill the original process
import os
from PyQt5 import QtGui, QtWidgets
from PyQt5.QtWidgets import QPushButton
class Widget(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.layout = QtWidgets.QGridLayout()
self.setLayout(self.layout)
self.b = QPushButton(f'{os.getpid()}')
self.b.clicked.connect(lambda x =os.getpid():self.on_close(x))
self.layout.addWidget(self.b)
self.pid = os.getpid()
def on_close(self,pid):
self.pid = pid
self.b.setText(f'{pid}')
python = sys.executable
self.destroy()
os.system(f'{python} {__file__}')
self._open(pid)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = Widget()
w.show()
sys.exit(app.exec())
this works in pyqt
this is all super hacky
why do you want to do this?
i realized while i was coding the GUI that after the user would input the new data to the excel spreadsheet, the only way to add a new row of data would be to restart the gui, or am i not thinking this through correctly?
you are almost certainly missing something
I can't imagine that you couldn't extend a table widget row count after it had been created
I've never used pysimplegui though
next time use pyqt and I may be able to help
lol
oh, so its not even a table widget?
its just a bunch of inputs that get turned into a row in some spreadsheet?
yes
so I have to ask, why is restarting the gui the only way to update the spreadsheet?
i didn't think i could make it go to a new line after the user inputs the data from the first button press
why not?
i'm assuming i can then. I'm a noob at this
What makes it go to a new line when you start the gui?
hopefully this is just a fun exercise and no hospital will come near this tool 🙂
oh its called a hospital because of all the bad PCB's that have failed testing
81
if you want to post it here I can take a look and may be able to point you in the right direction
import PySimpleGUI as sg
from openpyxl import load_workbook
from openpyxl.styles import Alignment
import os
import sys
wb = load_workbook(filename='Hospital QNs_Status.xlsx')
sheet = wb['QNs']
new_row_location = sheet.max_row + 1
center_aligned_text = Alignment(horizontal='center')
def on_close():
python = sys.executable
os.system(f'{python} {__file__}')
global started
started = False
sys.exit()
print('Opening user interface...')
sg.theme('Dark Blue 9')
layout = [[sg.Text('Enter QN # here', size=(15, 1)), sg.InputText(do_not_clear=False, key='-OUTPUT1-'),
sg.Button('QN #', tooltip='Press to enter data to workbook', key='-IN1-')],
[sg.Text('Enter Product P/N', size=(15, 1)), sg.InputText(do_not_clear=False, key='-OUTPUT2-'),
sg.Button('Product P/N', tooltip='Press to enter data to workbook', key='-IN2-')],
[sg.Text('Enter status of job', size=(15, 1)),
sg.InputCombo(('OPEN', 'IN WORK', 'WAITING PARTS', 'Waiting Planner', 'COMPLETE'), key='-OUTPUT3-', size=(20, 1)),
sg.Button('STATUS', tooltip='Press to enter data to workbook', key='-IN3-')],
[sg.Text('Enter the defect step', size=(15, 1)),
sg.InputCombo(('MTP', 'ATP', 'VIBE', 'ESS', 'HIPOT', 'LEAK', 'NFF', 'INSP'), key='-OUTPUT4-', size=(20, 1)),
sg.Button('DEFECT', tooltip='Press to enter data to workbook', key='-IN4-')],```
ugh
new_row_location = sheet.max_row + 1 should probably go at the end of your submit function
assuming it passes, add a new row
or you could throw it at the beginning and create the row and then enter the data into the row after its been created
at the beginning means the beginning of the submit function instead of adding a new row after every submission
that way, if its near the beginning you won't have an extra empty row in your spreadsheet
this is the code for the button presses
while True:
event, values = window.read()
if event in (sg.WIN_CLOSED, 'Cancel'):
break
if event == 'Submit':
wb.save('Hospital QNs_Status.xlsx')
if event == 'RESET FORM':
on_close()
elif event in '-IN1-':
qn_entered = values['-OUTPUT1-']
sheet.cell(column=1, row=new_row_location, value=qn_entered).alignment = center_aligned_text
elif event in '-IN2-':
pn_entered = values['-OUTPUT2-']
sheet.cell(column=2, row=new_row_location, value=pn_entered).alignment = center_aligned_text
elif event in '-IN3-':
status_entered = values['-OUTPUT3-']
sheet.cell(column=3, row=new_row_location, value=status_entered).alignment = center_aligned_text
elif event in '-IN4-':
defect_entered = values['-OUTPUT4-']
sheet.cell(column=4, row=new_row_location, value=defect_entered).alignment = center_aligned_text
elif event in '-IN5-':
causes_entered = values['-OUTPUT5-']
sheet.cell(column=5, row=new_row_location, value=causes_entered).alignment = center_aligned_text
elif event in '-IN6-':
notes_entered = values['-OUTPUT6-']
sheet.cell(column=6, row=new_row_location, value=notes_entered)```
oh
its not even a function
this gui framework is strange
you should be able to put the new_row_location line right betweenif event=='Submit': and wb.save('Hospital QNs_Status.xlsx')
well, i'm new to all of this, just started learning 3 weeks ago
if I'm understanding everything
well honestly you dodged a bullet by steering clear of tkinter
i started on tkinter, and then discovered pysimplegui
horrible docs and a weird api makes for a difficult learning process for people who are just starting out
well now you know about pyqt5!
or pyside2
i'm not picky!
they are exactly the same for every reason you would care about
ok i will move the new row location
try entering 2 different entries after to see if it worked or not
nice
it works
that was so much simpler than what i was trying to do
thank you so much!
is it possible to make a button in tkinter to make a while loop that never ends, UNLESS they press a stop button or something that stops the app with:
quit()
is it possible to do something like that?
just asign the quit() function to a button
from tkinter import *
root = Tk()
Button(root,text="Quit",command=quit).pack()
root.mainloop()
yes
yeah
from tkinter import *
root = Tk()
Button(root,text="Quit",command=quit).pack()
root.mainloop()
@digital rose can't you do like do mainloop() instead of root.mainloop()?
whats the diferrence?
mainloop() is a method of your tkinter application, you need to associate this method with his object. The method allows basically the application to receive informations/events from the mouse and keyboard @digital rose
One application Tk() can have multiple runtime Toplevel() child windows. You need to call mainloop only once. Mainloop() is listenning to events like open a new window, destroy a window, click a button....
Hi, I m new into python programming and i would like to know if anybody uses a simillar software as scenebuilder (java) but for python tkinter ?
i heard of Page, is it efficient or you prefer the "good old way"?
Qt question:
I'm displaying numbers inside a QSpinBox, but is it possible to set length of numbers? So 0 = 00000000 and 1 = 00000001 and 2 = 00000002
The SN field should always have 8 digits inside of it
Leading zeros
Hi
Hi, I m new into python programming and i would like to know if anybody uses a simillar software as scenebuilder (java) but for python tkinter ?
i heard of Page, is it efficient or you prefer the "good old way"?
@digital rose ?
yeap
@digital rose can't you do like do mainloop() instead of root.mainloop()?
@digital rose If you have one window makeroot.mainloop()but If you have multiple windows you will make justmainloop().
yeap
@digital rose I think there is software help you make programs layout in python
but everything in script is better
okay thx for your answer
you're welcome
hi, I'm using a tkinter GUI and pyinstaller, but whem I close the window the app still running in task manager, so many times as I open it, aways will open another one and I need to finish the process by hand, one by one
how can I close it from the script?
already tried sys.exit()
hmm i just use exit() by itself
I got an error
oof
can't run script, something like that
hmm can you send the problem code?
wierd, where are you using the exit()?
last line
after mainloop()
oh I think I figured out
there is a Thread in my script
I commented the Thread.start() and it finished
ahh ok
I don't think that's possible with threading
Well not directly
You've got to do something with daemons
that's one reason why I started using multi-processing instead of threading
sorry to interrupt, my tkinter thing is kinda messin
I have a button that i press in the LoginPage class that then calls checkLogin
Then i have a label in MenuPage that i want to change to "second str"
but when i call setUserInfo from checkLogin the tkinter varibales doesn't update, its still "first str"
class LoginPage(Frame):
def checkLogin(self,controller):
caller = MenuPage(self,controller)
caller.setUserInfo()
class MenuPage(Frame):
def __init__(self,parent,controller):
self.infoVar = StringVar(parent)
self.infoVar.set("first str")
label1 = Label(self,textvariable = self.infoVar)
label1.pack()
def setUserInfo(self):
self.infoVar.set("second str")
heres the sample code, any ideas why infoVar isn't changing to "second str"?
that's one reason why I started using multi-processing instead of threading
@void nest thx, I will look for it
and thx @crystal sentinel
^v^
Anyone know how to convert new_time to 12 hour time?
Current output
setDisplayFormat does not work
what did you try @silk basin
@eager beacon currently writing a function to convert my 24 hour time to 12 hour time
but whats the problem?
I thought there would be a function already built in python to simple convert that time to a 12 hour time format
yeah I literally just finished writing a function to do it for me
@staticmethod
def convert12(str1):
time = ""
# Get Hours
h1 = ord(str1[0]) - ord('0')
h2 = ord(str1[1]) - ord('0')
hh = h1 * 10 + h2
# Finding out the Meridien of time
# ie. AM or PM
Meridien = ""
if (hh < 12):
Meridien = "AM"
else:
Meridien = "PM"
hh %= 12
# Handle 00 and 12 case separately
if (hh == 0):
# print("12", end="")
time = "12"
# Printing minutes and seconds
for i in range(2, 5):
# print(str[i], end="")
time = time + str1[i]
else:
# print(hh, end="")
time = time + str(hh)
# Printing minutes and seconds
for i in range(2, 5):
# print(str1[i], end="")
time = time + str1[i]
return time + " " + Meridien
lol
was that useless
100%
print(new_time.time().toString("h:mm:ss ap"))
when you called time())
you were not referencing QDateTImeEdit anymore
its a QTime object
setDisplayFormat only affects what you see in the UI I think
holly crap I couldnt find any documentation on taht
you are a wizard
PyQt and I have a love hate relationship when it comes to its documentation
I looked at both :/
also, never ever ever write your own date time code
there is a 99.999999% chance you will mess it up
figures lol
date time stuff is some of the trickiest stuff to progeram correctly
you wouldn't happen to know how to make the am/pm Capitalized with one of your ingenious 1 liners ?
I'm sure you're a lot quicker to write code now than you were a month ago, right?
It is insane how big it is
it's because its used in embeded iot stuff, and digital dash boards and 10000 other things other than a desktop app
its like an OS in a box almost
That is insane
It is coming along real nice
yeah it is a semester long project. Like the Professor literally just said "create a note taking app"
so thats what I have been up too
how did you all decide to store the notes?
I decided to do it in QSettings
it was very simple
once I figured it out. Everything you input into QSettings is key'd
and it has a very convenient "retreive keys" function
yep
yep
this is my favorite note taking app
We are an indie app development company focusing on building high-quality productivity and educational apps.
steal some ideas from it
when we finish project for our final submission Ill make my github repository public and let you download the executable
so you can see source code and how everything works. It will also have detailed documentation.
Oh lmao
sounds good
getting the exectuable working is impossible
pyinstaller is the dumbest thing I have ever messed with
we are just having lots of compatablity issues
we are on 3.8 :/
pyinstaller that is
you have to do a ton of stupid stuff to get it working in 3.8
I honestly don't even remember what they are
but its well worth downgrading python to avoid the hassle and googling
would there be any issues downgrading?
not unless you're using some feature that was added in 3.8
okay cool
Yeah it is kinda amazing
Ill relay the information back to my members
you have been so much help. The projects final submission is due tuesday
thursday*
oh
can you use libraries ?
or are they restricted?
if you can you should take a look at this
instantly make the app look better with like 3 lines of code
we can use that and I have looked into it but we didn't know if that would work
how could we implelent that?
its literally only this
So that would just go in our main?
yes
its the easiest thing you can do to improve the ui
^
pip install qtmodern
i like the second option better
okay ill try it in a bit
@eager beacon
This is how my teammembers have this set up
what does APP do?
there aren't a ton of great reasons to subclass QApplication
either way
Lol i gotta ask my team members I literalyl have no clue. They changed all this last week
so this is something called app.py
and then in our main.py
^ this is the entire main file
so I think App is the whole program
I see
it's customary to name that something that makes sense
like MainWindow or Window
yeah I don't know my teammebers do major refractors without me even knowing lol
its so random,
how do you guys divy up the work?
Github issues
We have weakly meetings and decide on what issues we need to implement and then go from there
you can make the UI look a bit nicer if you want to set an app palette to override the button text color
or you can use a stylesheet
One of our team members has had an internship for 2 years now so he is very 'professional' and our git hub is very organized. We use pylint and use code freezes idk hes going way to hard
I like to think of what a linter says as a suggestion 🙃
lol
how can i make a camera application with tkinter without using opencv?
there is much more use
for image recognition
such as a program with tk + webbrowser, going to open chrome://newtab when the face is correct
alright, so i'm trying to make a responsive thingy, and this is what i've got
endx = shotgunbutton.winfo_x()
diffrence = endx - Game.winfo_width()
for button in buttonarray:
xbutton = button.winfo_x()
ybutton = button.winfo_y()
button.place(x=xbutton-diffrence, y=ybutton, anchor=tk.NW)```
shotgunbutton = rightmost button
It is possible to change the titlebar color in pyqt? jut the color of titillebar without affecting it's buttons?
but only the bottom buttons move and the shotgun button moves?
is there like a way to track how much to window changes size?
@digital rose you have to make your own window from a frameless widget to do something like that because the windows are controlled by the OS
pretty neat for tkinter
Thanks! I've been working really hard on this game for a long time!
what kind of game is it?
like a platformer shooter kinda game?
if you want to play it, i can send the gamejolt link
I tried launching the game but I can't seem to start it or click on anything
am I missing something?
ah, okay got it working
@inland notch can you make it for mac too?
i need help in the ios application pythonista... I want to learn more about the ui module
wdym?
i have a question: What is the best gui library for python?
is pyqt5 good?
never heared of it
@velvet garden PyQt5 comes with a designer tool so you can move the button with cursor and drag and drop widgets without any code so its much easier
ill try pyglet
i do
but it is a png
of a png
png.png
it's just empty
i need help in the ios application pythonista... I want to learn more about the ui module
If you need help, why don't you ask something?
So I have a Py. file I will call that 1. In 1 there is a Tkinter window. In another file called 2. I want to add a button on the Tkinter window in 1. How do I do that? pls answer me it been a month and I can't find the answer.
@eager beacon
What have you tried?
So I have a Py. file I will call that 1. In 1 there is a Tkinter window. In another file called 2. I want to add a button on the Tkinter window in 1. How do I do that? pls answer me it been a month and I can't find the answer.
Hi, quick question: I've been using the bar and Labels from ipywidgets to keep track of long computational tasks. But I see that sometimes things "lose rhythm". Does the update of ipywidgets compromise the computational performance?
@inland notch can you make it for mac too?
@velvet garden I don't think I can lol
did you use only tkinter for that?
@modern marsh for the gui? yeah. but I used pygame for the audio because tkinter can't do audio
@uncut pawn I don't know about tkinter well enough but assuming it has some sort of callback behavior you should be able to import 2 into 1 and connect a callback from whatever triggers the button to be created
@uncut pawn most people in this channel judging by the huge number of questions about it
tkinter is not bad, no
I made a game with tkinter
It's fine
I mean like
it does have it's limits
audio for example
and perfomance
Any ideas how to use open CV to focus camera on one open object at once and ignoring other objects ?
f
okay im gonna ask again
i need someone to just teach me some of the basic stuff in pythonista 3 ui module
there's actually a great website where you can find people that can teach you this stuff!
and where's that?
yeah
https://gamejolt.com/games/WidgetsGears/530598
@inland notch is this made in python?
anybody??
?
you can use "width" or "wraplength" parameter if you are using tkinter
@inland notch is this made in python?
@digital rose yeah
Anyone know how to store the click of a button as a string?
what do you mean
a button state is bool not string
do you mean store the input of a text feild onclick?
@granite drum
idk
im new to this
but yeah i need to store the input onclick
@digital rose
for example theres a numpad on screen and i need to record data thats typed into it
okay what are you using? it it just pure javascript?
or are you using python backend?
usually what I would do for that is add an id to the tag of the input text
and get it dynamically in javascript code
@granite drum
@granite drum how’d you get your video to be so smooth and HD
I'm not so good at tkinter which is what I assume you're using
@digital rose I know a lot of tkinter
any question about tkinter just ask me
@granite drum how’d you get your video to be so smooth and HD
@ornate tapir he was recording using shadow play
this sortware for nividea cards only
Anyone know how to store the click of a button as a string?
@granite drum ?
store ?
You mean bool prop?
it's just call a function when it is clicked
from tkinter import *
from tkinter import ttk
root = Tk()
def clicked():
Label(text="clicked").pack()
btn = ttk.Button(root,
text="click me", # The text on the button
command=clicked) # This is for call fumction when it's clicked
btn.pack()
root.mainloop()
Output:
Output when it's clicked:
and as you see I can re click the button and I will have this:
call the func when it's click one time
re click = re call the function
there is another ways to call the function
there is the .bind and more
but the command option is easier and good
@granite drum
Hey - I have the following problem:
My group and I, we need to program a software artifact, evaluating people based on text passages provided in an online assesment tool.
We already considered naive bayes but are still looking for an applicable algorithm.
We are focusing on the character traits "openess" & "neuroticsm" (read from unstructured text)
We will conduct a survey in order to conduct a dataset - because there are not enough german sets for training the algorithm.
We want to include regx, looked already at nlp-algorithms, but we aren't sure, which algorithm is the best one to integrate (in terms of time, ressources and difficulty)
The Project needs to be finished in january.
Looking forward to your feedback! 🙂
hi
You mean you want a software like the discord software ? @livid zodiac
online chat ?
More of an applicant online assesment. So Company XYZ offers a position. Person applies. And the algorithm checks the text provided by the applicant for character traits like openeness
e.g. He / She writes: "... I like to go out with friends", the algorithm ranks it as "Openess" and ranks the applicant for 4/5 openenss
someway like that
ah
I know now
Algorithm
I'm no thing at algorithm
you have very advanced problem
sorry I don't know the solution
but this channel is not for Algorithm
thanks alot!
Can you have a tkinter button that's just text?
ah I don't make any thing but you're welcome @livid zodiac
Can you have a tkinter button that's just text?
@inland notch Yes
FLAT
could you give me a code example?
yeah i will
sec
from tkinter import *
root = Tk()
btn_flat = Button(root,text="Click me",relief='flat',bd=0)
btn_flat.pack()
root.mainloop()
@ornate tapir use nvidia geforce if you have an Nvidia gpu
still a background. is this fixable?
@digital rose can you help me improve my code?
some bricks?
yeah like the alpha brick
what's an alpha brick?
this to make some transparent
how do i make an alpha brick?
make a function
sec
I will send the code
root.wm_attributes("-transparent", True)
root.config(bg='systemTransparent')
then add it for the bg of the button
from tkinter import *
root = Tk()
root.wm_attributes("-transparent", True)
root.config(bg='systemTransparent')
btn_flat = Button(root,text="Click me",relief='flat',bd=0,bg="systemTransparent")
btn_flat.pack()
root.mainloop()
Windows
Can you do it for windows?
yeah I think
do you
know how?
in wndows no
but
you can make the window alpha
root.attributes("-alpha", 0.5)
in windows
cool
but that's not what I want to do lol
@inland notch ah okay
there is articl for that
saying
Tkinter frame transparent background
Transparent background in a Tkinter window, There is no cross-platform way to make just the background transparent in tkinter. You just cannot set the transparency of the frame in tkinter. But you can set the transparency of the whole window with root.attributes ('-alpha', 0.5) You can also do root.attributes ("-transparentcolor", "red") if you are using Windows, but again it will be applied to the whole window.
in tkinter i put this string on the screen
but it shows like this
how can i fix that?
even if i remove the buttons, its still like that...
im trying to make a tictactoe game
and im trying to make those barriers between the x's and 0's
hmm I don't think this is the better solution here. You can for example play with "borderwidth" parameter on buttons or labels (i dont know what's the widgets you are using here) to make like a table.
there is a lot of example of this game made in python, you should look on github for example
it would be easier i think
yeah, i don't want to just steal someone else's code
hmm using librairies made by other is stealing ?
try to understand the solution and then you are not simply copy
ok
"good artists copy, great artists steal" Picasso
Whats the best gui tool to use for my usecase?
I need text that I can place wherever I want
I need buttons that I can click on that just run functions I make.
@digital rose User tkinter
lol i said that wrong
use tkinter
tkinter a gui library
super good
I just got pinged 3 times in general telling me to use tkinter
I guess im using tkinter
Can you make an nice looking modern ui with tkinter?
whaaaaaat is this @digital rose
😂
what
the string prop
you make it art
idk lol
there is better way
the canvas
im making a photo in photoshop rn
but there is canvas
for that
you can darw with canvas rectangle and lineand Shape
is it hard?
no
easy
ok
yeah