#user-interfaces

1 messages · Page 83 of 1

digital rose
#

i heard of that

#

i know that works with tkinter

solar nest
#

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

solar nest
digital rose
#

mm ok, i’ll go with it then

digital rose
solar nest
#

I suggest familiarizing youself with venv before getting into pyinstaller

digital rose
#

it’s just a mini project for my mom

solar nest
#

that will keep you from accidentally compiling something huge or destroying your native env

digital rose
#

i usually do that for mini projects

solar nest
#

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

digital rose
#

and what‘s onefile flag exactly?

#

😬

#

a file that i upload

#

to take data from it?

solar nest
#

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

digital rose
#

oh

solar nest
#

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

digital rose
#

hahaha

#

i prefer also to do it by myself

#

that‘s the fun part

solar nest
#

yep

digital rose
#

☺️

#

thank youu

solar nest
#

np

digital rose
#

oh

#

one more question

solar nest
#

kk

digital rose
#

unrelated

#

do you know how sould i extract a table with data from pdf

solar nest
#

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

digital rose
#

mm i dont think it is with img

solar nest
#

from my experience. I didnt get much farther than that

digital rose
#

let me show you

solar nest
#

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

digital rose
#

oh

solar nest
#

sorry, lol

digital rose
#

no

#

problem

#

thank you

#

anyway

#

you helped me

solar nest
#

👍

digital rose
#

🙏🏼

compact quail
#

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!

solar nest
#

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?

sinful pendant
#

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

sinful pendant
#

Code is a big boom boom

#

I changed some things into loop

tawdry mulch
proven basinBOT
#

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.

sinful pendant
#

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

tawdry mulch
#

If I do not see your code, I cannot help you🤷‍♂️ Im no magician

sinful pendant
#

Thats what problem i have

tawdry mulch
sinful pendant
#

Yes but idont know how to use it

#

Can u yell example

#

Cuz in that program i have 81 buttons ie 81 variables 😂

tawdry mulch
sinful pendant
#

Yeah but i cant able to think to manage

#

Uff bad network cant even upload an image

sinful pendant
tawdry mulch
tawdry mulch
# sinful pendant Cuz in that program i have 81 buttons ie 81 variables 😂

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()
sinful pendant
#

Thanks i got the point

#

😃

#

But idont k ow why sometimes making so many buttons with loops sucks in tkinter

sinful pendant
#

Yeah earlier i made buttons in two nested for loops

#

I got images for only last button

tawdry mulch
sinful pendant
#

Well config method seems good and seems like saving so much code to write

#

🤩

sinful pendant
#

@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

tawdry mulch
sinful pendant
#

👍

#

@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

tawdry mulch
sinful pendant
#

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

tawdry mulch
sinful pendant
#

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

tawdry mulch
sinful pendant
#

Everywhere tab needs to be one that button

#

Not working

tawdry mulch
sinful pendant
#

For now i have defined a func click which returns the event and i print that event

tawdry mulch
sinful pendant
tawdry mulch
#

Same as whatever is there in the original documentation given by John Shipman from NMT, but made into a website

sinful pendant
#

👍

tawdry mulch
sinful pendant
#

btn.bind('<KeyRelease-Tab>', click)

#

def click(e): print(e)

tawdry mulch
#

This will execute click after the key is released

sinful pendant
#

On pressing tab nothing in my terminal showed excpt \n

tawdry mulch
#

What you are doing is same as btn.bind('<KeyRelease-Tab>', print)

sinful pendant
#

Oh yeah

#

But it is somewhat different😂

#

Lmao i now thinking how to acess the buttons

tawdry mulch
sinful pendant
#

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

tawdry mulch
#

Is Sudoku and Soduko same?

sinful pendant
#

Oh yeash

#

Seems like i never watched soduko spellings😂

tawdry mulch
sinful pendant
#

Yeah its a feature 😅

tawdry mulch
#

Why dont you use Entry

sinful pendant
#

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

tawdry mulch
#

It does what you just explained😂

sinful pendant
#

Is enter amd entry are same?

tawdry mulch
#

No, entry is a widget where you type. Enter is an event.

sinful pendant
#

Oh then i think i will use entry with combination of key

#

Like i will be first binding with enter and then woth key

tawdry mulch
#

Why....

sinful pendant
#

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

tawdry mulch
sinful pendant
#

Ohk

#

Thanks for help i have navaer met with someone like u

#

Help at any step

tawdry mulch
tawdry mulch
sinful pendant
#

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

tawdry mulch
#

That was my idea too, anyway share some code when you have time

sinful pendant
#

Haha sure

#

Just aftee i get some wifi upgrade

#

Otherwise .py file or imahes😅🙃

tawdry mulch
sinful pendant
#

Ohk

tawdry mulch
#

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)
sinful pendant
#

That loop saved so much space

tawdry mulch
#

Pretty sure you can save 50 percent space more with more loops

sinful pendant
#

Where

#

In images?

tawdry mulch
sinful pendant
#

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

sinful pendant
#

Wont forget u to show the result

tawdry mulch
still zinc
#

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)?

tawdry mulch
still zinc
#

Oh ok

#

Why not?

tawdry mulch
still zinc
#

okay xD

tawdry mulch
#

You can put a canvas for the whole window then put scrollbar to it.

still zinc
#

Cool! Thanks!

autumn trout
#

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

pliant dagger
autumn trout
#

oops,

#

can't I continue here?

pliant dagger
pliant dagger
autumn trout
#

At both places all was mentioned about complex backend jobs like views, urls etc

digital rose
#

i'm not that good with web interface

autumn trout
#

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)

autumn trout
#

@pliant dagger

pliant dagger
#

I don't know

sinful pendant
#

@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

autumn trout
#

@sinful pendant do you have any idea of my problem?

sinful pendant
#

Currently i know only tkinter framework

sinful pendant
#

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

tawdry mulch
open pagoda
sinful pendant
#

Aah man u dont k ow how i managed to do this much

sinful pendant
#

Bruh my sucking net

tawdry mulch
#
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()
tawdry mulch
compact quail
tawdry mulch
compact quail
#

Thanks! I'll give that a try!

balmy imp
#

good UI?

sinful pendant
#

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

sinful pendant
#

I was finding the solution in the init code

#

I can understand bits that what ur code doing

sinful pendant
#

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

tawdry mulch
sinful pendant
#

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

tawdry mulch
sinful pendant
#

Can u send link of that docs

tawdry mulch
#

I did already, scroll up? Not infront of a system now

sinful pendant
#

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

sinful pendant
#

Soduko

#

Wid.row and .column dont gives the row and column for thay widget

tawdry mulch
sinful pendant
#

Yes

#

Of that button whose text i changed

tawdry mulch
sinful pendant
#

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

tawdry mulch
grizzled bolt
#

I need some help with a TUI i was trying to develop
Is this place right?

digital rose
#

can someone send me a tutorial on creating a Emailing service
dm me

solar nest
#

I tried to read the email standards documentation once. I would advise against the idea of managing or creating an email service. lol

solar nest
# digital rose 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

digital rose
#

that didnt make send

#

sense

#

im a web dev (for context)

solar nest
solar nest
#

?

digital rose
#

i want to make my own Gmail but lite

#

Gmail i heavy

#

is*

solar nest
# digital rose i want to make my own Gmail but lite

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.

digital rose
#

i mean 'lite'

#

as in simple

#

minimilistic

solar nest
#

so do I

#

parsers arent the things that get better the simpler they are

digital rose
#

basic functionality no complexity

#

but workability

solar nest
#

good luck with that

digital rose
#

i mean

digital rose
#

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

solar nest
# digital rose i mean

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

digital rose
solar nest
#

so you could still receive emails, but not all the content would get read in

digital rose
#

oh

#

i see

#

for example the sender name

tawdry mulch
#

Guys, this is not related to a UI, so please take it some other related channel.

solar nest
#

yeah or the body might not be where you are expecting it

digital rose
#

web, ui, os

tawdry mulch
digital rose
#

since u can make one with a ui

solar nest
#

this is more of a communication protocol thing, not a UI thing, users dont interact with email services, just their frontends

knotty vigil
solar nest
vital pike
#

Hi guys, can anyone help me with a rendering problem with qtile wm?

sinful pendant
#

@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

sinful pendant
#

So then at the end i will bind with frame instead root?

tawdry mulch
sinful pendant
sinful pendant
#

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

tawdry mulch
#

Or new window

sinful pendant
#

I mean should i pack them inside a function?

#

Because the whole code i have does that it provides u the solving thing

tawdry mulch
sinful pendant
#

I am thinking to go by def i think i should give it a rought try

sinful pendant
#

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

long quarry
#

Hi mates I want to create some thing like this how to do please send some resources

tawdry mulch
sinful pendant
long quarry
#

oh that question is related to web interface

tawdry mulch
rocky dragon
#

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!
sinful pendant
#

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

tawdry mulch
#

You can code this new thing inside a function or a class

sinful pendant
#

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🙃

proven basinBOT
#

@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!

fickle sentinel
#

If I am a really bad python programmer, should I use TK or something else

quasi plover
fickle sentinel
#

I know python

#

i just am not good w/ libraries

quasi plover
#

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

fickle sentinel
#

Ok

#

sorry for asking

quasi plover
#

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

fickle sentinel
#

I literally just wanna make a simple GUI that has buttons

#

that can add / remove elements at will

quasi plover
#

then tkinter will be fine

fickle sentinel
tawdry mulch
fickle sentinel
#

I want a proper understanding

tawdry mulch
# fickle sentinel 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.

▶ Play video
fickle sentinel
#

ty

knotty vigil
#

Hey am trying to build apk out of kivy but when I launch it on my cell it crashes

lucid totem
#

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()
digital rose
#

How do I put my terminal(or output) in a label in tkinter?

tawdry mulch
#

Please dont give wrong/false information out like that

tawdry mulch
digital rose
#

Ohh

#

Never knew the configure part

#

Thx

digital rose
static cove
digital rose
#

not find module

#

PyQt5.QtCore

static cove
#

Do you have pyqt5 installed with the right interpreter? It could be that you installed it for a different python version

digital rose
#

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?

white plover
dusk marsh
#

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

storm flare
#

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
tawdry mulch
storm flare
#

nah i fixed it

gritty plaza
#

hey, where do i learn qt designer?

#

like, can u suggest any youtube tutorials?

#

or courses?

mild spire
#

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?

mild spire
#

the left and the top

#

i only get padding on the bottom and right side

tawdry mulch
digital rose
#

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

sinful pendant
#

I have a frame packing in grid how i can make it take full available space

digital rose
#

whats the best way to make a modern ui in python?

pliant dagger
digital rose
#

Im on tkinter right now @pliant dagger

#

Can i use some other language like c# in combination with python?

pliant dagger
digital rose
#

I mean use python for functionality and something else for ui

#

I don't need python for front end

pliant dagger
digital rose
#

Btw im making a desktop app

pliant dagger
#

cause I'm not 100% sure

digital rose
#

Alright thank u

pliant dagger
#

😄

digital rose
#

Uh ok

dusk marsh
#

@sterile matrix thank you a lot

sterile matrix
#

btw for future reference, that widget is called Combo Box or Dropdown Menu in most gui toolkits

dusk marsh
#

yeah, the main problem was that i had no idea what to actually look for

sinful pendant
#

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

pliant dagger
#

it's pretty cool

tawdry mulch
sinful pendant
#

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

tawdry mulch
sinful pendant
#

Nope cuz as per grid configuration inside soduko frame the columns seperates

sinful pendant
#

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

#

😃

digital rose
#

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

tawdry mulch
digital rose
#

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

tawdry mulch
digital rose
#

What do you mean terminate app?

tawdry mulch
digital rose
tawdry mulch
digital rose
#

By running it like anybody else would

gritty plaza
#

what is the best way to create GUI?

digital rose
#

python -m file.py

gritty plaza
#

like, what libraries

tawdry mulch
gritty plaza
#

or if not python libraries, what other platform/language is the best for creating gui for python

digital rose
#

Then what? Terminate the parent process that then terminates the child process?

tawdry mulch
tawdry mulch
digital rose
#

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

gritty plaza
tawdry mulch
tawdry mulch
gritty plaza
# tawdry mulch Kind of yes

can you suggest any resources? I have been searching the internet for qt designer resources, but barely found any

digital rose
#

I'm not using tkinter

#

I'm using PyQt5

tawdry mulch
tawdry mulch
gritty plaza
tawdry mulch
gritty plaza
#

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

tawdry mulch
# digital rose I'm not using tkinter
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()
gritty plaza
#

i had to code like 200 lines of pygame to build the menu for a codebase of 100 lines

tawdry mulch
#

@plush stream Might be able to give some resources

gritty plaza
gritty plaza
#

ah ok thanks

plush stream
#

what's up?

gritty plaza
#

can I import custom assets in qt designer?

#

so far, I have seen that to be the case only with qt design studio

plush stream
#

I don't know unfortunately. I script my gui manually.

tawdry mulch
tawdry mulch
gritty plaza
gritty plaza
plush stream
#

The main reason i use pyqt in the first place is because you can literally override everything inside of it.

gritty plaza
#

can you use custom assets in pyqt?

#

im guessing u can

plush stream
#

Can you define "custom assets"?

#

Are we talking about something like icons?

gritty plaza
#

yep

#

and button designs

#

etc

plush stream
#

Oh

#

Of course you can

gritty plaza
#

yea, i couldnt find tutorials on that on youtube

#

anyways, ig ill check out the documentation

plush stream
#

Yep

#

If you want to customise the look of your GUI then look for qss

#

It's like css but for qt

gritty plaza
#

oh ok, cool

#

i'll look into it

tribal pier
#

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 ....)?

tawdry mulch
tribal pier
#

yeah, that's right

tawdry mulch
tribal pier
#

no, then the user can select a file (for example a *.zip) but not a directory

tawdry mulch
tribal pier
#

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

tawdry mulch
tribal pier
#

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().

tawdry mulch
tribal pier
#

in fact, both are directories, a folder and an archive (which can contain files and directories)

tribal pier
#

yeah, of course

#

but you can install from it like from a directory

tawdry mulch
#

install?

tribal pier
#

from a source archive

#

like pip does

#

you can install from a local project dir or from a local or remote source archive

tawdry mulch
tribal pier
#

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)

tawdry mulch
tribal pier
#

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?

tawdry mulch
#

and accordingly you can use if and use 2 separate dialog windows

tribal pier
#

yeah, for one i'll go with QFileDialog.getExistingDirectory() and for archives QFileDialog.getOpenFileName()

tribal pier
#

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?

tawdry mulch
tribal pier
#

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

tawdry mulch
#

Mmmm idk, maybe there is something. Feel free to wait till someone who knows answer

tawdry mulch
tribal pier
#

would be nice, thanks

wild cipher
#

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)```
ruby needle
#

Yo i need helppp

#

how do i fix this?

#

the white partss

ruby needle
tawdry mulch
#

Which framework is it

#

Judging by the style, looks like tkinter, if then, add relief='flat' option to Button.

ruby needle
#

Tkinter

#

@tawdry mulch thanks

teal void
#

is pyqt the same as pyside?

royal gull
# teal void 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.

teal void
#

alright, thank you.

pallid arch
#

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?

gritty plaza
#

hey, how do i use an image for a button in qt designer?

digital rose
digital rose
#

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

rocky dragon
#

How viable of an option are the asyncio Qt event loop integartions like qasync?

gritty plaza
#

how do I add hover effects to my buttons in qt designer?

median ridge
#

Not sure about in designer but you can make custom ones appear using hover events

digital rose
#

what do you think, which one of those are more usable and why? tkinter or pyqt5?

young sedge
#

Or kivy

digital rose
#

How to make this_

#

?

#

in tkinter

tawdry mulch
azure talon
#

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.

green stump
#

@azure talon have you tried Qt? I've heard it can play multimedia

azure talon
slate maple
#

anyone know of a responsive mit licensed chat template? i need it for a chat app but can't find one

young sedge
#

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

lime monolith
eager viper
#

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?

green stump
eager viper
#

I havn't tried any Python libraries really. You'd recommend PySide2?

green stump
#

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

eager viper
#

Noted, thank you!

eager viper
#

Anyone else have any thoughts?

young sedge
#

xD I hear "cute"

young sedge
#

the licensing looks like a nightmare though

#

some parts in LGPL, some in GPL, some in Commericial

young sedge
kindred mist
#

anyone got knowledge about pyqt and stylesheet?

royal gull
kindred mist
#

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

royal gull
kindred mist
#

I can specify the button then?

#

QAbstractButton#Button something like that?

royal gull
#

hmm yeah

kindred mist
#

didnt work

royal gull
#

try that

kindred mist
#

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

royal gull
#

not sure if this will work but try wrapping the :/icons/... path in quotes

kindred mist
#

" and ' didnt help ^^

#

mb something is wrong with that url(:/icons/new.png)

royal gull
#

yeah might be

#

check resources

kindred mist
#

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 🙂

young sedge
#

Powerful option

#

PyQt looks like... An ultimate thing

#

Like visual studio with c# and etc

#

Heavily thinking to go this way

royal gull
#

yeah PySide/PyQt is pretty decent for UIs

median ridge
#

virtually the same as PyQt

digital rose
#

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 ;))

young sedge
covert quest
#

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

proven basinBOT
#

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:

https://paste.pythondiscord.com

covert quest
#

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

edgy rivet
#

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.

icy flower
young sedge
#

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

digital rose
median ridge
#

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

limpid kindle
median ridge
icy flower
young sedge
# icy flower Can you let me know how to cache the css or js files
icy flower
#

@young sedge i fixed some bug thanks man

icy flower
#

I am beginninner

young sedge
icy flower
#

Can we scale the website of Django

young sedge
#

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

icy flower
#

i have the deployed statics files in aws ()s3 bucket does it have negative impact

#

on website

young sedge
#

I did not work with AWS yet

icy flower
young sedge
#

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

young sedge
#

the point of CDN is making web site fast for multiple countries

icy flower
#

but thanks for a pro tip

young sedge
#

just to be sure, I am not very experienced person as well. just learning stuff too.

kindred mist
#

Hey Hey, someone got pyqt5 experince with translucent window?

obtuse acorn
#

I'm developing a planogram management app, functionally everything is working but was hoping for a critique on the aesthetic

wind sierra
royal gull
royal gull
#

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

obtuse acorn
#

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!

proven basinBOT
#

: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).

median ridge
#

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)

median ridge
#

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

obtuse acorn
#

I moved the info to tabs like suggested, how does this look? (Feel free to ping with responses)

wind sierra
obtuse acorn
#

Just changing the overview background to match the rest has a pretty dramatic effect

mighty rock
#

how did you rotate all of these labels

obtuse acorn
#

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

mighty rock
#

A canvas can be rotated? With what method?

obtuse acorn
#
canvas.create_text(0, 0, anchor="nw", angle=270, text="90 Degree Text")
#

The text is rotated not the canvas itself

tawdry mulch
obtuse acorn
#

I've played with canvases a lot

#

one sec I have some cool stuff to show

obtuse acorn
#

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

tawdry mulch
obtuse acorn
#

fair enough haha 🙂

charred grotto
#

does anyone know which python tools I can use to start learning web development

obtuse acorn
#

How's this look? I tried to subdue the colors a bit

wind sierra
# obtuse acorn

looks more spaced out before it was too compressed keep going

obtuse acorn
#

bigger planograms will look more cramped unfortunately

obtuse acorn
#

Here, this should be better

woeful jasper
#

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

jaunty wing
#

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?

obtuse acorn
pallid arch
#
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..

versed vessel
#

Should I have one python file for every screen? So i can keep the main python file clean?

obtuse acorn
#

I usually break all the custom widgets into their own file then a separate file for each frame you want.

sinful pendant
#

I cant understand why it not able to get that image even its all correct

tribal path
#

could be the garbage collector or path isnt correct, relatively speaking

sinful pendant
#

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

sinful pendant
#

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

worn prairie
#

dont u need \\

#

and not \ @sinful pendant

sinful pendant
#

None of them works

digital rose
#

Can someone help me here im learning so dont roast me lol

rotund stone
pallid arch
#

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..

edgy rivet
#

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....

tawdry mulch
edgy rivet
#

What's custom text widget? And how to make it?

kindred turtle
#

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.

tawdry mulch
sinful pendant
#

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

pallid arch
#

PYQT5... Can we do multiple entries like in adding multiple emails to qlineedit or any other widget... Also with close icon..

eager viper
#

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

unique forge
#

You could enlarge the line edits

#

and use \n to separate each entry via line

median ridge
#

f-you button?

snow haven
#

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)

plush stream
#

Like an app that's developed using PyQt?

snow haven
#

Yes exactly

#

but any examples that you know of would do as long as its widely used

plush stream
#

Musicbrainz picard is the first one that came up in my mind.

#

And Qgis

#

Do you want pyqt only apps or qt too?

snow haven
#

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

median ridge
#

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...

sinful pendant
sinful pendant
#

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

sinful pendant
#

Value error

pallid arch
#

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...

digital rose
digital rose
eager viper
#

I'm already using cef:p

tawdry mulch
sinful pendant
#

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

#

😅

tawdry mulch
odd iris
#

uh can anyone help me? the "your money is: {number}" is not working well

#

the number is like bugging

tawdry mulch
sinful pendant
#

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

edgy rivet
#

Here 54 is the font size

proven basinBOT
#

lstbox.py line 10

pyglet.font.add_file('fonts/coolvetica compressed rg.ttf') # Add the task font```
sinful pendant
#

👌

#

When we write the family name then it searches that font in windows font?

tawdry mulch
#

Make sure to give the name of the font, not the name of the file

sinful pendant
#

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

sinful pendant
#

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

digital rose
#

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

burnt hemlock
#

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.

lost dragon
burnt hemlock
#

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

lost dragon
#

I would go with tkinter for that
extremely quick to get started with it

burnt hemlock
lost dragon
burnt hemlock
#

👍

burnt hemlock
#

I thought the default installation of python3 had tkinter included? ModuleNotFoundError: No module named 'tkinter'

tawdry mulch
misty canopy
burnt hemlock
#

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)?

sinful pendant
tawdry mulch
buoyant mural
#

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")```
burnt hemlock
#

Uhm, not sure how to hide the preview =S

copper jungle
#

I am getting spacing between my grid that I don't understand

copper jungle
#

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

tawdry mulch
tawdry mulch
copper jungle
#

I can paste the whole thing if that is better

#

okay

tawdry mulch
proven basinBOT
#

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.

copper jungle
#

sorry the "Quit" button actually remakes the grid

#

this is cleaned up a bit if you havent looked yet

tawdry mulch
copper jungle
#

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...

tawdry mulch
#

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?

copper jungle
#

ya it should be column 0 at the start

#

i think that is your pasting mistake though 🙂

tawdry mulch
#

no no

copper jungle
#

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

tawdry mulch
#

Yep

#

I changed the parent

#

I added a frame and then put the canvas inside it

copper jungle
#

can I see your code please?

#

im not sure how tkinter really works, the whole frame thing

tawdry mulch
#

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()
copper jungle
#

thanks @tawdry mulch I will take a close look

simple heart
#

so im using tkinter, is there a way to use an image/gif as a background?

paper quartz
#

@simple heart I'm still new to tkinter, but the way I've done it is using Label()

simple heart
#

for the background?

#

how have you done it?

#

can you send a code snippet or smtrh

paper quartz
#

@simple heart give me a sec

simple heart
#

oki

paper quartz
#

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

simple heart
#

ah thanks

simple heart
#

also is there a way to send the label to the bac?

paper quartz
#

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.

simple heart
#

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

paper quartz
#

You could create a container (using Frame()) to solve that

simple heart
#

oki

simple heart
paper quartz
#

One sec, let me try to write an example

simple heart
#

ok

paper quartz
#
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

simple heart
#

ah

#

lemme try this

simple heart
#

oh wait what

#

if i place them, it stops workin

paper quartz
#

What's the error

simple heart
#

none

#

it just doesnt show the buttons if i have place

paper quartz
simple heart
#

but if you place them it wont work

paper quartz
#

Hm

simple heart
#

like button.place(x=50, y=20)

paper quartz
#

Have you tried using grids?

simple heart
#

no cos i feel like that would be a waste of time

#

i might try this again another time

tawdry mulch
#

The best way for you is to create a canvas and then create images on top of it

proven basinBOT
#

: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).

royal dove
#

can we make modern GUI with Python?

rocky dragon
#

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

royal dove
#

For example if you want to put certain videos in interface or animation as background is it applicable with tkinter ?

charred aspen
#

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

lucid totem
#

What are buddies in pyqt?

median ridge
digital rose
#

does anyone know how to bind a funtion to clicking on a tab in a ttk notebook?

digital rose
#

ping me if you know

sinful pendant
#

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

young sedge
#

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

sinful pendant
#

Among pyqts and pyaide6 which gives wider range of flexibility@young sedge ?

young sedge
sinful pendant
#

I just like to work in one and get better and better at that

young sedge
#

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

sinful pendant
#

Do tkinter also has commercial use policy?

young sedge
#

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

sinful pendant
#

Haha even though they are good dont think they have been used in good companies

young sedge
#

who kknows

#

anyway, if you need to make quick dumb GUI without any styling, then PySimpleGUI is the best ;b

#

it does fastest job

lime monolith
royal dove
#

i want a GUI Library to make same interface as for example League of Legend's interface

sinful pendant
#

Ohh, so () after fun means it will be called instant,

#

It sounds dumb😅

cursive basin
royal dove
civic heath
#

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

royal dove
#

how to show an animated (GIF) in tkinter as my background

lime monolith
royal dove
#

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()
civic heath
#
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?
lime monolith
civic heath
#

And if I want to change the image i can do panel.image = img2

#

@lime monolith

proven basinBOT
royal dove
#

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

digital rose
#

how would approach integrating a GUI into an async package im developing?

lucid totem
#

how does linkActivated & linkHovered signals work in pyqt label??

royal dove
woeful jasper
#

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

indigo crane
#

tkinter menus kinda look bad, so I made my custom one :)

#

now compare it with the menus provided by tkinter

tawdry mulch
heady brook
#

is it possible to make a good-looking GUI with tkinter?

tawdry mulch
indigo crane
#

its a mess currently, and i'm cleaning up, will try to bring up a library for modern widgets if possible :)

nova palm
#

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?

royal dove
#

for tkinter you need to make thousands of code line and planning for a good modern GUI from Zero