#user-interfaces
1 messages · Page 83 of 1
I would go into detail, but that is a very dangerous thing you can easily messup, you'll want to consult package development best practices
it works with anything written in python, it is builtin
mm ok, i’ll go with it then
im not trying to do smth big
I suggest familiarizing youself with venv before getting into pyinstaller
it’s just a mini project for my mom
that will keep you from accidentally compiling something huge or destroying your native env
i know venv
i usually do that for mini projects
okay, if you know venv then what you want to do is lookup the pyinstaller docs and search for the onefile flag
that is what flattens python into executables that do not require python to be installed
it tells pyinstaller that you want to compile the package not into a wheel or a distribution, but a single executable file. you should be able to ctr-F or grep it from the docs
oh
I don't want to give you the actual shell command for it, I'd rather you find out yourself so I can't be blamed for something horrible. lmao
yep
np
kk
that one is tricky
it depends entirely on the formatting of the pdf, pd'fs are spatially defined colormaps, and having scrapable text is entirely optional
so some pdf's you can just pull the text out simply, others you have to do like, color and font detection if they are just flat image scans
mm i dont think it is with img
from my experience. I didnt get much farther than that
let me show you
I never really tried to pull from pdf's, I was trying to generate them from docs, so my experience is likely counter-intuitive to what you are trying to do
oh
sorry, lol
👍
🙏🏼
Hey guys! Hope all is well. Does anyone by chance know to set a path for an icon in tkinter that will be universal so other users that install the application are able to load it?
This snippet is working for me...
wondering if there's a way to do something relative to the user like
hopefully this makes sense... Thanks!
you could set the path as a global, but that is not generally considered kosher
that can complicate permissions level issues if you have multi-user environments
or wait, is this for like, a pseudo environment?
I am making a soduko 9x9 in tkinter
And to represent numbers i ised 81 buttons with bgimg
.
I am thinking that when i press a number from keyboard the image with that number should be displayed in that button bg ing so any idea how i can do this without having much effort for binding 81 buttons seperately
I have made each button as sep var brc, ie button row column
To pack buttons i have made a for loop
What is your code
!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.
Oh no not that again
I just need to know that which button ipressed cuz as per that i will change hg image of that button
If I do not see your code, I cannot help you🤷♂️ Im no magician
Thats what problem i have
You could easily do that with the button callback
Yes but idont know how to use it
Can u yell example
Cuz in that program i have 81 buttons ie 81 variables 😂
thats very bad
Yeah but i cant able to think to manage
Uff bad network cant even upload an image
Are u taking about root.bind function?
No, just the normal command
Get the idea from this:
from tkinter import *
root = Tk()
def change_name(row,col,btn):
btn.config(text=(9*row+col)+1)
for i in range(9):
for j in range(9):
btn = Button(root,text='Random Button')
btn.grid(row=i,column=j)
btn.config(command=lambda i=i,j=j,btn=btn: change_name(i,j,btn))
root.mainloop()
Thanks i got the point
😃
But idont k ow why sometimes making so many buttons with loops sucks in tkinter
what?
Yeah earlier i made buttons in two nested for loops
I got images for only last button
Because you are overwriting each image with the old one
@tawdry mulch can configure and bind go with the same buttons?
Likewise i am currently increasing the numbers from 0 to 9 thenafter 9 back to 0
So i am thinking to bind button with the number key i press so that i get the number displayed i pressed
Currently this much progress has been done🙃
I am thinking to keep working on this 3rd tkinter project
bind and config is different. So they can go with each other
👍
@tawdry mulch i forgot to clewr one doubt
what config doing at back
Is it creating a new button and placing above the last button
Or
Its modfying that button
Modifying the existing button
So i used keybind event it seems like it works after tab has been pressed
I searched somethings in docs but its just simple one page
Nor even told what we can type in sequence
What do you want in sequence
I mean like i puted moise pointer on a cell and after pressing a number key it changed the image to that number i pressed
Cureently i know only some methods like
Button 1 2 3
Enter leave
Focus in out
Return
Use event <KeyRelease-Tab>
For now i have defined a func click which returns the event and i print that event
Is this link is only docs by the python for tkinter
https://docs.python.org/3/library/tkinter.html#bindings-and-events
No, there are many
Describes the Tkinter widget set for constructing graphical user interfaces (GUIs) in the Python programming language. Includes coverage of the ttk themed widgets. This publication is available in Web form and also as a PDF document. Please forward any comments to tcc-doc@nmt.edu.
Same as whatever is there in the original documentation given by John Shipman from NMT, but made into a website
👍
What did you use?
This will execute click after the key is released
On pressing tab nothing in my terminal showed excpt \n
Dk, have to see more code.
What you are doing is same as btn.bind('<KeyRelease-Tab>', print)
Oh yeah
But it is somewhat different😂
Lmao i now thinking how to acess the buttons
Why, which button
I mean if u are playing soduko and if u are putting value of 9 and it is currently set to 1 then u will be clicking 8 times to reach 9 and if u pressed more than that then more clicks
Haha less soduko more clicks
I can see that tkinter is noticing where my moise button is
Is Sudoku and Soduko same?
Is that the approach you are using?
Yeah its a feature 😅
Its not really a good feature.
Why dont you use Entry
Yeah seems like i need to say that if pointer is one that widget enters and then some num key is preeesd then change num
Or you could use an Entry widget...
It does what you just explained😂
Is enter amd entry are same?
No, entry is a widget where you type. Enter is an event.
Oh then i think i will use entry with combination of key
Like i will be first binding with enter and then woth key
Why....
Because enrty i kind or a mess like if i was to enter values then i had made 81 widgets
But then againg thinking that how i will contril the button like which button needs to be updated
Follow a tutorial, they will have neat methods
How did you create gap between the widgets
Thank Discord 😛
I just said if the row or col gives mod by 3 to 0 then give pad for both x and y by (0, 10)
If row gives 0 then for row if col then for col if both then for both
That was my idea too, anyway share some code when you have time
Image is enough for now, just want to see
Ohk
I have this now @sinful pendant :
for i in range(9):
for j in range(9):
if not i%3 and not j%3:
print(i,j)
Entry(root,width=5).grid(row=i,column=j,padx=5,pady=5)
else:
Entry(root,width=5).grid(row=i,column=j)
Pretty sure you can save 50 percent space more with more loops
yea and also their lists
Yeah i have idea about it not trying as thats not my priority
For now functionality is priority
I thinking to make it as a whole app with some other nxn sodukos
Hmmm yes
Wont forget u to show the result
Sure!
correct me if I'm wrong, but here I have two frames with scrollbars.. so I was wondering how do I go about adding a main scrollbar (if I needed one)?
You cannot add scrollbar to a whole window, per se
It is like that....?
okay xD
You can put a canvas for the whole window then put scrollbar to it.
Cool! Thanks!
hi. I have coded a text form like html file and now i want to import the text written in the form in python
which is the easiest way
I have heard name of Django flask etc, but they have many complex things in them which I don't need now
can anyone tell me the selected topics I need to study now
This seems to be the wrong channel for this, maybe try #web-development ?
btw how'd you perceived them to be complex if you haven't worked with it?
you surely can but #web-development would be better for this one
by seeing an introductory YT vedio and documentation of Django
At both places all was mentioned about complex backend jobs like views, urls etc
i'm not that good with web interface
but for my project I need only the part where the input text is transferred to my python code(the data like name class roll no and admission no which I will then store in a SQL database)
so which framework is best for this simple task?
@pliant dagger
@tawdry mulch i dont think bind is a good way to do what i told you seems like i have to go for configure
Also i cant able to get that work dk that can multiple config will work and also how i will make them work with the key i pressed
@sinful pendant do you have any idea of my problem?
Currently i know only tkinter framework
What are you doing
When i hover over a button and press 5 the button shows 5, if pressed 8 then button shows 8 etc
I tried so many but none of them work
I tried 2nd config and seems that only one config needs to be there
I told you to use an Entry widget right...?
there has to be a better way to do this
Aah man u dont k ow how i managed to do this much
Yeah but i have used images on buttons
Bruh my sucking net
Try if something like this works for you....
from tkinter import *
root = Tk()
def callback(e):
wid = root.winfo_containing(e.x_root,e.y_root)
if wid is not None and isinstance(wid,Button):
try:
num = int(e.keysym)
wid.config(text=num)
except ValueError:
pass
for i in range(5):
for j in range(5):
btn = Button(root,text='this is a button',width=15)
btn.grid(row=i,column=j)
root.bind('<Key>',callback)
root.mainloop()
duh
Basically just trying to get it so the installer will allow users to load the icon. It's a pretty basic custom calculator.
Include the image with the py file and use relative path, like if the folder is named C:/GUI and py file and image is inside it and you are running the file from inside 'GUI', the relative path of image will be something like: 'imagename.png'.
Thanks! I'll give that a try!
Omg genious man
I was so mad that i was searching something for it in the code files
Can i give a smol description that how u find/did it
??
I was finding the solution in the init code
I can understand bits that what ur code doing
Nice
U said that let widget at place x,y be wid
And if wid is a button
Then try int of e.keysym
And changing the bgimg if no valueerror
I read thatwinfocontaining def in init
Haha but code also dont gets i to my brain
Don't read that, use the docs
Docs is somewhat a bit non understanding to me idk why
Like if i am giving description about button i will tell functions attributes and other methods fully here
And in docs all these things dont gets into mind
It's also given in docs, not all methods will be given in code
Can u send link of that docs
I did already, scroll up? Not infront of a system now
Ohk then i have thise ones
Just a minor thing left in that
Since i able to display the image but i not able to update soduko as it requires row and column
What do you want to update?
You want to get the row and column of a button?
Hmm pretty sure there is something.... Try grid_info or something, not sure if that's the name
Ot has but it shows something else when i print it
I found one
Grid_location
But in doc string it says returns tuple and giving me nothing
After bit of frustration problem solved
Ah great
I need some help with a TUI i was trying to develop
Is this place right?
can someone send me a tutorial on creating a Emailing service
dm me
I tried to read the email standards documentation once. I would advise against the idea of managing or creating an email service. lol
why
because emails are clouds or various tags that define themselves and half of the giant standards book was optional but could happen at any time
what
that didnt make send
sense
im a web dev (for context)
neither does setting up your own email service, just pay for hosting
?
email servers are just parsers that make sense of what the last email server assembled before sending it to the recipient. the more 'Lite' you make it the more likely you are to miss something on the email.
good luck with that
i mean
i need somthing to learn about it, your thowing shit at me i dont understand
idk how they work
i cant find anything on them
my guess is i encrypt the bites then send em off
as i would a chat app
sorry, don't mean to be negative, email is an old standard at this point and not every email server is upto date, so making it lite generally means not having backward compatibility in the formatting standards
lol, i dont know half of what u just said but sure
so you could still receive emails, but not all the content would get read in
Guys, this is not related to a UI, so please take it some other related channel.
yeah or the body might not be where you are expecting it
its related to all
web, ui, os
you're right, my bad
When did email service be related to UI
since u can make one with a ui
this is more of a communication protocol thing, not a UI thing, users dont interact with email services, just their frontends
I have a prblm with kivy can some1 pls check #help-croissant
dm?
sent
Pls some1 help
Hi guys, can anyone help me with a rendering problem with qtile wm?
@tawdry mulch i want to ask ir opinion that how i create the different sections in my main window
.
Like at bottom of menu bar i am in solving working space so this seems like this where side bar is just some tools i gonna add later
.
I wanna ask taht like if i added a new workspace in menu to make place where i can design soduko etc then how should i go
Use frames
So then at the end i will bind with frame instead root?
Bind for what
I mean when we change the numbwrs for that i have first binded it with mainroot
Yea it should be still fine
When i puted everysoduko cell in frame then bind didnt worked
But still i will be able to make it work
For now im just thinking about that
That like for now i have a workspace hwere we solve soduko
And i want to provide a workspace to make soduko
Which can be acessed through menus
But i am thinking that how i should implement it
As I said, frames
Or new window
I mean should i pack them inside a function?
Because the whole code i have does that it provides u the solving thing
Idh much context here, but you should be able to do it either way
I am thinking to go by def i think i should give it a rought try
I want to ask one more question related to tkinter working ,like it has root.mainloop() at the end so what that does
This i know that it prevents program to close
But when it reaches that line what happens after that if i do nothing
Hi mates I want to create some thing like this how to do please send some resources
It's like a loop, for the rest of code to execute you have to end the app
Framework?
If u are talking about tkinter widget for this then it is called spinbox
just for interface using simple css
oh that question is related to web interface
Yup
What exactly is it trying to say here? The signal is defined with system_sig = QtCore.Signal(str)
15:08:49 | main | CRITICAL | Uncaught exception:
Traceback (most recent call last):
File "D:\pycon\Auto_Neutron\main.py", line 91, in <module>
ui.startup()
File "D:\pycon\Auto_Neutron\auto_neutron\hub.py", line 62, in startup
self.setup_journal_follow(Journal(Path(...)))
File "D:\pycon\Auto_Neutron\auto_neutron\hub.py", line 58, in setup_journal_follow
self.active_journal.system_sig.connect(self.worker.update_system)
RuntimeError: method 'connect' vanished!
Did some here made a an app with tkinter, having various workspaces(more than 1) and used menus to acess them, i just wanna know how u did that
I already said right. Traditional way is to create a new window. A modern way would be to use new frames and hide/show the frames.
You can code this new thing inside a function or a class
Yeah frame is a good idea to pack those cells, i was trying that to work and now i got a solution to that i tried a small smaple of code and it works🙃
@maiden ridge Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!
If I am a really bad python programmer, should I use TK or something else
you should just learn python.
then learn the libraries, read the documentation
there isnt really one library better than another
you just pick what you need
its like asking if apples or oranges are better it makes no sense
you dont have to apologize lol. Personally if you ask me in terms of use case kivy provides interfaces that look gorgeous. Tkinter looks like it was made with Windows XP type software
I literally just wanna make a simple GUI that has buttons
that can add / remove elements at will
then tkinter will be fine
yes tkinter
is there a good resource for learning tk from the ground up?
documentations are there, video tutorials too. Depends on what your looking for.... proper understanding of concept or just to get the things done
I want a proper understanding
Learn how easy it is to use Tkinter and Python to build simple GUI applications with author Alan D Moore.Check out Python GUI Programming with Tkinter: https://amzn.to/37klJwd
Example code for this video can be found here: https://github.com/alandmoore/tkinter-basics-code-examples
Reposted this with higher quality rendering.
ty
Hey am trying to build apk out of kivy but when I launch it on my cell it crashes
how should i make the back button work
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.centralWidget = QWidget(self)
self.setCentralWidget(self.centralWidget)
self.generalLayout = QVBoxLayout()
self.centralWidget.setLayout(self.generalLayout)
self.next = QPushButton('Next')
self.next.clicked.connect(self.gotoNext)
self.generalLayout.addWidget(self.next)
self.show()
def gotoNext(self):
self.next.setParent(None)
self.back = QPushButton('Back')
self.back.clicked.connect(self.gotoBack)
self.generalLayout.addWidget(self.back)
def gotoBack(self): ... # HELP!!!
def main():
app = QApplication(sys.argv)
win = Window()
sys.exit(app.exec())
if __name__ == '__main__':
main()
How do I put my terminal(or output) in a label in tkinter?
Please dont give wrong/false information out like that
Label(window,text='WHATEVER') is how you would display the text 'WHATEVER' in a label, if you want to update a label, then labelname.configure(text='NOWEVER'), and it will change from 'WHATEVER' to 'NOWEVER'
what's the issue you're running into?
Do you have pyqt5 installed with the right interpreter? It could be that you installed it for a different python version
Is it okay to do something like ```py
class MainGui_SaveButtonFunctions:
@pyqtSlot()
def save_button(...):
...
...
class MainGui(QMainWindow, main_gui.Ui_MainWindow, MainGui_SaveButtonFunctions, MainGui_CloseButtonFunctions, ...):
...
can anyone come up with a better code design?
anybody got any idea how to do a selection menu like this in kivy?
i basically have a bunch of graphs, and depending of what you would select in this menu, that graph would appear
ive been using tkinter to make a gui, but when i create a new page and import it, it sometimes just crashes the tkinter
this my code
def next_page():
root.destroy()
import new_page
what is new_page
nah i fixed it
hey, where do i learn qt designer?
like, can u suggest any youtube tutorials?
or courses?
Hi
in TKINTER ipadx and ipady gives me padding only on thr bottom and right side, How do i get it even on all sides?
all sides? what all side
ipadx will padding on the inside left and right and ipady will padding on the inside top and bottom
Does anybody know how to reboot/restart a PyQt GUI without making a loop
like something like py self.reboot() # closes the current gui, and opens a new one
I have a frame packing in grid how i can make it take full available space
whats the best way to make a modern ui in python?
Well... things get a bit odd here for python. It's prolly not the language you wanna work with to make UI's maybe you might wanna try C# or something like Java and if you really make it in python then maybe try QT, tkinter is a bit classy.
Im on tkinter right now @pliant dagger
Can i use some other language like c# in combination with python?
I'm not sure on that with GUI, maybe you can't use both on the frontend
I mean use python for functionality and something else for ui
I don't need python for front end
thats cool, no offense to tkinter it's really simple good but not much modern
Btw im making a desktop app
That probably wouldn't be too hard I think, just ask some geeks here later on
cause I'm not 100% sure
Alright thank u
😄
Uh ok
@sterile matrix thank you a lot
np
btw for future reference, that widget is called Combo Box or Dropdown Menu in most gui toolkits
yeah, the main problem was that i had no idea what to actually look for
sticky='news' maybe
It came out like this , it took the actual full place but not relative
Soduko is sticky='nse'
I have also ised grid.row and col config for both frames and also for widgets in thise frames
did you just call tkinter classy
Yep, it's not very modern but there are some workarounds
it's pretty cool
it is
relative to?
It means that the pink colour space in between the frames is that it is kind of a place of soduko frame
.
Currently sticky for soduko is nse so its right when i make nsw it mives to left but then crearing a blank space at right
I think i will prevent of windo being resized
Cuz when the window pops up the middle spaces is not there
so news does not work?
Nope cuz as per grid configuration inside soduko frame the columns seperates
hmmmm
Well i havent tried or got more ideas, will be doing this after 3rd oct, i got a big exam upcoming
For now u can only solve default soduko
😃
hmm okay, all the best
Does anyone know how to make a Qt GUI close and then re-open a new version of itself?
just rebooting or restarting the GUI
one way i can think of, one is to create another py file that runs this py file(restarter.py), and on closing the app, run that restarter.py file
I don't want to use a subprocess
It needs to close itself, then collect/delete everything it used, then re-open a new version of itself
once you "terminate app", you lost control over it too
What do you mean terminate app?
close the app
I don't understand
how do you run your app
By running it like anybody else would
what is the best way to create GUI?
python -m file.py
like, what libraries
yes, similarly like that, you can create a py file that will call python -m file.py
or if not python libraries, what other platform/language is the best for creating gui for python
Then what? Terminate the parent process that then terminates the child process?
Beginner - Tkinter. PySide
Intermediate - Kivy, PyQt, PySide
you dont have to terminate anything, once you class the app, it will terminate everything
Then I'll have 2 GUIS, and by the way, this is an expensive app to start up
so it will use too much memory with 2 of them open
by pyqt, do you mean qt design studio?
Kind of yes
I can give you an example using tkinter, if you want.
can you suggest any resources? I have been searching the internet for qt designer resources, but barely found any
With PyQt you cannot use QML I guess, but with Qt design studio, you can
The idea will be the same....This is a basic principle
for which framework
i currently don't have any
then decide? then maybe I can provide something
i mean, I'm building a webscraping application with selenium
and want to build the GUI with pyqt
well, qt design studio
i have used tkinter and pygame for building GUI in the past
but they seem to be unnecessarily long and convoluted
from tkinter import *
import os
root = Tk()
def on_close():
root.destroy() # In PyQt something like QCoreApplication.quit()
os.system('python mcve.py') # Keep in mind, this halts the thread like mainloop()
print('Hello')
Button(root,text='Restart',font=(0,19),command=on_close).pack()
root.mainloop()
i had to code like 200 lines of pygame to build the menu for a codebase of 100 lines
hmmmmm
Try the official pyqt docs, they do have everything
@plush stream Might be able to give some resources
can you link them? I couldnt find them on the qt website
It starts here https://doc.qt.io/qtforpython/
ah ok thanks
what's up?
can I import custom assets in qt designer?
so far, I have seen that to be the case only with qt design studio
I don't know unfortunately. I script my gui manually.
some pyqt resources for this fella, if you know any
custom assets like?
with pyqt? Isn't the cool thing about qt is that you don't have to code the gui and can just drag and drop?
button designs, etc.
Using qt designer will severely limit my ability to customise the internals of pyqt
The main reason i use pyqt in the first place is because you can literally override everything inside of it.
yea, i couldnt find tutorials on that on youtube
anyways, ig ill check out the documentation
Yep
If you want to customise the look of your GUI then look for qss
It's like css but for qt
Hi,
in PyQt 5 I want to provide an option to install from a directory or from a source archive. For that I tried QFileDialog.getExistingDirectory() but of course that allows only selecting directories. Should I use QFileDialog.getOpenFileName(), is there a way to allow selecting directories and archives (*.zip, *.tar ....)?
that is basically choosing filepath right?
yeah, that's right
filename = QtGui.QFileDialog.getOpenFileName(self, 'OpenFile') ?
no, then the user can select a file (for example a *.zip) but not a directory
You can extract the directory name from a filename itself.
i know, but if the user selects a directory? when clicking on a dir it enters the dir, you cannot select it, because it wants you to select a file
what else do you expect the user to select? You either give the user a change to select directory, or you give them a chance to select a file, which one...?
well, a directory then, but also archives, like *.zip, *.tar ...
if there is no option for that, then i would have to provide two context menu actions, one for installing from a project directory (containing source code) and one for installing from a source archive
i thought, maybe there is a possibility to treat an archive like a directory in QFileDialog.getExistingDirectory().
In every application there is a 'save' and an 'open' file right? If what you said was possible, they could just ask for a path and then decide if it is to save or open
in fact, both are directories, a folder and an archive (which can contain files and directories)
An archive, is a file.
install?
from a source archive
like pip does
you can install from a local project dir or from a local or remote source archive
so if an archive is a file, you get its path, not the path of the items inside it.
yes, the archives are something like project.zip
you can select it and pip will install that project
my problem is, in QFileDialog.getExistingDirectory() you cannot select files at all (they are grey and unselectable)
it is for selecting directories only....
so i would have to ask the user before opening the dialog, whether he/ she wants to install from a local project directory or from a source archive?
exactly
and accordingly you can use if and use 2 separate dialog windows
yeah, for one i'll go with QFileDialog.getExistingDirectory() and for archives QFileDialog.getOpenFileName()
Yep that should do
that's what i wanted to avoid
are you absolutely sure, that it's not possible to add a special case and allow archives to be treaten like a dir?
im not absolutely sure, but it seems highly unlikely that there is such mechanism
i was searching the whole evening on the inet, but found nothing
but i remember that in the past i had an application, where that was possible (selecting a target directory and also archives)
but unfortunately it's a long time ago
well thx, i'll look for a solution on the inet
Mmmm idk, maybe there is something. Feel free to wait till someone who knows answer
@plush stream knows some intense pyqt, maybe he can help
would be nice, thanks
Does anyone know about QWebEngineView in PyQt5?
self.vbox = QtWidgets.QVBoxLayout()
self.btn=QtWidgets.QPushButton()
self.vbox.addWidget(self.btn)
self.webEngineView=QtWebEngineWidgets.QWebEngineView()
self.url = QtCore.QUrl.fromLocalFile(r"C:\Users\orhan\OneDrive\Masaüstü\pyqt5\test.html")
"""self.webEngineView.load(self.url)"""
self.loadPage()
self.vbox.addWidget(self.webEngineView)
self.setLayout(self.vbox)
self.setGeometry(500, 500, 500, 500)
self.show()
def loadPage(self):
with open('test.html', 'r') as f:
self.html = f.read()
self.webEngineView.setHtml(self.html)```
what is it?
Which framework is it
Judging by the style, looks like tkinter, if then, add relief='flat' option to Button.
is pyqt the same as pyside?
Bit late. Practically yes, technically no, although similar.
- PySide is the official binding for Qt made by the Qt Company. It's licensed under the LGPL license.
- PyQt is another binding for Qt made by Riverbank Computing (a third party), it's licensed under the GPL license which is a bit more strict.
They generally don't have much difference in the syntax and code, which are basically interchangeable with each other, apart from some minor differences really.
So really the only major difference between both is their license and the companies behind them. Syntax remains practically the same for both.
alright, thank you.
I want to graph this code into my PYQT5 script..
I want to convert this code into class and which may be callable from my Pyqt5 script which I will provide N60 and Depth (lines above try:except) from PYqt class attributes..
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.figure import Figure
N60 = np.array([7.4,8.7,10.6,15.5,12.5,13.3,18.2, 18.2,19.0,19.8, 22.3, 21.5,23.1])
Depth = np.array([5,10, 15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100])
Depth_Lim = Depth[0:len(N60)]
try:
plt.figure(dpi=1200)
plt.figure(figsize=(2,6))
plt.plot ( N60,Depth_Lim)
# plt.ylim([5,100])
# plt.xlim([0,20])
plt.tight_layout()
ax = plt.gca ()
ax.set_ylim(ax.get_ylim()[::-1])
ax.xaxis.tick_top()
# plt.xticks (np.arange (min (N60),max (N60), (min (N60) + max (N60) / 2 )))
plt.xticks (np.arange (0,101,50))
plt.yticks (Depth_Lim)
ax.yaxis.tick_left()
plt.show()
# plt.savefig ('Test.png')
except Exception as e:
print ('Cannot Plot because',e)
Any helpful link will be appreciated...
actually pyqt cannot accept pyplot so what can i replace plt with?
#help-popcorn Claimed for help..
hey, how do i use an image for a button in qt designer?
I am trying to build an application that on login opens a tray application. it sends the message but does not sit in tray.
code:
https://pastebin.com/HxUYHSs2
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.
Does anyone know how to track keypresses on a QPlainTextEdit after it updates the display
so like for example they press the letter Q, and I can handle that after it registers that letter into the text edit
right now I'm using an eventFilter but that gets the key press before it registers into the text edit
How viable of an option are the asyncio Qt event loop integartions like qasync?
how do I add hover effects to my buttons in qt designer?
Not sure about in designer but you can make custom ones appear using hover events
what do you think, which one of those are more usable and why? tkinter or pyqt5?
Or kivy
lot of ways, why
Any good libraries to use for quick pop up mp4 videos? Don't say CV2 as I can, in no way, make it work on my comp. I want the vid to popup over my TK interface for 3-5 sec then close.
I've been messing with Pyglet but I can't seem to get it to close when the video is done. Consistently anyway without it crashing python randomly.
@azure talon have you tried Qt? I've heard it can play multimedia
PyQt. I have not. I will try it. Thanks.
anyone know of a responsive mit licensed chat template? i need it for a chat app but can't find one
Trying to choose the best GUI compatible with other licenses we have
So far it looks like Kivy is like Django, while Tkinter is like Flask
both are solid choices, to choose one of them 🤔
PyQT5 is thrown away due to license incompatibilities
Have a look into Wxpython as another possible choice.
So I'd like to build a game, I wanted to ask you guys which UI framework and language you'd suggest
My requirements are:
— attractive, modern 2D and 3D graphics
— distributable
— A high level, language, preferrably
Is there a Python GUI framework that seems these requirements? And if not, what else is there?
The go-to, especially if I want to be able to put it on Stream, would be unity, no?
Have you tried PySide2? It has LGPL licenses i believe (its exactly like pyqt)
I havn't tried any Python libraries really. You'd recommend PySide2?
I would not recommend PySide2 for any games, especially 3D, it's pretty good for general GUI development tho
But! I would recommend pygame for 2D games (there are 2D games on steam made with pygame especially dafluffypotato's), but for any serious 3D games with intentions in publishing it, go for Unity if you're a beginner but go for unreal if you're comfortable, would recommend C++ for them
Noted, thank you!
Anyone else have any thoughts?
worthy to try, thanks.
the licensing looks like a nightmare though
some parts in LGPL, some in GPL, some in Commericial
it looked dreadful from afar
anyone got knowledge about pyqt and stylesheet?
just ask your question
I try to specify a pushbutton with an image in a qss file.
QPushButton#pushButtonNewEmployee
{
image: url(:/icons/new.png);
}
like this
but it dont load, and i ask me why. If i try it in the main code with SetIcon it works
What if you try using QAbstractButton instead of QPushButton?
hmm yeah
didnt work
QAbstractButton:QPushButton#pushButtonNewEmployee
{
qproperty-icon: url(:/icons/new.png);
}
i tried this, and without the type selector
QAbstractButton#pushButtonNewEmployee
Ok with this i can change the color but it dont load the image ^^
o its the right button, but the image is the problem
not sure if this will work but try wrapping the :/icons/... path in quotes
ok, ehm i got the mistake and the brainless form 😄
first :/path/image is probably outdated
next ist, i use the css file path in my database -.-;
qproperty-icon: url(icons/new.png);
so this works without : and specialy an / at the front. i dont know what i thought -.-;
But thanks for the help 🙂
Yeah, it looks like lgpl which would be compatible choice for me
Powerful option
PyQt looks like... An ultimate thing
Like visual studio with c# and etc
Heavily thinking to go this way
yeah PySide/PyQt is pretty decent for UIs
PySide6 is the newest version
virtually the same as PyQt
Qt is great for ui-design, probably the best option for python
Here’s one of my latest works with qt5 for the gui.
Just message me if you need help with something ;))
Yup. All other Frameworks aren't having stable visual designers, so it is the only choice then for fast work
hey guys
i have a problem
i created a python program it has ui
basic ui
but when i run program it runs ui and not the program which i created
Hey @covert quest!
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:
can anyone help me with this code :-
https://paste.pythondiscord.com/ufewolufut.py
i am trying to create jarvis type thing named SkyBot
basically whenever i run the file it only shows gui and when i click on run it runs the gui but not the main_code() function
Hi all! I'm working on a project with Text() widget in tkinter and I need to highlight "bad" throughout the user input inside the text widget. Someone please help me how to do this.
hey anybody can check my ui please and suggest me changes https://techkynewz.com
I did not look beyond first page, but you could look in a bit tighting your security and perhaps learning how to cache stuff better
for example I found that you use Nginx 1.18.0 version with Ubuntu server
$ curl -I https://techkynewz.com
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Fri, 01 Oct 2021 10:48:08 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 10514
Connection: keep-alive
X-Frame-Options: DENY
Vary: Cookie
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
a bit of long time to load the page
anyway, just read the lighthouse report and fix problems perhaps. it mentions them with quite good description how to fix things
huh. even security alert on one of your libraries
yeah, as I thought, your static files aren't having client side caching declared
I was speaking about server side/web accelerator caching too though
Did you design that
How do you use good quality images in Qt? Whenever I load images using a pixmap the image is all pixelated, even when I repaint with antialiasing on
friend how do you change the top of window
I mean the close and minimize button and title bar
those are custom widgets i think
Can you let me know how to cache the css or js files
this book is for free, you know...
https://www.nginx.com/resources/library/complete-nginx-cookbook/
Can we hide that information I don't know much
@young sedge i fixed some bug thanks man
web backend/devops
surely. it depends on how you made it though
there should be clear separation, between stateful and stateless parts of your web application
keeping only database as stateful
the rest of your app should be stateless and easily destroyed/replaced/multiplicated
but, that's a second step in my opinion
better to start with good caching
caching can be made at... a lot of different stages, it will speed up web site faster and with less effort
i have the deployed statics files in aws ()s3 bucket does it have negative impact
on website
I did not work with AWS yet
it is like spaces in Digtal Oecan
oh, cool. that what I was looking for I think.
it has the feature of CDN (in digital ocean at least)
yes, it is exactly the way to deliver frontend to client
a way to make sure he would get it fast no matter from which part of the world
btw, this feature probably will be useless if your host web site only for one country target
the point of CDN is making web site fast for multiple countries
sorry i don't know much about devlops i am working in backend
but thanks for a pro tip
just to be sure, I am not very experienced person as well. just learning stuff too.
Hey Hey, someone got pyqt5 experince with translucent window?
I'm developing a planogram management app, functionally everything is working but was hoping for a critique on the aesthetic
it may sound funny but what is a planogram ?
They're commonly used in retail to indicate where items and stuff should go in a store.
I'm not sure, but this looks like it could very well be divided into tabs or something.
Like one for logs, one for the planogram overview, one to search an UPC, and things like that.
Although that looks like Tk and I'm not sure if they have a tab bar widget by default
I could make one pretty easily on a canvas, I've been doing tk in some form for about 4 years. Ik ttk has a "Notebook" option but it looks pretty ugly. The item info always needs to be up, the console will eventually go away and the item info will take that whole space. I'll see if I can hide the new/deleted items list behind a tab though, thanks for the input!
:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1633214692:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).
how do you make high quality (non pixelated) icons in PyQt? whenever I try to display a pixmap icon on a label it looks pixelated, especially near the edges
right is with Qt.SmoothTransformation applied (I'm downscaling both images)
ok so I did some more digging and adding os.environ["QT_FONT_DPI"] = "96" fixed the resolution issues, however is there alternative fixes. When I add this to my code the entire ui gets a bit smaller
I moved the info to tabs like suggested, how does this look? (Feel free to ping with responses)
hmm yeah that looks neat
there's definitely some progress since yesterday
Just changing the overview background to match the rest has a pretty dramatic effect
how did you rotate all of these labels
It's all drawn on a canvas
the canvas text widget can be rotated
Here's a video of it in action for context, sorry my scanner is a bit slow
A canvas can be rotated? With what method?
canvas.create_text(0, 0, anchor="nw", angle=270, text="90 Degree Text")
The text is rotated not the canvas itself
Never knew there was an angle parameter
I've played with canvases a lot
one sec I have some cool stuff to show
This one is a pixel art animation studio I made
Nice
If you have questions about doing stuff with canvases feel free to bug me
I feel like my apps are looking less and less like 'tkinter' apps
I hope that's a good thing
not really, im here to provide help only 😄
fair enough haha 🙂
does anyone know which python tools I can use to start learning web development
looks more spaced out before it was too compressed keep going
Here, this should be better
dang that's really cool
I've used canvases before but I never tried putting widgets in them
wait are they widgets
I suddenly can't tell
https://paste.pythondiscord.com/agoxokejiz.py
this is my code and there is a massive problem on the option_three_commmand function
so this function's purpose is to create a button for each of the contacts that are saved in the names.txt file for ex. Oreo, Devil, Bill and when this button is clicked the contact's button will delete the name from the names.txt file and then the seperate txt file for the contact for example Oreo.txt. My problem is that although the buttons are created when i click for example at Oreo only the last contact from the for loop will be deleted (Bill in this case) rather than Oreo and i cant fix it
sry if i didnt explain it well
could sm1 help me with this?
The bottom chunk with the tabs are widgets, the actually diagram is just a canvas
QtWidgets.QToolBar.__init__(self, parent)
TypeError: arguments did not match any overloaded call:
QToolBar(str, parent: QWidget = None): argument 1 has unexpected type 'Ui_MainWindow'
QToolBar(parent: QWidget = None): argument 1 has unexpected type 'Ui_MainWindow'
Aborted (core dumped)
Please Someone let me know why this is happening...
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg,\
NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
# from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from PyQt5.QtWidgets import QScrollArea
from PyQt5 import QtWidgets
class MplCanvas(FigureCanvas):
def __init__(self, parent=None, width=4, height=12, dpi=1200):
self.fig = Figure(figsize=(width, height), dpi=dpi)
super(MplCanvas, self).__init__(self.fig)
class UIGraph:
def __init__(self):
super(UIGraph).__init__()
def graph_make (self,UI,NEFF,Depth):
N_EFF = np.array (NEFF)
Depth_ = np.array (Depth)
Depth_Lim = Depth_[0:len (N_EFF)]
sc = MplCanvas(self, width=2, height=3, dpi=100)
ax = sc.fig.gca()
ax.plot(N_EFF,Depth_Lim,linewidth = 5)
sc.fig.tight_layout(pad=2)
ax.set_ylim(ax.get_ylim()[::-1])
ax.xaxis.tick_top()
ax.yaxis.tick_left()
ax.set_xlabel('my xdata')
ax.set_ylabel ('Y')
## Warning....... Fix it...
# ax.set_xticklabels(np.arange (0,101,50))
# ax.set_yticklabels(Depth_Lim)
# self.canvas = FigureCanvas(self.fig)
toolbar = NavigationToolbar(sc, UI)
scroll = QScrollArea(UI.graph)
scroll.setWidget(sc)
UI.Graph.addWidget(scroll)
UI.Graph.addWidget(toolbar)
UI.graph.setLayout(UI.Graph)
self.UIClass_, self.Temp = loadUiType (SPTMainUI)
self.UI = self.UIClass_()
self.UI.setupUi(self)
SPTMainUI is my UI file..
Should I have one python file for every screen? So i can keep the main python file clean?
I usually break all the custom widgets into their own file then a separate file for each frame you want.
I cant understand why it not able to get that image even its all correct
could be the garbage collector or path isnt correct, relatively speaking
In main game the same path working let me try full path
Lol even if i start from the drive ot says imahe dont existas
Idont k owwhy but tried so many things
Created new img and tried loding that
Tried full path
Tried making another directory and fetching it from there
Tried to fetch that dictionary from that file its working
But not a single worked
Or i think i cant able to prived that path better to make it understand
None of them works
Can someone help me here im learning so dont roast me lol
can you show me all the code?
Any pyqt5 expert please refer #help-lemon for my question...
Here I have asked a question about pyqt.. Can someone can answer my question either in help-lemon.. or forum..
Is there any way I could create a temporary dropdown in tkinter? I want to use in my program... Its a type of autocorrect system in text widget of tkinter where if i type helko and hover my mouse on it, itshould give me list on options below my mouse cursor having hello and some other meaningful words like that.
its ok even if pops up in the screen instead of showing below mouse cursor....
Nothing like that, but if you have the logic worked out, then you can create a custom Text widget that does this
Sorry I didn't get what you mean
What's custom text widget? And how to make it?
Would anyone want to work together on a python project through GitHib? I know the basics of python and am familiar with some of the common modules used and would like to gain more experience by coding more projects. I don't really care what the program would be, however I would like for it to be challenging.
If anyone would be interesting in doing so DM me or just respond to the message.
By using OOP
Is there method to pause the tkinter app from running, like wise icureently i working on minesweeper game,
I accidently putted 100 ros and cols and my program got so slow due to that even thought i used a method to check that the amount dont exceed by 30 , it showed me warning but after closing it it went to prepare 10,000 minesweeper tiles
PYQT5... Can we do multiple entries like in adding multiple emails to qlineedit or any other widget... Also with close icon..
I'd like to ask you guys about toolbars
I'm working on a graphics library (of sorts) which relies on wxPython
wxPython has a toolbar/toolbarmenu/toolbaritem setup, and these widgets are related to keyboard shortcuts
What I want to know is — does this setup do anything "special" other than organize the widgets visually, and connect to widgets to listen for keyboard command?
I ask this, because the bulk of my library's graphics are in HTML. If the above two actions are all wxPython is doing — well — I can code that using HTML and reduce my dependancy on wxPython
yes of course
You could enlarge the line edits
and use \n to separate each entry via line
pause?
f-you button?
Can anyone give me few good examples of widely used GUIs developed in PyQT please if you know them from the top of your head like what comes first in mind (any platform)
Like an app that's developed using PyQt?
Musicbrainz picard is the first one that came up in my mind.
And Qgis
Do you want pyqt only apps or qt too?
I am doing this research to think ahead about my future career lol
I think GUI dev jobs are RARE and I don't think I am interested in any of this frameworks anymore to be honest lol
Autodesk uses Qt for their products, although not sure if they use Python
more can be found here
Qt (pronounced "cute") is a widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms such as Linux, Windows, macOS, Android or embedded systems with little or no change in the underlying codebase while still being a native application with native capabilities...
Well i made try excpet and if there is error the else block wont be running
Which error
I mean try,excpet,else, if user gave something wrong except will be exceuted and if everything fin then after try else will be executed
Which error
Value error
I have developed an application in Pyqt5 which contains a lot of inputs.. I am using Matplotlib or maybe use pyqtgraph later.. So My question here is that Is it possible to draw an triangle (necessary demand) on Y-Axis of plot on specific position.. How can I achieve this? Anyone have Idea.. Is there any matplotlib function to draw where we can input some shapes (in our case triangle) in y-axis or even x-axis (in future version).. Or I do it manually by user by opening image and draw triangle manually (using pyqt5) and then save that image to process further.. How can I do this? (No Idea because I am beginner to PyQt5).. Kindly I need any helping suggestion.. Anyone have some sample work or code for it... Thanks...
it will compile it to a native c app whereas otherwise you'd have to figure out how to bundle a browser i.e. https://github.com/cztomczak/cefpython/blob/master/examples/wxpython.py
but you can also package sanic or something into an exe and call webbrowser.open("https://localhost:8080")
I'm already using cef:p
entire error code please
I solved that problem , in research i found that btn.config dont works like when we press it will do whatever commamd is mentioned, as as soon as it will hit that config line of code it will automatically execute, which made program to convert empty values in entry box to be converted to integer
😅
I've no idea what you are trying to say, but if it worked for you, then it might be the correct response you were expecting
uh can anyone help me? the "your money is: {number}" is not working well
the number is like bugging
You are prolly over writing buttons with more buttons on top
I dont know but i cant get how to use custom fonts in tkinter
Lile where i mention family name idk what to put and how tk will recogonise that it has to use that font
Just put like font = ["font_name", 54]
Here 54 is the font size
Use pyglet
lstbox.py line 10
pyglet.font.add_file('fonts/coolvetica compressed rg.ttf') # Add the task font```
yes
Make sure to give the name of the font, not the name of the file
Aah sadly not able to work on program that time, @tawdry mulch and this not working
Haha i made minesweepr working, but i wasnt satisfied with ui so i made the one matching with old windows game
I also defined the font by
`from tkinter.font import Font
Myfont = Font(family=filepath, size=12)
then in label i used
Mylb = Label(root, font=Myfont)
Mylb.pack()`
But still not works
Hello Kutiekatj9, (don't wanna ping you but hopefully you'll read it), i want to know how can use the gestures in PyQT? in my application, i want to switch a QstackedWidget page, How can i do that by swiping on the screen? there is PyQt5.QtWidgets.QSwipeGesture but i don't know how can i use it nor i found any examples online about it so far so could you please write a short snippet of code to call a function upon swiping on application UI? Thanks
Quick way to set up application with a mouse-clickable canvas, some buttons, text field and keyboard support? I havent done gui in along while, what's the most neat? 🙂
So the question is, which framework would be your choice? I guess.
wdym by a "mouse-clickable canvas"
A canvas that can detect clicks from the mouse, so that I can trigger a callback on mouse events
perhaps that's not the canvas' responsibility
I would go with tkinter for that
extremely quick to get started with it
Ok I also got a vote for Kivy, lets see how they compare 🙂 quick find: https://www.educba.com/kivy-vs-tkinter/
Kivy is better if you plan to spend more time in the GUI or are planning to scale (instead of Kivy I would go with PyQt unless im specifically targeting phones)
Tk is better if you just want something up and running
👍
I thought the default installation of python3 had tkinter included? ModuleNotFoundError: No module named 'tkinter'
what is the file name and font name
Yes, though I think only if you didn't uncheck it in the installer.
I have a fresh ubuntu 20, but I installed it manually
How could I start to play an animation in a tkinter.Canvas and use button to start/stop that animation? Maybe something similar to register/unregister an animation function using Tk.after(0, anim_func)?
Idk how to tell tkinter to acess font from different directory, i commented to codemy.com and he said to add them in windows font folder
yea that works for YOU. but not if you send the file to someone else
can someone help me? How can i run 2 different actions with one Button in TKinter? The actions and buttons are following:
def scissor_action():
action_label.config(text="Du hast Schere gewählt!",bg="palegreen3")
action_label.pack(side='bottom',before=scissor_button)
#Aktion für Stein
def stone_action():
action_label.config(text="Du hast Stein gewählt!",bg="palegreen3")
action_label.pack(side="bottom",before=scissor_button)
#Aktion für Papier
def paper_action():
action_label.config(text="Du hast Papier gewählt!",bg="palegreen3")
action_label.pack(side="bottom",before=scissor_button)
#Button für Schere
scissor_button = Button(fenster, text="Schere",bg="pink3",fg="white",height= 3, width=10,command=scissor_action)
scissor_button.pack(padx=70,pady=20, side="left")
#Button für Stein
stone_button= Button(fenster, text="Stein",bg="palegreen4",fg="white",height= 3, width=10,command=stone_action)
stone_button.pack(padx=40,pady=20, side="left")
#Button für Papier
paper_button = Button(fenster, text="Papier",bg="cadet blue",fg="white",height= 3, width=10,command=paper_action)
paper_button.pack(padx=70, pady=20, side="right")
#Aktion zum verblassen der Button Farben bz. Schere
def scissor_colour():
stone_button.config(fenster, text="Stein",bg="gray",height= 3, width=10)
stone_button.pack(padx=70,pady=20, side="left")```
First tkinter app, current state: https://imgur.com/a/cFD3ICe
Uhm, not sure how to hide the preview =S
I am getting spacing between my grid that I don't understand
code?
if I make a smaller grid its fine
basically I am adding a whole bunch of canvases to the tkinter root
def MakeCanvases(amount):
done = 0
currentRow = 1
currentColumn = 0
s = int(math.ceil(math.sqrt(amount)))
newRow = False
while done < squares:
if(newRow == False):
size = math.floor(root.winfo_height()/s)/2
newCanvas = Canvas(root,width=size,height=size, bg=PickColor('white'))
newCanvas.grid(row = currentRow, column = currentColumn)
squareArray.append(newCanvas)
if(currentColumn < s):
currentColumn += 1
if(currentColumn == s):
currentColumn = 0
currentRow +=1
done += 1
squares is the number added in the input box
Usually command=[func1(),func2()]
can you give a reproducible example?
!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.pythondiscord.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.
sorry the "Quit" button actually remakes the grid
this is cleaned up a bit if you havent looked yet
Mmmmm im not sure, I guess somethign is wrong with currentColumn
its so weird
if oyu print out the currentColumn and currentRow, it all makes sense
it is what you would expect. when I add the sticky parameter it stretches the canvas to fill that empty space
also why does it work with smaller grids...
1 1
1 2
1 3
1 4
2 0
2 1
2 2
2 3
2 4
3 0
3 1
3 2
3 3
3 4
4 0
4 1
4 2
4 3
4 4
5 0
5 1
Would this be how you expect? rows and columns to be?
ya it should be column 0 at the start
i think that is your pasting mistake though 🙂
no no
if I put in 21 I get
1 0
1 1
1 2
1 3
1 4
2 0
2 1
2 2
2 3
2 4
3 0
3 1
3 2
3 3
3 4
4 0
4 1
4 2
4 3
4 4
5 0
and this
the top row is for the button and input, could that be the issue?
i think thats it
can I see your code please?
im not sure how tkinter really works, the whole frame thing
You can work from here:
from tkinter import *
from tkinter import ttk
from random import choice
import math
import winsound
colors = ['gold', 'green', 'yellow', 'sandybrown', 'lawngreen', 'pink', 'lightgreen', 'lightyellow', 'wheat', 'indigo']
squareArray = []
beeps = [600, 800, 1000, 1200, 1400, 1600, 1200, 800]
root = Tk()
root.geometry("1000x1000")
root.title("Animation")
frame = Frame(root)
frame.grid(row=1,column=0)
frame2 = Frame(root)
frame2.grid(row=0,column=0)
entry1 = Entry(frame2)
entry1.grid(column=1, row=0)
def DestroyCanvases():
for x in squareArray:
x.destroy()
squareArray.clear()
def MakeCanvases(amount):
done = 0
currentRow = 0
currentColumn = 0
s = int(math.ceil(math.sqrt(amount)))
newRow = False
while done < squares:
if(newRow == False):
size = math.floor(root.winfo_height()/s)/2
newCanvas = Canvas(frame,width=size,height=size, bg='red')
newCanvas.grid(row = currentRow, column = currentColumn)
squareArray.append(newCanvas)
if(currentColumn < s):
currentColumn += 1
if(currentColumn == s):
currentColumn = 0
currentRow +=1
print(currentRow,currentColumn)
done += 1
def ChangeSquareCount():
global squares
squares = entry1.get()
squares = int(squares)
DestroyCanvases()
MakeCanvases(squares)
def Beep():
duration = 75
winsound.Beep(choice(beeps), duration)
def PickColor(lastColor):
a = choice(colors)
if(a != lastColor):
return a
else:
return 'purple'
ttk.Button(frame2, text="Quit", command=ChangeSquareCount).grid(column=0, row=0)
def redraw():
global t
root.after(1000,redraw)
for x in squareArray:
g = choice([1,0])
if(g == 1):
x.configure(bg=PickColor(x["background"]))
redraw()
root.mainloop()
thanks @tawdry mulch I will take a close look
so im using tkinter, is there a way to use an image/gif as a background?
@simple heart I'm still new to tkinter, but the way I've done it is using Label()
@simple heart give me a sec
oki
background = PhotoImage(file=r"some.png")
label = Label(image=background)
label.place(x=0, y=0)
@simple heart
Give that a shot, really depends on your size of app window, and if you locked resizing if that is even a reasonable solution
ah thanks
what does the r do in the file bit?
also is there a way to send the label to the bac?
Sorry, use to typing that in my other libs, you don't need the r. As for placing it in the back, trying placing it as the first label loaded to see if that solves it.
also sadly that doesnt work with gifs
ah
i have it like this
but it just shows this
should have 3 buttons at the front
You could create a container (using Frame()) to solve that
Python - Tkinter Frame, The Frame widget is very important for the process of grouping and organizing other widgets in a somehow friendly way. It works like a container, which is respo
oki
doesnt seem i can use an image for that
One sec, let me try to write an example
ok
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
background = PhotoImage(file="logo.png")
label = Label(image=background)
label.place(x=0, y=0)
welcome = Label(root, text="Welcome", bg="white")
welcome.pack(pady=20)
frames = Frame(root, bg="white")
frames.pack(pady=20)
btest = Button(frames, text="Another button")
btest.pack(pady=20)
if __name__ == '__main__':
root.geometry("400x400")
root.resizable(False, False)
root.title("SPOSCIE example")
root.mainloop()
@simple heart
so this should work right?
oh wait what
if i place them, it stops workin
What's the error
but if you place them it wont work
Hm
like button.place(x=50, y=20)
Have you tried using grids?
no cos i feel like that would be a waste of time
i might try this again another time
it is the better than place
The best way for you is to create a canvas and then create images on top of it
:incoming_envelope: :ok_hand: applied mute to @tough viper until <t:1633877083:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).
can we make modern GUI with Python?
Depends on what you mean with modern but most frameworks will get you something decent looking with some work
Qt is probably the most robust with its styling/QML but others like kivy or tkinter are fine too
For example if you want to put certain videos in interface or animation as background is it applicable with tkinter ?
hello peeps, is there a tkinter cookbook anywhere out there in the wild?
sadly i gotta use it for work and im not that experienced with it
What are buddies in pyqt?
would recommend doing that with pyqt
does anyone know how to bind a funtion to clicking on a tab in a ttk notebook?
ping me if you know
I made a timer class for minesweeper game and i ise after function of tkinter to recall itself after one sec,
But this gives recursion error since it dont waits for one sec to call that func again
to_digits function is just to make that countdown a three digit string for display in label
yes, but if you aren't doing open source project, then it would a bit of a license nightmare hell 😉
PyQT5 /PySide6 are quite cool to provide really modern experience
technically u can do modern looking thing with other frameworks where there is no issues like QT have
Kivy and e.t.c.
But they don't have visual designers, while QT has 🤔
so it would a bit longer experience
Among pyqts and pyaide6 which gives wider range of flexibility@young sedge ?
highly likely PyQT5
PySide6 was made as a less license restricted copy of the PYQT5, so it would be always a bit behind, or at least it was
I just like to work in one and get better and better at that
U have any solution to this?
read about licensing stuff though, just in case
be sure to know that for commercial usage
there would be requirement to pay monthly/yearly payments for all times while you distribute stuff that uses QT
In several special options, the payments could be ten times less though
for open source usage there will be no payments though
Do tkinter also has commercial use policy?
Kivy, Tkinter are having MIT licenses, they can be used for commerical stuff without limitations/payments
Tkinter is actually having Python license, which is close to forgot the name, New BSD license I think? It is free to use as well
Haha even though they are good dont think they have been used in good companies
who kknows
anyway, if you need to make quick dumb GUI without any styling, then PySimpleGUI is the best ;b
it does fastest job
The method passed to after should not be called remove the () as follows
self.label.after(1000, func=self._update_after_sec)
i want a GUI Library to make same interface as for example League of Legend's interface
Aah i was too close ,thanks
Ohh, so () after fun means it will be called instant,
It sounds dumb😅
pyside6 or you can use a game lib eg arcade, pygame
like i can include pygame or arcade inside of my tkinter ?
no
I'm having a bit of trouble with adding an image onto tkinter. Here is the code
img = ImageTk.PhotoImage(Image.open('Images/head.png'))
panel = tkinter.Label(wn, image=img)
panel.pack(side="bottom", fill="both", expand="yes")
I'm doing exactly I saw online, but the image isn't even showing up
how to show an animated (GIF) in tkinter as my background
try keeping a reference to img so it doesn't get garbage collected
panel.img = img
will this work # Reading an animated GIF file using Python Image Processing Library - Pillow
from PIL import Image
from PIL import GifImagePlugin
imageObject = Image.open("./xmas.gif")
print(imageObject.is_animated)
print(imageObject.n_frames)
Display individual frames from the loaded animated GIF file
for frame in range(0,imageObject.n_frames):
imageObject.seek(frame)
imageObject.show()
What is garbage collected
Also where should i put that line
img = ImageTk.PhotoImage(Image.open('Images/head.png'))
panel = tkinter.Label(wn, image=img)
panel.image = img
panel.pack(side="bottom", fill="both", expand="yes")
``` Like this?
https://docs.python.org/3/glossary.html
garbage collection
The process of freeing memory when it is not used anymore. Python performs garbage collection via reference counting and a cyclic garbage collector that is able to detect and break reference cycles. The garbage collector can be controlled using the gc module.
Hey @royal dove!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
from tkinter import *
from PIL import ImageTk,Image
#image = Image.open("Backgroundgif.gif")
#background_image = ImageTk.PhotoImage(image)
root = Tk()
root.geometry("1280x724")
imageObject = Image.open("./ezgif.com-gif-maker.gif")
Display individual frames from the loaded animated GIF file
frameCnt = imageObject.n_frames # This will get the number of frames in a gif
frames = [PhotoImage(file='Backgroundgif.gif',format = 'gif -index %i' %(i)) for i in range(frameCnt)] # This will extract the frames as images from the gif.
#This function is to display each image in the gif from the list as a gif.
def update(ind):
frame = frames[ind]
ind += 1
if ind == frameCnt:
ind = 0
label.configure(image=frame)
root.after(100, update, ind)
label = Label(root)
label.pack()
root.after(0, update, 0)
root.mainloop()
I managed to make animated Gifs in tkinter, but having trouble as making it my background
how would approach integrating a GUI into an async package im developing?
how does linkActivated & linkHovered signals work in pyqt label??
https://paste.pythondiscord.com/cetumepece.py this link is to a code containing script to run animated(GIF) background in tkinter made by me
now get the duration of each frame from the gif file 😉
I'm kidding that's kinda a lot of work it looks good to me
tkinter menus kinda look bad, so I made my custom one :)
now compare it with the menus provided by tkinter
Sharing code is always appreciable 😄
is it possible to make a good-looking GUI with tkinter?
With hardwork, yes
its a mess currently, and i'm cleaning up, will try to bring up a library for modern widgets if possible :)
Hi there - whats the most battle tested gui framework when it comes to use html,css,js? Found only pywebview? Anyone have experience with it?
for tkinter you need to make thousands of code line and planning for a good modern GUI from Zero