#user-interfaces

1 messages · Page 72 of 1

tawdry mulch
#

If i were to say button(width=30) this 30 is with respect to my screen, but what about a smaller display?

modern marsh
#

which ig you can use to scale individual widgets

modern marsh
#

that is ,scaled too much

tawdry mulch
#

Hmmmmm I see

modern marsh
#

idrk how the width=30 thing works in tkinter

#

cuz i dont think 30 is number of pixels

tawdry mulch
#

I guess my understanding of is wrong somewhere

tawdry mulch
modern marsh
#

hmm

tawdry mulch
#

It is based on pts

#

For labels. I think the same works for buttons too.

modern marsh
#

oh alright

tawdry mulch
modern marsh
#

yeah i dont use tkinter anymore

#

switched to Qt

tawdry mulch
#

Okays, thanks for the help 😄

modern marsh
#

np :D

modern marsh
#

oooo

#

by RiverBank Computing

#

i suppose you can make mobile apps with pyqt after all

#

for pyside

leaden tiger
#

hello, can somebody explain me an error message?

brittle bolt
leaden tiger
#

i use buttons and images for a card game ... if i use the method grid_forget no error occurs, but i dont know why 3 of 5 buttons stay on screen and they should disappear ... if i use the method destroy i get at least this error message, but i dont understand it

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.9/tkinter/init.py", line 1892, in call
return self.func(*args)
File "/mnt/linux_d/Python/PyCharmSchnapsenGUINew/main.py", line 383, in <lambda>
command=lambda i=i: player1click(i)))
File "/mnt/linux_d/Python/PyCharmSchnapsenGUINew/main.py", line 32, in player1click
playedcomputercard.configure(image=newimage)
File "/usr/lib/python3.9/tkinter/init.py", line 1646, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.9/tkinter/init.py", line 1636, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".!myownbutton3"

tawdry mulch
#

It means the button is destroyed and cannot be reused. Show the code? @leaden tiger

leaden tiger
#

my code is about 450 lines

tawdry mulch
#

!paste

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.

leaden tiger
sullen thunder
#

Hey is there a best practice for developing a GUI for variable screen resolutions?

tawdry mulch
sullen thunder
#

Currently I am just planning to address it one screen at a time and manually check the 3 primary resolutions.

modern marsh
#

check the Qt forums

sullen thunder
#

Yeah I will do some research. Just thought I would poke in and ask. I will report back

leaden tiger
#

@tawdry mulch is the code readable?

rugged marsh
#
from tkinter import *

root = Tk()
root.geometry('300x130')

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default value

w = OptionMenu(root, currencies1, *OPTIONS)
w.config(font=("Arial Rounded MT Bold", 20))
w.grid(row=0, column=0)

def swap():
    cur1option = currencies1.get()
    cur2option = currencies2.get()
    currencies1 = cur2option
    currencies2 = cur1option
swapButton = Button(root, text="Swap", command=swap)
swapButton.grid(row=1,column=0)

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies2 = StringVar(root)
currencies2.set(OPTIONS[1]) # default value

w = OptionMenu(root, currencies2, *OPTIONS)
w.config(font=("Arial Rounded MT Bold", 20))
w.grid(row=2, column=0)

This is my code, and I wanna swap options when "Swap" Button is pressed. But it gives me an error when I press instead:

    cur1option = currencies1.get()
UnboundLocalError: local variable 'currencies1' referenced before assignment
#

why is that?

sullen thunder
# tawdry mulch I've been trying to find the answer too 😦

Interesting to see, how I am not alone. I scrolled up to see your issue. I do agree with using Pyside/PyQt for the project over tinker. I am biased though.

I know for my situation I plan to adjust me interface designs to adjust based upon the received screen size. Just a slow approach, got like 15 screens to work on.

modern marsh
#

don't import * :(

#

huh

#

why are there two OPTIONS

tawdry mulch
leaden tiger
#

yeah, i told you its about 450 lines 🙂

#

i checked the buttons which he should hide and he counts 5 buttons ... so normally they should all disappear

tawdry mulch
#

What I meant is there are pictures and module that IDH from your code, which wont run. @leaden tiger

leaden tiger
#

what do you mean?

tawdry mulch
#

Your code uses pictures and some modules named 'Classes'. Since I dont have those, I cannot run this.

leaden tiger
#

do you want a screenshot?

#

classes is a different file

#

i just pasted two files in one paste

#

1-58 is file classes and the rest is file main

tawdry mulch
#

Oh god, should've said it.

leaden tiger
#

sorry 😦

#

the game looks like this

tawdry mulch
#

Where do you use grid_forget, line number I mean

shadow perch
#

you should make the cards simpler in my opinion

leaden tiger
#

line 215 and 237

tawdry mulch
#

I am sorry, the code is not debuggable. I would recommend you use print() and verify the values and then proceed slowly. @leaden tiger

leaden tiger
#

i already did that :( ... which variables do you mean exactly?

tawdry mulch
#

Which all widgets you expect to disappear. Use print() on them and make sure they are accessible?

leaden tiger
#

do you mean print(button)? i checked on those two lines (215 and 237) the buttons which the gui should hide. every computer button appears in command line

amber sorrel
#

Hey I had an idea to make a GUI for viewing pdfs from scratch and also merge multiple pdfs into one. Anyone has any idea for making it happen ?

ivory ember
lament rampart
#

Hello, I am working with pyqt5 and his tools currently and i want when to click a button to go from the current .ui, that i have designed, to another .ui. I achieved that with using stacked widget(widget= QtWidgets.QStackedWidget()) and then widget.addWidget(ui that i want to go) and finally widget.setCurrentWidget(...). The problem was when i went to another python file and imported the widget variable and did the same thing and pops the message "Process finished with exit code -1073740791 (0xC0000409)" (IDE:Pycharm) and then it exits. But when i am working with all my classes in the same file i dont have a problem. Is there any way to solve that? Thanks in advance.

tawdry mulch
leaden tiger
#

@tawdry mulch if you want i can send you the pictures in private chat ... i am searching for the error since 1 week

remote ravine
#

hey anyone knows how t properly remove a widget from a layout ( I am trying to remove every widget from the layout)

#
for i in reversed(range(self._vbox.count()-1)):
  self.layout.removeItem(self.layout.itemAt(i))
  # or 
  self.layout.itemAt(i).widget().setParent(None)
  # or
  self.layout.itemAt(i).widget().deleteLater()
#

nothing worked so far (the solutions above do not work)

tawdry mulch
ivory ember
#

@remote ravine please let me know if that works

hybrid spindle
#

just starting to play around with pyqt. Trying to have multiple tabs with plots. Currently, my script is plotting all figures under the last created tab. How would one specify a tab to connect each figure to?

rugged marsh
tawdry mulch
rugged marsh
#

It acts like the updownarrowbutton here

tawdry mulch
rugged marsh
#

Okay

#

Ahh i get it

#

Thanks

rugged marsh
#

@tawdry mulch

#

i tried this....

#
from tkinter import *

root = Tk()
root.geometry('300x130')

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default value

w = OptionMenu(root, currencies1, *OPTIONS)
w.config(font=("Arial Rounded MT Bold", 20))
w.grid(row=0, column=0)


def swap():
    print(currencies1.get())
    print(currencies2.get())
    w.config(text=currencies2)
    z.config(text=currencies1)
swapButton = Button(root, text="Swap", command=swap)
swapButton.grid(row=1,column=0)

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies2 = StringVar(root)
currencies2.set(OPTIONS[1]) # default value

z = OptionMenu(root, currencies2, *OPTIONS)
z.config(font=("Arial Rounded MT Bold", 20))
z.grid(row=2, column=0)





#

no errors, but didnt swap too

tawdry mulch
#

Hmmmmm why dont you rethink your approach, you are using lists

#

and then you try to set to a single word

#

And I recommend using ttk.Combobox.

#

@rugged marsh

rugged marsh
#

Sure! Ty for the suggestion :)

tawdry mulch
#

I just did that for you

#
from tkinter import *
from tkinter import ttk

root = Tk()
# root.geometry('300x130')

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default value

w = ttk.Combobox(root, textvariable=currencies1, values=OPTIONS)
w.config(font=("Arial Rounded MT Bold", 20))
w.grid(row=0, column=0)

def swap():
    print(currencies1.get())
    print(currencies2.get())
    a,b = currencies2.get(),currencies1.get()
    currencies1.set(a)
    currencies2.set(b)

swapButton = Button(root, text="Swap", command=swap)
swapButton.grid(row=1,column=0)

currencies2 = StringVar(root)
currencies2.set(OPTIONS[1]) # default value

z = ttk.Combobox(root, textvariable=currencies2, values=OPTIONS)
z.config(font=("Arial Rounded MT Bold", 20))
z.grid(row=2, column=0)

root.mainloop()
#

@rugged marsh

#

I made a few changes, check again

rugged marsh
#

Tyvm, lemme try runnin it.

rugged marsh
#

IT WORKS!!! THANK YOU SO MUCH!!! @tawdry mulch \

rugged marsh
#

how can i change the size of a dropdown option box in tkinter?

#

see? the text INSIDE gets out of the box

eager beacon
#

I'd start by changing the font size to something smaller than what you are using right now.

#

Did you get it working?

rugged marsh
#

Cuz i gotta make it large to match the big screen

digital rose
#

I think combobox has a width attribute. Try this:

z = ttk.Combobox(... .. . , width=10)
 .. .. 
#

@rugged marsh

rugged marsh
#

Thanks

digital rose
# rugged marsh Thanks

If that doesnt work you can instead use the expand option in .pack() by saying something like this:

z.pack(side=TOP, fill=X, expand=True)
#

So that it expands horizontally to fit the size of the screen whenever you resize the window.

#

You can even say fill=BOTH so it completely resizes, not just horizontally. @rugged marsh

rugged marsh
#

hi

#
convertButton = Button(root, text="Convert", command=button_command, bg='blue')
convertButton.grid(row=1,column=3)
eager beacon
#

The code you had originally looked find on a mac

rugged marsh
#

can anyone tell me why the button is still not blue?

rugged marsh
#

/wdym

#

im using a mac, yeah

eager beacon
#

On my machine the characters were within their combo boxes

rugged marsh
#

why???

eager beacon
#

idk

rugged marsh
#

why not mine???

eager beacon
#

i just copied and pasted what you posted

rugged marsh
#

oh i wasnt using combo box

#

thats why

eager beacon
#

hmm, I think you were..

rugged marsh
#

hmm

#
# Import tkinter
from tkinter import *

#

ok now this is what i did

#
w = ttk.Combobox(root, textvariable=currencies1, values=OPTIONS)
#

what i inserted

#

it said something about name 'ttk' is not defined

#

@eager beacon

eager beacon
#

so add from tkinter import ttk

rugged marsh
#

ok,

#

just did

#
 w = ttk.Combobox(root, currencies1, *OPTIONS)
TypeError: __init__() takes from 1 to 2 positional arguments but 13 were given
#

now this

#

@eager beacon

eager beacon
#

remove the * from OPTIONS

rugged marsh
#

@eager beacon

#

looks kinda strange

#

not the font, i changed it

eager beacon
#

Yeah I don't know. Maybe the widget containing the combo boxes doesn't have enough room to expand... I don't really use Tk

eager beacon
digital rose
#

That would throw an error.

rugged marsh
#

don't know what u mean

digital rose
#

It does.

#

Look up the docs.

rugged marsh
#

so... what should i do

eager beacon
#

run the code from the post above

digital rose
rugged marsh
eager beacon
#

No errors

rugged marsh
#

the font size is 20, not 30

#

ah

#

thx @digital rose

digital rose
#

Use the .pack () instead of grid.

rugged marsh
#

but my whole code is using grid

#

dont wanna change

eager beacon
#

30 works just the same for me 🥲

digital rose
#

You can do that only for these three widgets, the two comboboxes and the swap button.

rugged marsh
#

hm

#

lemme try

digital rose
#

Here, i did it for you.

from tkinter import *
from tkinter import ttk

root = Tk()
# root.geometry('300x130')

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default value

w = ttk.Combobox(root, textvariable=currencies1, values=OPTIONS, width=10)
w.config(font=("Arial Rounded MT Bold", 10))
w.pack(side=TOP, fill=BOTH, expand=True)

def swap():
    print(currencies1.get())
    print(currencies2.get())
    a,b = currencies2.get(),currencies1.get()
    currencies1.set(a)
    currencies2.set(b)

swapButton = Button(root, text="Swap", command=swap)
swapButton.pack(side=TOP)

currencies2 = StringVar(root)
currencies2.set(OPTIONS[1]) # default value

z = ttk.Combobox(root, textvariable=currencies2, values=OPTIONS)
z.config(font=("Arial Rounded MT Bold", 10))
z.pack(side="top",fill=BOTH, expand=True)

root.mainloop()
rugged marsh
#

cant use this code without using pack?

digital rose
#

Try running this code.

#

You'll see enlarged combo boxes.

rugged marsh
#

is this not available to grid?

digital rose
#

No.

#

Those args are for .pack()

rugged marsh
#

...

digital rose
#

Did you run it?

rugged marsh
#

no unfortunately, cuz using pack means i gotta change my whole code literally

digital rose
#

You can run this code in a new file

rugged marsh
#

and im not very good at using pack

#

it's not very long thou

digital rose
#

Dont change what you presently have, just run it in a new file.

rugged marsh
#

mind teaching me about pack?

#

so i can use it in the future

#

@digital rose

digital rose
#

You can look it up in the docs, its impossible to teach so many arguments within pack. Just briefing you about it:
Pack is just another geometry method to render widgets only, and the arguments i use are:
side, fill, and expand.

rugged marsh
#

padx, pady?

digital rose
#

what?

rugged marsh
#

does using pack means i gotta delete all grid stuff?

#

if yes, so be it, imma learn pack today

digital rose
#

I did that for you. Just run my code in a separate file.

rugged marsh
#

oh

#

ok]

rugged marsh
#

this is just my testing code

#

this is my whole code

#

ahh no

#

not this

#

sorry

#

this Î

#

@digital rose

digital rose
#

Erm, you just need to this:

widget.grid(.. .. . )

To:

widget.pack(side=TOP, fill=BOTH, expand=True)
#

Thats all.

#

You dont need to do anything else.

rugged marsh
#

oh

#

thanks

digital rose
#

It would've been better to understand this if you would've run my code there.

rugged marsh
#

so my .grid(row=0,column=0 can be kept

#

?

digital rose
#

No , replace that with the pack statement.

rugged marsh
#

so change all of that?

digital rose
#

You can comment it out if you dont want to remove it.

rugged marsh
#

nah imma duplicate my file

digital rose
#

Thats what ive been saying for the past 15 minutes 😆

rugged marsh
#

??

#

?!?!

#

:(

#

im depressed

digital rose
#

Thats an example of how you can expand your combobox.

rugged marsh
#

...

digital rose
#

Theres no other built-in way, except to just change your font size.

rugged marsh
#

oof

#

k

#

thanks all @eager beacon @digital rose

modern marsh
#

how do Tk widgets look on mac?

#

non ttk

eager beacon
#

did you ever use windows 3.1?

digital rose
modern marsh
#

oh ok

digital rose
#

@rugged marsh i get this on my windows machine, and it does increase the size of the entry in the combo box.

rugged marsh
#

Using mac

digital rose
#

i dont really know whats wrong with the size increase on your mac.

rugged marsh
#

different os diff results

digital rose
#

mm hmm.

eager beacon
#

Which Macos version are you using?

digital rose
#

@eager beacon does this code work for your mac?

rugged marsh
#

11.0.1

digital rose
eager beacon
#

which version of the code?

digital rose
#
from tkinter import *
from tkinter import ttk

root = Tk()
# root.geometry('300x130')

OPTIONS = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD"
] #etc

currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default value

w = ttk.Combobox(root, textvariable=currencies1, values=OPTIONS, height=10)
w.config(font=("Arial Rounded MT Bold", 20))
w.pack(side=TOP, fill=BOTH, expand=True)

def swap():
    print(currencies1.get())
    print(currencies2.get())
    a,b = currencies2.get(),currencies1.get()
    currencies1.set(a)
    currencies2.set(b)

swapButton = Button(root, text="Swap", command=swap)
swapButton.pack(side=TOP)

currencies2 = StringVar(root)
currencies2.set(OPTIONS[1]) # default value

z = ttk.Combobox(root, textvariable=currencies2, values=OPTIONS, height=100)
z.config(font=("Arial Rounded MT Bold", 20))
z.pack(side="top",fill=BOTH, expand=True)

root.mainloop()
#

this one.

eager beacon
#

When I increase the font size it forces the combobox to make room for the new font size

#

let me see

#

I get this

digital rose
#

for the code i just sent?

eager beacon
#

Yes

digital rose
#

try maximising the window.

#

the boxes should expand.

eager beacon
#

They do

digital rose
#

@rugged marsh try maximising then. it should fix your problem.

eager beacon
digital rose
#

phew! it works finally.

eager beacon
#

you don't even need to maximize, just increase the size of the window

digital rose
rugged marsh
#

K

#

Maybe tmr i gtg rest

remote ravine
eager beacon
#

What are you trying to do?

remote ravine
#

nvm

#

for some reason i had to make a tuple first and iterate over it and remove each widget object with self.layout.removeWidget(widget)

#

weird

#
@QtCore.pyqtSlot()
def _remove_all_items(self) -> None:
    widgets = (self._vbox.itemAt(i).widget() for i in reversed(range(self._vbox.count())))
    for widget in widgets:
        self._vbox.removeWidget(widget)
#

seems to work

eager beacon
#

If you're not going to use the widget again you should call widget.deleteLater() also

remote ravine
#

so

eager beacon
#

removing the widget does not delete the widget from memory

remote ravine
#

oh

#

thank you

eager beacon
#

sure

remote ravine
#
@QtCore.pyqtSlot()
def _remove_all_items(self) -> None:
    widgets = (self._vbox.itemAt(i).widget() for i in reversed(range(self._vbox.count())))
    for widget in widgets:
        self._vbox.removeWidget(widget)
        widget.deleteLater()
```like this ?
eager beacon
#

yeah

remote ravine
#

nice

#

thank you !

#

is it worth looking into qt6 already ?

eager beacon
#

nope

remote ravine
#

oki

eager beacon
#

Stay away until 6.2

#

There are still a lot of things missing

remote ravine
#

i aint touching qt6 till KDE (like DE like Gnome) switches to qt6

eager beacon
#

then you've probably got some time 🙂

remote ravine
#

yeah. indeed

#

anyways... thank you !

eager beacon
#

no problem

digital rose
#

Do you use tkinter? DM! me if you want to join a cool tkinter based server!

digital rose
#

is there a way to manipulate a GUI lib to generate multiple input cursors in a text box? i dont need to stick to a particular lib, like tkinter, or PyQT, just wanted to get this done.

tawdry mulch
tawdry mulch
#

@digital rose invite meh in!

tawdry mulch
tawdry mulch
#

@rugged marsh Just post a screenshot of expected result, ill try to recreate it

tulip cedar
#

Hey I'm a bit new out here.
Idk of my question makes a lot of sense but I've been trying to develop an application that can be used on desktop, iOS and Android systems. I ONLY know python as a programming language and want to avoid using html, css javascript throughout the app making process.
Is there a way to do that if I need a decent enough UI/UX interface?

#

I don't know how to use any of the python frameworks like django, flask, pyqt, Tkinter, etc but would be willing to learn anything that involves python as a programming language

modern marsh
#

you can use PySide or PyQt but uhh

#

there is not enough documentation on it

#

if you can learn other stuff, try out Qt Quick

digital rose
#

yo what are thesee

tawdry mulch
digital rose
#

Okay any idea on how to remove them???

#

or not include them in a list?

#

@tawdry mulch

#

I've been trying to get rid of them in my list for 2 hours now

#

also they're Label related

#

not Entry boxes

abstract crown
#

and what are you trying to do?

digital rose
#

Im trying to create multiple labels using loop

#
def Average_Equation(First, Second, Third, Fourth):
    Average_Cell = eval(str((int(Data[First].get())+int(Data[Second].get())+int(Data[Third].get())+int(Data[Fourth].get()))/4))
    Average_of_Cells.append(Average_Cell)
    print(Average_of_Cells)
    for Repeat, Loop in zip(Number_Of_Labels,Average_of_Cells): 
        Loop.config(text=list(zip(Number_Of_Labels,Average_of_Cells)))
#

this is what comes out :/

#

and also

for Repeat in Number_Of_Labels:
    Label_4_Average = Label(screen, text=Average_of_Cells, font=('TkDefaultFont', 20, 'bold'))
    Average_of_Cells.append(Label_4_Average)
    Y_Label += 80
    Label_4_Average.place(x=200, y=Y_Label)
#

This is what I used to actually display

abstract crown
#

so your trying to make a grid system that lets you place labels inside of the area of the grid?

tawdry mulch
#

What do you expect to come? @digital rose

digital rose
tawdry mulch
#

First use print() and verify what Data[First] is then Data[First].get(). @digital rose

modern marsh
#

Whats the use of adding the @slot decorater ?

digital rose
#

how do i set a footer at the top of the tkintr?

digital rose
dry jungle
#

Is there anyone who could freeze (compile) the PySide6 project? I think that I can't find any "middle-difficult" solution for this. PyInstaller seems not working with it. FBS is paid. Cxfreeze... Well, I have a mess with it. So isn't there any way to compile my project?

dry jungle
# dry jungle Is there anyone who could freeze (compile) the PySide6 project? I think that I c...

Okay, I somehow made it to work. I don't know which step helped me, but I've done this: upgraded cxfreeze with pip --upgrade cx_Freeze PySide6 (similarly as in cx_freeze PySide2 example on GitHub), move build catalog into the direction without Cyrillic symbols, then I noticed, that it tells about missing .qss file - when I added it into catalog with the executable, then it started working.

modern marsh
#

Same follows for another new and upcoming tool called nuitka

#

Pyside is releasing version 6.1 this or next week

#

And there is supposedly full nuitka support for it

dry jungle
modern marsh
#

I do not know about that

#

Just gave you another option

digital rose
#

Does anyone know how mouseevent flags work in pyside 6? I tried looking at the both dir(event.flags()) and help(event.flags()), and tried reading documentation aswell and doing a bunch of googling, but I can't find anything on how the flags attribute works. The reason I'm trying to figure this out is because I want to get the pos of the mouse click, but all the methods to do so are depreciated except for event.flags(), which supposedly has the details of the event inside of it.

digital rose
#

Nevermind, I'm a fool, there's a function for what it inherits called "position()" that does what I need

unique forge
#

I'd say PyQt

wooden bough
#

I've been using tkinter, and most of it i get. However when I try to incorporate classes that create a button or canvas or oval it; it starts falling apart.

#

Maybe i should avoid using classes? I've been getting overwhelmed at that stage.

fiery flare
#

can i set up turtle with tkinter?

#

like setting up the turtle thing on a canvas of tkinter is it possible?

digital rose
# wooden bough I've been using tkinter, and most of it i get. However when I try to incorporate...

It depends on what you've been doing with your classes. The only thing i literally do is use classes! This is how a small program will look for me in tkinter, every time i start making one from scratch.

from tkinter import *

class Foo(Canvas):
    # the class name that is changed everytime.
    pass

class MainWindow(Tk):
    def __init__(self,):
        Tk.__init__(self)

This is a template i use everytime. The way you're incorporating classes could be wrong. It could not be a reason to discard the use of classes.

digital rose
#

As far as i know, you can only use a Turtle object on a turtle.Screen() instance.

modern marsh
#

classes are best

austere sun
#

Anyone got any tips for making TUIs look good?

rough isle
digital rose
#

I made this in Tkinter it is good?

tall mesa
#

Hi i am making second window in my app, and i cant change variable in Entry (after running the entry is empty, even if there should be "hello")

#
def new_file(*input):
    global filename, textn1, textn2, textn3
    window_new = tkinter.Tk()
    window_new.title("New File")
    filename = askopenfilename()
    label1 = tkinter.Label(window_new, text="FileName")
    label2 = tkinter.Label(window_new, text="FileExtension")
    label3 = tkinter.Label(window_new, text="Description")
    textn1 = tkinter.StringVar()
    textn1.set("hello")
    textn2 = tkinter.StringVar()
    textn3 = tkinter.StringVar()
    in1 = tkinter.Entry(window_new, textvariable=textn1)
    in2 = tkinter.Entry(window_new, textvariable=textn2)
    in3 = tkinter.Entry(window_new, textvariable=textn3)
    label1.grid(row=0, column=0)
    label2.grid(row=1, column=0)
    label3.grid(row=2, column=0)
    in1.grid(row=0, column=1)
    in2.grid(row=1, column=1)
    in3.grid(row=2, column=1)
    window_new.mainloop()
digital rose
tall mesa
#

Ok thank you so much 😄 It works now

digital rose
#

when you want to insert text to Entry do.insert(index:int, text:str) :

my_entry.insert(0, "Hello")

and when you want to insert it at the end without int index do:

my_entry.insert(tkinter.END, "Hello")
tall mesa
#

Oh ok. But maybe i will use tk variables. Idk why but it is more comfortable for me to use.

digital rose
#

yes but as the usual way and the best way to insert text to Entry is the .insert(index:int, text:str) function it's made for that 👍🏼

tall mesa
#

Ok. I will look more into that

digital rose
#

keep going in Tkinter 👍🏼

tall mesa
#

Thanks 😄

digital rose
#

you are welcome

tall mesa
#

I have another problem. I have two listboxes in app (list1, list2) and i have bind on list1 if i select something. But it activates even, if i select something in list2. And function list1.selection_get() returns what i selected in list2 !! pls would you help me?

digital rose
#

did you want to call a func when the listbox have focus

tall mesa
#

I want to call func when i click on element in list1 (left) and another function on element list2 (right) But when i click on list2 list1 function is activated

digital rose
#

make tow different functions for list1 : list1.bind("<<ListboxSelect>>", list_1) and list2 : list1.bind("<<ListboxSelect>>", list_2)
or ?

tall mesa
# tall mesa

This is function for list1. But idk why it gets called even if i click on the list2

#

And function for list2 is not done yet. But this was causing errors (thanks god for try: except: XD)

digital rose
#

strange did you call it with bind in the another list list2 and you didn't know?

proven basinBOT
tall mesa
#

This is my code. I sent most important parts in screenshots, but i could have missed something.

digital rose
#

nice I will take a look at it

#

how do i att text to tkinter?

digital rose
tall mesa
#

Yeah, because it is connecting to my API...

digital rose
#

and give me error after a while

digital rose
#

do you want a text showing on ?

#

yrs

digital rose
#

to the tkinter.Text

#

idk.. i am new to this

tall mesa
#

And also i think Text is wrong command you should use Label (text is used for input as far as i know)

digital rose
#

oh ok, ty

#

did you mean Text the multi line text ? because tkinter.Text is for that

#

but if you want just output text uneditable use tkinter.Label instead

digital rose
#

because

#

tkinter.Text doesn't have text command like tkinter.Label

#

it's just multiline input text

tall mesa
#

also you have "," so it will be syntax error and i think there needs to be root/window too?

digital rose
#

Im new to tkinter, but why does this not work?

def accountcreate():
    label = tk.Label(text="What would you liek your username to be?")
    entry = tk.Entry()
    entry.pack()
    label.pack()
    frame.mainloop()
    username = entry.get()
#

This is outside of that

frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')```
#

what is the Error?

#

Nothing

#

It just does nothing

#

i cant see any problem

#

It just sits there like a potato

#

ah

#

easy

tall mesa
#

I would suggest to add button to function, where would be entry.get()

#

or something like that

digital rose
#

just cut that frame.mainloop() to the last line of your file

#

Hmm

#

Well

#

That did something

#

But not the right thing

#

It now just skips over it

#

call the function ? accountcreate()

#

?

#

Oh

#

Thats called in another function tho

#

like:

import tkinter as tk
frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')
def accountcreate():
    label = tk.Label(text="What would you liek your     username to be?")
    entry = tk.Entry()
    entry.pack()
    label.pack()
    username = entry.get()

accountcreate()
frame.mainloop()
#

Uh

#

More like

#
from tkinter import *
frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')
def accountcreate():
    label = tk.Label(text="What would you liek your     username to be?")
    entry = tk.Entry()
    entry.pack()
    label.pack()
    username = entry.get()
def start():
    accountcreate()
start()
frame.mainloop()
digital rose
digital rose
#

the list1 function dosen't have self parameter

#

and it's required to work on .bind function

#

try:

def update_inputs(self, *input):
    ...
digital rose
#

I can confirm it does not

#

this mean your IDE actually have a problem

#

Im using python idle

tall mesa
#

prints in except

digital rose
tall mesa
#

I mean in original python idle

digital rose
tall mesa
#

But this does not seem like original python idle

digital rose
# digital rose What do i need?

try this:

import tkinter as tk
frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')

def accountcreate():
    label = tk.Label(frame,text="What would you liek your     username to be?")
    entry = tk.Entry()
    entry.pack()
    label.pack()
    username = entry.get()

def start():
    accountcreate()

start()
#

if not working this mean this is not original python idle

#

Ya it does not work, does the same as before, just skips it over

#

I have alot more code than that tho

digital rose
# digital rose Ya it does not work, does the same as before, just skips it over

try this if not working your idle have a problem:

import tkinter as tk
frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')

def accountcreate():
    label = tk.Label(frame,text="What would you liek your     username to be?")
    entry = tk.Entry()
    entry.pack()
    label.pack()
    username = entry.get()

def start():
    accountcreate()

start()
frame.mainloop()
#

Ahem

#

It does not work

tall mesa
#

Ok i am trying to make working code with this i will send it to you

digital rose
#

your IDLE have a problem

#

to fix it

#

check your python include path

#

it's important to add bin and lib

tall mesa
#

This does not work on my pc too

#

I will redo it

digital rose
digital rose
# tall mesa This does not work on my pc too

this is working for me:

import tkinter as tk
frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')

def accountcreate():
    label = tk.Label(frame,text="What would you liek your     username to be?")
    entry = tk.Entry()
    entry.pack()
    label.pack()
    username = entry.get()

def start():
    accountcreate()

start()
frame.mainloop()
digital rose
digital rose
tall mesa
#
import tkinter as tk
frame = tk.Tk()
frame.title("Testing Program")
frame.geometry('400x200')


def accountcreate():
    label = tk.Label(frame,text="What would you liek your     username to be?")
    entry = tk.Entry()
    button = tk.Button(frame, text="test", command=lambda: print(entry.get()))
    entry.pack()
    label.pack()
    button.pack()

def start():
    accountcreate()

start()
frame.mainloop()
#

This works 100%

digital rose
tall mesa
#

You have button to test it (print username)

digital rose
tall mesa
digital rose
digital rose
#

but this is not his problem

#

Ok

tall mesa
#

His program is running

#

he sent screenshots did not he?

digital rose
#

It does run

tall mesa
#

Try my code and tell us if it prints right thing

digital rose
#

yes

#

if not you will have a problem with the library

#

Still skips over it and moves on to the other part of the code @tall mesa

tall mesa
#

You are running it with another code right? Then there must be error there. Because this is running on my machine and printing that user wrote into entry

digital rose
#

Can i just send all my code, would make it alot easier to explain

tall mesa
#

Paste the code there, save and send us the link

digital rose
#

your app work well but why you use tkinter if your app just use prints?

#

Im starting to change it from print to tkinter

tall mesa
#

Just erase everythink and make it in tkinter. It will be more easy

#

But the window opens if you do this:

#
def accountcreate():
    frame = tk.Tk()
    frame.title("Testing Program")
    frame.geometry('400x200')
    label = tk.Label(frame,text="What would you liek your     username to be?")
    entry = tk.Entry()
    button = tk.Button(frame, text="test", command=lambda: print(entry.get()))
    entry.pack()
    label.pack()
    button.pack()
    username = entry.get()
    frame.mainloop()
    if os.path.isfile("Users/" + username + '.txt'):
        print("You have an account already\n")
        login()
    else:
        password = input("What would you like your password to be?\n")
        f = open("Users/" + username + '.txt', "w")
        f.write(password)
        f.close()
        print("Account has been created, please login\n")
        login()
#

but it will not work

digital rose
#

Ty

#

and you will take a look at it

#

yes

digital rose
#

not working for me

tawdry mulch
tawdry mulch
#

There are controllers and frame switching with tkinter available with OOP.

tawdry mulch
digital rose
tawdry mulch
tawdry mulch
digital rose
tawdry mulch
#

Seems fine, though the first statement is useless, you can remove it.

#

What is the problem you are facing?

digital rose
#

this is what i get

tawdry mulch
#

To begin with, I would never use place(), I would use grid().

#

Much easier

gritty tree
#

hey guys is possible to call a tkinter function every microsecond instead of a millisecond?

tawdry mulch
#

Yes, millisecond*1000 @gritty tree

digital rose
gritty tree
#

isnt that a second? @tawdry mulch u mean ms/1000_

tawdry mulch
#

@digital rose It uses rows and columns

tawdry mulch
#

But I would discourage it though. It might cause slight delay to other events being processed

gritty tree
#

@tawdry mulch i receive a bad argument error...

tawdry mulch
#

Give an example? @gritty tree

gritty tree
#

window.after(1/500,Lettura())
bad argument "0.002": must be cancel, idle, info, or an integer

tawdry mulch
#

Hmm as i thought you cannot pass in decimals

#

That means the min value that you can pass is 1 microseconds

#

Less than that is not acceptable

gritty tree
#

im basically making an oscilloscope with arduino, and i have to read data from it very often with 1ms i can only receive 500hz signal or less

tawdry mulch
tawdry mulch
gritty tree
#

which alternative i have to tkinter?

digital rose
tawdry mulch
#

What do you want to use?

gritty tree
tawdry mulch
#

Oh you mean in terminal?

#

Oh sorry my bad, since this UI channel, I thought you were referring to one.

#

Use if else?

tawdry mulch
gritty tree
#

it can happens in less than a ms?

tawdry mulch
#

It does not take any arguements. As long as there is no events to process. func will be called

#

I recommend you ask this question on stackoverflow, there might be someway that I am not aware of.

digital rose
digital rose
tawdry mulch
#

take input from user? What do you want to display? @digital rose

digital rose
#

If you want the user to be re directed to a page, you can create an instance of a Toplevel() (in tkinter.).

#

Ah.

#

A naive yet okay-ish approach could be to store the different pages in a dict and clear the terminal at every interval, using something like

os.system('cls')

which is just an example.

#

Your program structure could look like this:

Take input
Process it
Clear page
Draw new page
#

@digital rose

tawdry mulch
#

And how is this related to UI ? @distant abyss

distant abyss
#

wrong channel my bad

hybrid spindle
#

in tkinter, is there a way to save user inputs as a variable? Everything I can find just uses a throw away function in the Entry command and idk how to use the inputs further downstream.

What im exactly after is to have the initial window ask the user for a filename and a couple other parameters, then based on the loaded data it can open up multiple new windows to display that information. But no idea how to use the user input outside of the command function for said entry

tawdry mulch
#

Use global @hybrid spindle

hybrid spindle
#

I did 😦 even tried throwing global in every class. Idk maybe im an idiot and forgot how to use global lmao

tawdry mulch
#

Shw an exampel?

eager beacon
hybrid spindle
# tawdry mulch Shw an exampel?

`def load_dat():
global filepath
filepath = datapath_txt.get(1.0,"end-1c")
if filepath:
newWindow = tk.Toplevel(app)

datapath_txt = tk.Text(self,height=3,width=30)
datapath_txt.pack()

pulldat = tk.Button(self,text='Use Path',command=load_dat)
pulldat.pack()

print(filepath)`

tawdry mulch
#

!code

proven basinBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

hybrid spindle
#

it always screams at me when i do three🤷‍♂️

#
def load_dat():
            global filepath
            filepath = datapath_txt.get(1.0,"end-1c")
            if filepath:
                newWindow = tk.Toplevel(app)

datapath_txt = tk.Text(self,height=3,width=30)
datapath_txt.pack()
        
pulldat = tk.Button(self,text='Use Path',command=load_dat)
pulldat.pack()
        
print(filepath)
tawdry mulch
#

Nothing seems wrong

hybrid spindle
#

printing filepath yields ' ' or none.

I suppose I can just make the main program inside that load_dat() function though

shrewd raven
hybrid spindle
shrewd raven
#

you could use self to store the variable as an attribute of your class? self.filepath = ...

#

idk if its best practice or not, but when im doing oop i put literally everything within one class or another, and my if __name__ == "__main__" only contains the instance of my class main or similar, and i avoid globals and only use class method locals (ie not self.something) when its a throwaway or temporary variable.

hybrid spindle
tawdry mulch
#

Paste the entire code? @hybrid spindle

shrewd raven
#

oop guis can be a right pain to get going with, but once you get past the initial stages and it clicks, youll be making them like its nothing at all

tawdry mulch
#

Why is a pain ? 😉 @shrewd raven

shrewd raven
#

to begin with it just doesnt make sense in context of a gui, it gets frustrating especially if you havent done much with oop. but it gets very easy very fast after the initial learning curve

tawdry mulch
#

Hmmm OOP is more flexible but if you ask me, I don't use OOP for simple projects at all @shrewd raven

#

indeed NONE of my projects use OOP

#

I mean the main projects dont, I use OOP to make widgets though

hybrid spindle
# tawdry mulch Paste the entire code? <@!530207557252415508>
class App(tk.Tk):
    def __init__(self,*args, **kwargs):
        tk.Tk.__init__(self,*args,**kwargs) 
        container =  tk.Frame(self)
        container.pack(side='top', fill='both', expand=True)
        container.grid_rowconfigure(0,weight=1) 
        container.grid_columnconfigure(0,weight=1)
        self.container = container
        
        self.frames = {}
        frame = StartPage(container, self)
    
        self.frames = frame
        frame.grid(row=0,column=0,sticky='nsew')  
        self.show_frame(StartPage)
        
    def show_frame(self,cont):
        frame = self.frames
        frame.tkraise()
        
class StartPage(tk.Frame):
    def __init__(self,parent, controller):
        global filepath
        tk.Frame.__init__(self,parent)
        label = tk.Label(self,text = "File Path", font = LARGE_FONT) #page title
        label.pack(pady=10,padx=10)
        
        def load_dat(self):
            global filepath
            filepath = datapath_txt.get(1.0,"end-1c")
            self.filepath = filepath
            data = Load(filepath)
            print(data.wave)
            if filepath:
                newWindow = tk.Toplevel(app)
                
                f = Figure(figsize=(8,6),dpi=100)
                axes = f.add_subplot(111)
                axes.plot([1,2,3,4,5,6,7],[1,2,3,4,5,6,7])

                canvas = FigureCanvasTkAgg(f,self)
                canvas.draw()
                canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)

                toolbar = NavigationToolbar2Tk(canvas,self)
                toolbar.update()
                canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)      
            
            
        datapath_txt = tk.Text(self,height=3,width=30)
        datapath_txt.pack()
        
        pulldat = tk.Button(self,text='Use Path',command=load_dat)
        pulldat.pack()
#

Ideally I'd like to have another class or two similar to StartPage that initializes new windows after the user inputs the filepath. But couldn't figure out how to pass the container to the load_dat() function for it to do this. I'd rather it not open up an entirely new window with TopLevel, but that was all I could get working

tawdry mulch
#

Still foggy to me

#

What is datapath_txt? @hybrid spindle

hybrid spindle
tawdry mulch
#

What is the issue with this code?

#

Seems fine to me

hybrid spindle
#

I was hoping to avoid using the toplevel and opening a new window. Wanted one overall window and to initialize new windows/ buttons to link to the new windows after the user inputs their information. Unfortunately without toplevel, it wont wait for user input....and reads filepath as empty.

tawdry mulch
#

You just want to wait for filepath to be entered or verified?

hybrid spindle
# tawdry mulch You just want to wait for filepath to be entered or verified?

yeah pretty much thats it. Then integrate this instead of the above:

    def load_dat(parent,controller):
        global filepath
        filepath = datapath_txt.get(1.0,"end-1c")
        if filepath:
            data = Load(filepath)
            frame = PageOne(parent,controller,data)

class Load:
    def __init__(self,filename):
        data = fits.open(filename)[1].data
        self.flux = data['FLUX']
        self.wave = data['WAVE']
        self.error = data['ERROR']
        
class PageOne(tk.Frame):
    
    def __init__(self, parent, controller,data):
        tk.Frame.__init__(self,parent)
        label = tk.Label(self,text = "Species 2", font = LARGE_FONT)
        label.pack(pady=10,padx=10)
        button1 = ttk.Button(self,text='Initial Species', 
                             command=lambda:controller.show_frame(StartPage))
        button1.pack()
#

^in place of the toplevel. But right now the "if filepath:" never executes as it evaluates this script before the user actually inputs/verifies? so filepath stays empty and nothing happens

tawdry mulch
hybrid spindle
tawdry mulch
#

Ah I think I slightly get you

#

The thing is usualy, its like we enter the data first and then we execute the function AFTER the data is entered.

#

Here ig the data is not entered and then load_dat is called and after the if is done it continues

#

Oh wait that makes no sense. I am dumb

tawdry mulch
hybrid spindle
#

yup....unfortunately haha. I mean I dont NEED to do it this way. Just thought itd be a nicer general program if the user could just input their data within the program.

hybrid spindle
tawdry mulch
#

Hmmmm if I could understand the problem I could help

#

hopefully next time :p

hybrid spindle
#

If I wasnt dumb I could properly explain my problem....but here we are haha

tawdry mulch
#

I'm pretty sure you did it good, I always have trouble reading text and understanding so nvm

hybrid spindle
ancient trench
#

hi i need help with tkinter how can I switch frames uppon entering a button?

#

i'm trying to make a mysql crud that can access multiple tables

digital rose
#

@digital rose i thought it was me, nvm.
You could try storing the pages in separate functions, and then call them whenever you need to draw a new page. Look at this example:

from os import system
from datetime import datetime as dt

def page1():
    print('Welcome!')
def page2():
    now=dt.now()
    print(f'The date today is,{now.strftime("%d:%M:%Y"}')

pages={
    '1':page1,
    '2':page2,
}

while True:
    page=input('Enter the page number: ')
    if page == '1':
        system('cls')
        pages['1']()
    elif page == '2':
        system('cls')
        pages['2']()
    else:
        print('invalid page number')
#

This approach of storing the pages along with their functions in a dict, and calling them later, even though there can be many more solutions to this.

pliant dagger
#

I know we can use themes in tkinter with something like :

self.style.theme_use("classic")

So my question is how can I stop using a particular theme when a button is clicked?

def stop(self,*args):
  self.style.stop_using_theme("classic") #?????
B = Button(text="Click me",command = stop)
B.pack()
tawdry mulch
#

Try self.style.theme_use("default") inside the func? @pliant dagger

pliant dagger
#

ok just a min let me try it out

#

that doesn't work somehow

tawdry mulch
#

You might want to also say root.update() after it

pliant dagger
#

ah ok

#

that still doesn't work @tawdry mulch

tawdry mulch
#

Okay let me try it out

pliant dagger
#

sure

#

See my real problem is that I have a button and whenever I click it ,it changes the theme to classic,I also have another button which changes the theme to clam (My script automatically changes the theme to clam when run). So whenever I change the theme to classic it works alright but when I change the theme back to clam it doesn't work only the theme of that particular button gets changed to clam

tawdry mulch
#

Check this out

#
from tkinter import *
from tkinter import ttk

def change():
    s.theme_use('default')

root = Tk()

s = ttk.Style()
s.theme_use('vista')

ttk.Label(root,text='Hello').pack()
ttk.Button(root,text='Damn',command=change).pack()

ttk.Button(root,text='Dummy').pack()

root.mainloop()
pliant dagger
#

this works

#

but I don't know why mine doesn't

tawdry mulch
#

Poste your code?

pliant dagger
#

that's almost 2k+ lines of code

tawdry mulch
#

The relevant parts

pliant dagger
#

ok

#
def Frontend(self):#User-interface
   theme_list = ['Dark theme', 'Light theme']
   self.root = Tk()
   self.root.tk.call('source','azure-dark.tcl') #Got this theme from github
   self.style.theme_use('azure-dark')
   self.themebox = ttk.Combobox(self.root, state='readonly', values=theme_list)
   self.themebox.current(0)
   self.themebox.place(x=640, y=8)

def print_combo(self,*args): #Change to light theme/dark theme here

        if self.themebox.get() == 'Light theme':
            try:
                if not self.called:
                    self.root.tk.call('source','azure.tcl')
                    self.called = True
                self.style.theme_use("azure")
            except Exception as e:
                print(e)
            
        if self.themebox.get() == "Dark theme":

            try:
                #self.style.theme_use("default")
                #self.root.tk.call('source','azure-dark.tcl')
                self.style.theme_use('azure-dark')
                print("Wo")
                self.root.update()
            except Exception as e:
                print(e)
#

there you go @tawdry mulch , sorry if you don't like mentions

tawdry mulch
#

Does any error come out?

pliant dagger
#

nope

tawdry mulch
#

Does the print statement get executed?

pliant dagger
#

yeah it does

#

the theme of the combobox gets changed

#

wouldya like to see my screen?

zenith epoch
rotund stone
zenith epoch
turbid crow
zenith epoch
#

my pleasure

#

we arent even taught tkinter in my school, had learn all myself lel

digital rose
#

One of the few designs that i actually like.

zenith epoch
unique forge
rough isle
# zenith epoch can i get reviews on my ui?

In terms of style it's quite nice, although in my opinion a different font might be nice. Also, I'm not a huge fan of the input boxes. I think the labels shouldn't disappear when typing, it confuses some people.

#

It does fit the general modern aesthetic though, and in terms of color/contrast it's really nice.

zenith epoch
rotund stone
rough isle
#

Not sure if that's specific to Material, I've seen it used a lot when people want to save space in small forms.

zenith epoch
#

i can wait to pull this application together, so much fun making this

#

my pleasure to hear this sir

digital rose
#

how do i loop that to update every minute?

zenith epoch
#

not the right place to ask mate, this is for ui only

digital rose
#

sry

zenith epoch
#

np

rough isle
# digital rose how do i loop that to update every minute?

Take a look at this code snippet, it does something similar to what you want to do and uses .after()

from tkinter import *
from datetime import datetime as dt

class MainWindow:
    def __init__(self):
        self.master = Tk()
        
        self.renderClock()
        self.updateClock()

        self.master.mainloop()
    def renderClock(self):
        self.clockLabel=Label(self.master, text="", font=("Consolas", 15, 'normal'))
        self.clockLabel.pack(side=BOTTOM, fill=X, expand=True)

    def updateClock(self):
        now = dt.now()
        t = now.strftime("%d/%M/%Y    %H:%M:%S")
        self.clockLabel.config(text=t)
        self.master.after(999, self.updateClock)
        
if __name__ == "__main__":
    root = MainWindow()
digital rose
#

TY!

hybrid spindle
#

anyone have issues with pyqt5 just randomly not working? I havent even written any code. Copied an example, ran. Did fine. Ran again, buttons no longer work. Refresh and run...sometimes works sometimes doesnt

#

idk...my prof told me to use pyqt over tkinter, its "more stable".....first hour and it seems terrible.

digital rose
eager beacon
#

@hybrid spindle It seems unlikely that the same code wouldn't work the same way when reloading a new instance of the app.

#

Are you sure you don't have unsaved changes?

hybrid spindle
zenith epoch
digital rose
zenith epoch
#

Tkinter is but he wanted help with looping not tkinter, and If he want to he can ask idc

tawdry mulch
zenith epoch
tawdry mulch
#

That is nice, which tutorial? how long have you been working on pyqt? @zenith epoch

tawdry mulch
eager beacon
#

For something small/not very complex like that you could use QPainter and just create some widgets and move them into place for the inputs @tawdry mulch

#

its probably around 100 lines

tawdry mulch
#

after() guarantees that it will not call the function BEFORE 999 ms, but there is no guarantee that it will be called exactly at 999, it can be 1000, 1001, 1005, depending upon system and the events to process. @rough isle

tawdry mulch
eager beacon
#

Do you know how to use QPainter?

tawdry mulch
#

I jus somehow got Qtcreator to get installed

hybrid spindle
#

Is there some special treatment of key events in interactive pyplots within a tkinter program?

It keeps saying my event functions are not defined

tawdry mulch
#

not working but got Qt design studio to work @eager beacon

tawdry mulch
eager beacon
#

I just mean it doesn't have a ton of functionality.. Its all of 2 lineEdits and a pushButton for the user to interact with

#

give me a few minutes and I'll send you an example

hybrid spindle
# tawdry mulch can ya show code?
class StartPage(tk.Frame): # start Page can be first 6 images; second page for spillover
    def __init__(self,parent, controller):
        tk.Frame.__init__(self,parent)
        label = tk.Label(self,text = "File Path", font = LARGE_FONT)
        label.pack(pady=10,padx=10)
        
        def load_dat():
            
            def onclick(self,event):
                toolbar = plt.get_current_fig_manager().toolbar
                if event.button==1 and toolbar.mode=='':
                    window = ((event.xdata-2.5)<=self.wave) & (self.wave<=(event.xdata+2.5))
                    y = np.median(self.flux[window])
                    plt.plot(event.xdata,y,'ro',ms=5,pickradius=5,label='cont_pnt',markeredgecolor='k')
                plt.draw()
            
            filepath = datapath_txt.get(1.0,"end-1c")
            data = Load(filepath)
            if len(data.lines) < 7:
                newWindow = tk.Toplevel(app)
                f = Figure(figsize=(15,8),dpi=100)
                for ii in range(len(data.lines)):
                    self.axesL[ii] = f.add_subplot(6,2,2*ii+1)
                    self.axesR[ii] = f.add_subplot(6,2,2*(ii+1))
                    ##Plot Stuff##

                f.subplots_adjust(left=0.05,right=0.95,top=.95,bottom=0.05,hspace=.2)
                canvas = FigureCanvasTkAgg(f,self)
                canvas.draw()
                canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
                toolbar = NavigationToolbar2Tk(canvas,self)
                toolbar.update()
                canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True) 
                #canvas.mpl_connect('button_press_event',lambda event: canvas._tkcanvas.focus_set())

        datapath_txt = tk.Text(self,height=3,width=30)
        datapath_txt.pack()
        pulldat = tk.Button(self,text='Use Path',command=load_dat)#load_dat(parent,controller))
        pulldat.pack()

tawdry mulch
#

What is this event is it a tkinter generated event? @hybrid spindle

eager beacon
hybrid spindle
tawdry mulch
#

I am not sure abt how matplotlib handles tkinter events, hav u tried searcing

eager beacon
#

You might be better off asking about something like that in a help channel

hybrid spindle
eager beacon
#

Did you get it to work? @tawdry mulch

tawdry mulch
tawdry mulch
tawdry mulch
eager beacon
tawdry mulch
#

Damn okay, ill take a look 😄

#

@eager beacon thanks!

#

BTW these coordinates 0, 0, 300, 400 that you used will be same in all screens? Like a different resolution?

#

Or will the positions change @eager beacon

eager beacon
#

0,0 is the internal coords of the TopLeft corner of Widget and 300/400 is the width and height of the rects inside the paintEvent in Widget() so the position will always remain in the same position. @tawdry mulch

#

The only way it could cause an issue is if you didn't resize Widget() to be large enough to contain the rects

regal pulsar
#

Anyone know why with Tkinter when i close my UI thingy it opens a new one?

#

then when i close the new one it just closes

modern marsh
# zenith epoch can i get reviews on my ui?
  1. How did you set a line under the input box? A line itself or some stylesheet tweaks?
  2. What event did you use for the change of colour in the pushbutton?
  3. How did you add the shadow beneath the button
#

Great work btw :)

regal pulsar
# tawdry mulch can you share code
import pyautogui as pyg
import keyboard
import tkinter as tk
from core import *

window = tk.Tk()

runningText = "Temp"

for i in range(3):
    window.rowconfigure(i, weight=1)
    window.columnconfigure(i, weight=1)

label1 = tk.Label(text="Start key",relief=tk.RAISED,borderwidth=5)
label2 = tk.Label(text="Stop key",relief=tk.RAISED,borderwidth=5)
label3 = tk.Label(text="Clicks per second",relief=tk.RAISED,borderwidth=5)
label4 = tk.Label(text=runningText,relief=tk.RAISED,borderwidth=5)

entry1 = tk.Entry()
entry2 = tk.Entry()
entry3 = tk.Entry()

button1 = tk.Button(relief=tk.RIDGE, borderwidth=5,text="Start listening for inputs")
button2 = tk.Button(relief=tk.RIDGE, borderwidth=5,text="Stop Listening for inputs")

label1.grid(row=0,column=0, padx=5,pady=5)
label2.grid(row=0,column=1, padx=5,pady=5)
label3.grid(row=0,column=2, padx=5,pady=5)
label4.grid(row=2,column=0)

entry1.grid(row=1,column=0,padx=5,pady=5)
entry2.grid(row=1,column=1,padx=5,pady=5)
entry3.grid(row=1,column=2,padx=5,pady=5)

button1.grid(row=2,column=1,padx=5,pady=5)
button2.grid(row=2,column=2,padx=5,pady=5)

window.mainloop()```
tawdry mulch
#

My first guess ~ core is causing issues. Share its code @regal pulsar

regal pulsar
#

it has nothing but comments currently

tawdry mulch
#

When you say from core import *, python runs that file once, so if there is a Tk(), inside that. It can cause issue

regal pulsar
#

Hmm

#

I'll check that out

tawdry mulch
#

I mean just remove from core import * and see

regal pulsar
#

ok

#

Odd that does fix it

#

thanks!

regal pulsar
#

yeah

#

makes sense

modern marsh
#

when i resize the window, the frame does not resize with it

#

does anyone know why this is happening

zenith epoch
#

I haven't tried yet lel

zenith epoch
modern marsh
#

ooooh

#

use pyinstaller or nuitka

zenith epoch
#

I will definitely let you guys know about the release, and if you need help making your layout, I would be more than happy to help you

digital rose
#

I see python is not the the most probable choice for making desktop apps. What could be the reason for this? and what language / framework is most chosen for making desktop apps for production? i heard electron was popular, though.

rugged marsh
#

Hi i have a question with my code:
so this is my default optionbox, where the options are called currencies1:

"USD - US Dollar",
"EUR - Euro",
"JPY - Japanese Yen",
"GBP - Pound Sterling",
"AUD - Australian Dollar ",
"CAD - Canadian Dollar",
"CHF - Swiss Franc",
"CNY - Renminbi (Chinese Yuan)",
"HKD - Hong Kong Dollar",
"NZD - New Zealand Dollar",
"SEK - Swedish Krona",
"KRW - South Korean Won",
"SGD - Singapore Dollar",
"NOK - Norwegian Krone",
"MXN - Mexican Peso",
"INR - Indian Rupee",
"RUB - Russian Ruble",
"ZAR - South African Rand",
"TRY - Turkish Lira",
"BRL - Brazilian Real"

and i want that if i press a button, the option turns into this:

        
        "USD - 美元",
        "EUR - 歐元",
        "JPY - 日元",
        "GBP - 英鎊",
        "AUD - 澳大利亞元",
        "CAD - 加拿大元",
        "CHF - 瑞士法郎",
        "CNY - 人民幣",
        "HKD - 港元",
        "NZD - 新西蘭元",
        "SEK - 瑞典克朗",
        "KRW - 韓元",
        "SGD - 新加坡元",
        "NOK - 挪威克朗",
        "MXN - 墨西哥比索",
        "INR - 印度盧比",
        "RUB - 俄羅斯盧布",
        "ZAR - 南非蘭特",
        "TRY - 土耳其里拉",
        "BRL - 巴西雷亞爾",

I'm doing this on tkinter. how can i acheive this?

modern marsh
#

flutter is neat

digital rose
modern marsh
#

yes

rugged marsh
#

@digital rose can u help me pls

digital rose
#

in what?

rugged marsh
#

@digital rose

#
def save_command():
   if langOpt.get() == "Chinese":
       OPTIONS = [
        "USD - 美元",
        "EUR - 歐元",
        "JPY - 日元",
        "GBP - 英鎊",
        "AUD - 澳大利亞元",
        "CAD - 加拿大元",
        "CHF - 瑞士法郎",
        "CNY - 人民幣",
        "HKD - 港元",
        "NZD - 新西蘭元",
        "SEK - 瑞典克朗",
        "KRW - 韓元",
        "SGD - 新加坡元",
        "NOK - 挪威克朗",
        "MXN - 墨西哥比索",
        "INR - 印度盧比",
        "RUB - 俄羅斯盧布",
        "ZAR - 南非蘭特",
        "TRY - 土耳其里拉",
        "BRL - 巴西雷亞爾",
        ] #etc
currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default valu
w = OptionMenu(my_frame1, currencies1, *OPTIONS)
w.config(font=("San Francisco", 25), width=25)
w.grid(row=1, column=0)
        
saveChangesButton = Button(my_frame2, text="Save", command=save_command, bg='#000080')
saveChangesButton.grid(row=2,column=1)
digital rose
#

you can use .config() to update the text, as usual.

rugged marsh
#
OPTIONS = [
"USD - US Dollar",
"EUR - Euro",
"JPY - Japanese Yen",
"GBP - Pound Sterling",
"AUD - Australian Dollar ",
"CAD - Canadian Dollar",
"CHF - Swiss Franc",
"CNY - Renminbi (Chinese Yuan)",
"HKD - Hong Kong Dollar",
"NZD - New Zealand Dollar",
"SEK - Swedish Krona",
"KRW - South Korean Won",
"SGD - Singapore Dollar",
"NOK - Norwegian Krone",
"MXN - Mexican Peso",
"INR - Indian Rupee",
"RUB - Russian Ruble",
"ZAR - South African Rand",
"TRY - Turkish Lira",
"BRL - Brazilian Real",
] #etc

currencies1 = StringVar(root)
currencies1.set(OPTIONS[0]) # default value

w = OptionMenu(my_frame1, currencies1, *OPTIONS)
w.config(font=("San Francisco", 25), width=25)
w.grid(row=1, column=0)
#

i wanna update the whole options

#

like changing languages

digital rose
#

i dont really get you :/

rugged marsh
#

originally the options are in english

#

when i press the save button, they become chinese

digital rose
#

ah.

#

!paste

rugged marsh
#

should i put there?

digital rose
#

yes, so that i get to know what variables are used for what purpose.

rugged marsh
#

imma put my whole code

#

!p

proven basinBOT
#
Missing required argument

pep_number

#
Command Help

!pep <pep_number>
Can also use: get_pep, p

Fetches information about a PEP and sends it to the channel.

rugged marsh
#

!past

digital rose
#

where do you want the text to be in chinese?

#

i mean which widget.

#

@rugged marsh

#

its quite strange to see you have declared two OptionMenu widgets with the same name w and over 4 times. Name them something different, so that you can access them to change their text later on, in the command.

rugged marsh
#

At the moment

digital rose
rugged marsh
#

Wdym

#

Idk

digital rose
#

i see currencies1 and currencies2 are StingVars

rugged marsh
#

Yes

#

how can i acheive this?

digital rose
rugged marsh
#

yes

#

when i press the button

digital rose
#

ah. i see a second OptionMenu, so im assuming you want the table that is first shown to become:

        
        "USD - 美元",
        "EUR - 歐元",
        "JPY - 日元",
        "GBP - 英鎊",
        "AUD - 澳大利亞元",
        "CAD - 加拿大元",
        "CHF - 瑞士法郎",
        "CNY - 人民幣",
        "HKD - 港元",
        "NZD - 新西蘭元",
        "SEK - 瑞典克朗",
        "KRW - 韓元",
        "SGD - 新加坡元",
        "NOK - 挪威克朗",
        "MXN - 墨西哥比索",
        "INR - 印度盧比",
        "RUB - 俄羅斯盧布",
        "ZAR - 南非蘭特",
        "TRY - 土耳其里拉",
        "BRL - 巴西雷亞爾",

from:

"USD - US Dollar",
"EUR - Euro",
"JPY - Japanese Yen",
"GBP - Pound Sterling",
"AUD - Australian Dollar ",
"CAD - Canadian Dollar",
"CHF - Swiss Franc",
"CNY - Renminbi (Chinese Yuan)",
"HKD - Hong Kong Dollar",
"NZD - New Zealand Dollar",
"SEK - Swedish Krona",
"KRW - South Korean Won",
"SGD - Singapore Dollar",
"NOK - Norwegian Krone",
"MXN - Mexican Peso",
"INR - Indian Rupee",
"RUB - Russian Ruble",
"ZAR - South African Rand",
"TRY - Turkish Lira",
"BRL - Brazilian Real"
```?
#

basically change the table written in english to the chinese version you showed?

#

@rugged marsh

#

you can do that by using .config() to change the values in an OptionMenu widget.

modern marsh
#

do you have a link?

digital rose
# rugged marsh exactly!

ah, look at this example on how to change the values of an OptionMenu:

from tkinter import *

class MainWindow(Tk):
   def __init__(self, ):
      Tk.__init__(self, )

      self.choices1 = ['Option1', 'Option2']
      self.choices2 = ['Option3', 'Option4']

      self.draw_widgets()

   def switch(self):
      self.w['menu'].delete(0, 'end')
      self.string_var.set(self.choices2[0])
      
      for i in self.choices2:
         self.w['menu'].add_command(label = i, command=lambda:None)

   def draw_widgets(self):
      self.string_var = StringVar(self)
      self.string_var.set(self.choices1[0])
      
      self.w = OptionMenu(self, self.string_var, *self.choices1)
      self.w.grid(row = 0, column = 0)

      self.change = Button(self, text = 'Change', command=self.switch)
      self.change.grid(row=2, column = 0)

if __name__ == '__main__':
   root = MainWindow()
   root.mainloop()

@rugged marsh

#

basically making use of the add_command function to add a value, and using .delete() and passing in the indices to delete the contents of the OptionMenu and then inserting the new values.

rugged marsh
#

Ty

#

Will see

modern marsh
#

how do i set stylesheets easily?

rugged marsh
#

@digital rose

#

in tkinter

#

can i make specific words grey in option box

digital rose
rugged marsh
#

e.g. USD - US dollar, USD=black; -US dollar=grey

plush stream
#

heyo so i just made this context menu in pyside2. is there any way to make the context menu have rounded edges?

rapid galleon
#

is there any good libraries for nicer UI in terminal?

tawdry mulch
modern marsh
plush stream
modern marsh
#

and how did you get that acrylic look to the context menu

modern marsh
#

can you drag and drop each row up and down?

plush stream
#

No, not really. Maybe you could but i didn't implement it

tawdry mulch
modern marsh
#

hmm yeah but how do you even get it?

#

win32 thing?

plush stream
#

Yes

modern marsh
plush stream
tawdry mulch
#

is translucent windows possible with qt? like blurry bg @modern marsh

modern marsh
#

oooh

#

uhh idk, never tried

tawdry mulch
#

noice, its not possible in tkinter, i dont think it is possible in qt either. But that seems far fetched since almost everything is possible with qt

plush stream
#

Oops replied to the wrong message there

plush stream
#

But yeah it's essentially a Translucent qmenu with acrylic over it

tawdry mulch
#

Nice, looks dope

plush stream
#

Thanks

plush stream
modern marsh
#

hmm

#

did you try the

#

border-radius attribute

#

i love the acrylic but my app is supposed to be crossplatform

#

guess i gotta make some settings stuff

plush stream
#

You could always write a fallback option for your program so that the acrylic only enabled if the app is running on windows machine

modern marsh
#

yeah thats what imma do

#

thanks :D

modern marsh
#

how do you guys make separate pages for a UI

#

do you use different frames or something else?

plush stream
modern marsh
#

aight

plush stream
#

Didn't do anything

modern marsh
#

how much did you set it to

#

border-radius: 10px; would be nice ig

plush stream
#

25px

modern marsh
#

o

#

hmm

ivory ember
modern marsh
#

ah

rugged marsh
#

@digital rose u online?

#

idk how to replace the eng options with chinese :(

#

i tried (kinda) ur method

#

but i dont rly get it

#

ty

digital rose
#

Maybe your implementation is wrong.

zenith epoch
#
def close(self, Form):
                self.close()
self.pushButton_2.clicked.connect(close)```
#

i have this and getting error

#

TypeError: close() missing 1 required positional argument: 'Form'

#

my class:

class Ui_Form(QtWidgets.QWidget, object):```
digital rose
#

can someone help me with tkinter please? i want to do ```py
async def ip(ctx,ip):

this but in tkinter
modern marsh
#

without any arguments

zenith epoch
modern marsh
#

self.pushButton_2.clicked.connect(lambda: [self.destroy(), sys.exit()])

#

close might work too, never tried it

zenith epoch
#

@modern marsh bro thanks alot i have been struggling with this for hours

modern marsh
#

np

zenith epoch
#

@modern marsh any way to only close the widget not the whole program

#

?

modern marsh
#

instead of self, put the widget name

#

and remove the sys.exit()

zenith epoch
#

ok

#

@modern marsh sorry to bother you again, but now when i exit the main application the widget doesnt let the program to end

modern marsh
#

eh?

#

i dont understand

zenith epoch
#

in terminal its still running

#

just cant see the widget

tawdry mulch
modern marsh
#

idts

modern marsh
zenith epoch
#

nvm i changed something and now it closes completely, thanks for all your help

modern marsh
#

np

zenith epoch
tawdry mulch
#

The UI looks nice, you need to start working on fonts

zenith epoch
#

yes i am first gonna finish up the UI

modern marsh
#

nice

zenith epoch
#

lel

#

i earlier used to think that we cant do much with python xD

tawdry mulch
#

Well, its all in PyQt

#

not just that, i am pretty sure if you try hard, something like this is possible with tkinter too

#

not PERFECT, but something similar

zenith epoch
modern marsh
#

no

zenith epoch
#

but yeah its in pyqt5, althought i worked my ass off to make things work correctly

modern marsh
#

you used designer?

zenith epoch
#

only for login screen

modern marsh
#

alright

zenith epoch
#

i am not very familiar with programming yet so had to use it

#

i know js well enough for discord bots now tho

tawdry mulch
#

root.overrideredict(1)

zenith epoch
#

noice then

tawdry mulch
#

But, you lose all the controls. The entire taskbar and icons and so on

modern marsh
#

same in Qt too

zenith epoch
#

i am gonna make custom controls ez

plush stream
zenith epoch
#

which is the most powerful gui in python?

modern marsh
#

Qt

zenith epoch
#

hmm

modern marsh
#

well, for web apps there is eel, pywebview

#

for android, kivy

zenith epoch
#

theres something called pyside6 and kivy

#

yeh

#

kivy

modern marsh
#

pyside is qt lol

zenith epoch
#

xd

#

well yeah they all are made in designer or creator

modern marsh
#

creator?

#

hmm

#

thats qml right

zenith epoch
#

editor

modern marsh
#

why are you mixing both

zenith epoch
#

i mistook

#

fuck

#

one is designer and one is creator

tawdry mulch
zenith epoch
#

well most of the programs are made in qt if we talk about C++ and python

tawdry mulch
#

Well big apps shouldnt be made in python strictly speaking

zenith epoch
#

yea i know

plush stream
zenith epoch
#

but i have to make this program in python even tho it can get big, cuz i have to stick to my school project guidelines

plush stream
#

pfft y'all make guis from qt or other framework? try to make gui from pure opengl and i guarantee you it's fun

zenith epoch
#

i dont have time for that xd, i get those marks now

digital rose
plush stream
#

OpenGL runs natively on cpp and c. Though there's a python binding for OpenGL if you want to try it.

plush stream
digital rose
#

lol thanks for clarifying

#

I make a gui for my project with WXPython rn, I'm just started learning gui and just chose wx because it looks nice

plush stream
#

Oh and btw qt qml uses OpenGL so technically you've written a gui using OpenGL if you use qml

#

And that's one of the reason why qml guis usually looks way better than classic qt but then again it's more complex to write

modern marsh
#

no

#

its easy

zenith epoch
tawdry mulch
coarse mirage
#

In PyQt5, I'm trying to change the border-image of a button when pressed.
However, it isn't working when I code it.

from PyQt5.QtWidgets import*
from PyQt5.QtGui import*
from PyQt5.QtCore import*

class Main_Window (QWidget):
    def __init__(self):
        super().__init__()
        self.title = "Dice Game"
        self.left = 10
        self.top = 30
        self.width = 420
        self.height = 540
        self.label = QLabel(self)
        self.button_1()
        self.mw_attributes() 
        
    def mw_attributes(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left,self.top,self.width,self.height)
        self.pixmap = QPixmap("C:/Users/nomar/Dropbox/Blueprints/ivc.png")
        self.label.setPixmap(self.pixmap)
        self.label.resize(self.pixmap.width(),self.pixmap.height())
        self.show()
        
    def button_1(self):
        pybutton = QPushButton(self)
        pybutton.resize(113,53)
        pybutton.move(160, 480)
        pybutton.setStyleSheet("background:transparent;")
        pybutton.setStyleSheet("border-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbutton.png);")  
        pybutton.clicked.connect(self.clickme) 

        
    def clickme(self):
        self.setStyleSheet("border-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbuttonpressed1.png);")
              
          
app = QApplication(sys.argv) #Creates the app
ex = Main_Window() #Creates the instance of the main window
sys.exit (app.exec_()) #Starts the app```
#

Here's what the output looks like so far, but the button doesn't change when pushed:

unique forge
#

why are you setting an image to the border?

#

could you send the images

coarse mirage
#

It actually does work when setting it to a background image first though:

#

But setting it as a background image has it look like a "sticker" rather than a custom button.

proven basinBOT
#

Hey @coarse mirage!

It looks like you tried to attach file type(s) that we do not allow (.kra). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.

Feel free to ask in #community-meta if you think this is a mistake.

coarse mirage
#

Window background

#

Button (standard)

#

button pressed

#

I just realized that once the button is "unpressed" I'd like it to go back to standard.

#

This is mainly due to the button looking "strange" when it is set to background image.

unique forge
#

why are you using border-imag though

#

if you want to change the background

coarse mirage
unique forge
#

you could use background-color

coarse mirage
#

Just a white button

unique forge
#

you probably did it wron

#

g

coarse mirage
# unique forge you probably did it wron
    def button_1(self):
        pybutton = QPushButton(self)
        pybutton.resize(113,53)
        pybutton.move(160, 480)
        pybutton.setStyleSheet("background:transparent;")
        pybutton.setStyleSheet("background-color : url(C:/Users/nomar/Dropbox/Blueprints/ivcbutton.png);")  
        pybutton.clicked.connect(self.clickme) ```
digital rose
#

you might be able to do pressed/released with it perhaps?

unique forge
#

🤦‍♂️

#

background-color is for rgb colours

#

not images

coarse mirage
#

Yeah, but I need the image uploaded to replace the default button.

unique forge
coarse mirage
#

Yes. But I'd like to also know how to do it in case it wasn't.

unique forge
#

border-image does not set an image for the whole button

coarse mirage
#
        pybutton = QPushButton(self)
        pybutton.resize(113,53)
        pybutton.move(160, 480)
        
        pybutton.setStyleSheet("background:transparent;""background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbutton.png);")  
        pybutton.clicked.connect(self.clickme) 

        
    def clickme(self):
        self.setStyleSheet("background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbuttonpressed1.png);")```
unique forge
#

yep

#

thats correct

coarse mirage
unique forge
#

anyway

#

now you should nto use image

#

and instead of background-color

coarse mirage
unique forge
#

your image is a plain colour

digital rose
#

Question, is the "self.setstylesheet" in clickme setting the style sheet for the entire thing, or just the button?

coarse mirage
#

This gets things working but not only does the image not go back to it's "unpressed" state, but that's not the correct code.

unique forge
#

use background-color instead with a rgb color equivalent

unique forge
#

instead of press

coarse mirage
#
        pybutton = QPushButton(self)
        pybutton.resize(113,53)
        pybutton.move(160, 480)
        
        pybutton.setStyleSheet("background:transparent;""background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbutton.png);")  
        pybutton.clicked.connect(self.clickme) 

        
    def clickme(self):
        self.setStyleSheet("border-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbuttonpressed1.png);")
              ```

`border-image` is wrong I know.
coarse mirage
#

The color change was to just make it obvious that the image changed to me.

unique forge
#

well I have to go now

#

hope you figure out your problem

coarse mirage
#

I can understand if you don't want me to.

#

Don't want to be an inconvience.

#

I managed to do it. Though in a bit of an odd way.

#
        pybutton = QPushButton(self)
        pybutton.resize(113,53)
        pybutton.move(160, 480)
        
        pybutton.setStyleSheet("QPushButton""{""background:transparent;""background-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbutton.png);""}""QPushButton:pressed""{""background:transparent;""border-image : url(C:/Users/nomar/Dropbox/Blueprints/ivcbuttonpressed.png);""}")   
unique forge
sharp stone
spark prism
#

should I use JS CSS OR HTML for user interfaces???? (or anything else)

pseudo gazelle
#

all 3 together

spark prism
#

how would I do that tho