#user-interfaces

1 messages Β· Page 84 of 1

royal dove
#
from PIL import ImageTk,Image
import threading

root = Tk()
width = 1280
height = 720
root.geometry(f"{width}x{height}")
root.title("WK Industries for Web Development and software developement")

global frames , count, frameCnt

count = -1 
# Image List for Gif
imageObject = Image.open("./giphy.gif")

frameCnt = imageObject.n_frames # This will get the number of frames in a gif
frames = [PhotoImage(file='./giphy.gif',format = 'gif -index %i' %(i)) for i in range(frameCnt)] # This will extract the frames as 

#Create Canvas to hold image
background_canvas = Canvas(root, width=1280,height=720,highlightthickness=0)
#background_canvas.grid(columnspan=3, rowspan=2, row=0)
background_canvas.pack(fill='both',expand=True,side='top')
#set Image to canvas

background_canvas.create_image(0,0,image=frames[0],anchor="nw")

# Next()
def next():
    global count, frameCnt

    if count == frameCnt-1:
        background_canvas.create_image(0,0,image=frames[0],anchor="nw")
        count = 0
    else:
        background_canvas.create_image(0,0,image=frames[count + 1],anchor="nw")
        count += 1
        print(count)
    
    root.after(100,next)

# OR next()
threading.Thread(target=next).start()
mainloop()```
#

for example this is only for one single back ground animated canvas

edgy rivet
#

is it absolutely necessary to uses classes to make pyqt5 GUI??

#

Can I somehow do it without classes??

plush stream
#

Yes

#

But your code will be very messy and very hard to maintain

#

And because of that it'll be more prone to bugs.

#

What makes you avoid classes anyway? They're very useful in python.

pastel cobalt
#

Hey, I'm developing a shell and I'm using prompt-toolkit for creating the final prompt. There is a class called HTML that converts a html-like string into usable prompt but it doesn't accept transparent as a valid color, if i dont specify any foreground, output looks like this.

Does anyone know, how to make it transparent ?

civic heath
#

I'm trying to paste an image whenever "incorrect_count" equals a specific number. It pastes the first image, but it doesn't add any more images.

  incorrect_count += 1
            if incorrect_count >= 6:
                progress_label.config(text="Oops! Game over!")
                img = ImageTk.PhotoImage(Image.open('Images/right_leg.png'))
                panel = tkinter.Label(wn, image=img)
                panel.image = img
                panel.pack(side="bottom", fill="both", expand="yes")
                game_over = True
            if incorrect_count == 1:
                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")
            if incorrect_count == 2:
                img = ImageTk.PhotoImage(Image.open('Images/torso.png'))
                panel = tkinter.Label(wn, image=img)
                panel.image = img
                panel.pack(side="bottom", fill="both", expand="yes")
            if incorrect_count == 3:
                img = ImageTk.PhotoImage(Image.open('Images/left_arm.png'))
                panel = tkinter.Label(wn, image=img)
                panel.image = img
                panel.pack(side="bottom", fill="both", expand="yes")
            if incorrect_count == 4:
                img = ImageTk.PhotoImage(Image.open('Images/right_arm.png'))
                panel = tkinter.Label(wn, image=img)
                panel.image = img
                panel.pack(side="bottom", fill="both", expand="yes")
            if incorrect_count == 5:
                img = ImageTk.PhotoImage(Image.open('Images/left_leg.png'))
                panel = tkinter.Label(wn, image=img)
                panel.image = img
                panel.pack(side="bottom", fill="both", expand="yes")
daring iron
#

god

misty canopy
#

A lot of this code can be deduplicated by just taking it out of the ifs.

royal dove
edgy rivet
blazing sun
#

Hello guys! I just wanna ask is there any ways to separate public user login and admin logins? Because I'm struggling with tkinter haha

royal dove
#

os.system() function , you guys might need when making well organized tkinter app

runic palm
#

Does Kivy work on M1 Macs? I always get an error when trying to run the example application

modern marsh
#

well made πŸ˜„

indigo crane
#

thank you πŸ˜‡

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1634219398:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

digital rose
#

Using pyqt5 to make a gui within python, And I am making a long in screen. I also have a button that shows the register account instead. However I can't seem to get it to show the 2nd window.

#

Would anyone be willing to help please.

sinful pendant
#

Any explanation why its displaying --01 instead -01 , as in termial also it display the count as -01

#

Any explanation why its displaying --01 instead -01 , as in termial also it display the count as -01

sinful pendant
#

Aah its just simple

#

This one handles the display

#

to_strdigits is the function which takes int i out and converts it to string of given number, here 3

#

This function works fine as can be seen in terminal

wind plinth
#

maybe you are overwriting a variable at some point, idk

sinful pendant
#

Cant say, might be some glitch

#

Sometimes things are correct but dont work , then after some here and there it tarts to work as i thought

ocean flicker
#
############ IMPORTS ############
# Libraries
import tkinter as tk;
from tkinter import *
import tkinter.filedialog;
from PIL import *;
import glob;
#################################

class mainMenu:
  def __init__(self) -> None:
    return None;
  
  def menuStart(self) -> None:
    def backgroundDisplay():
      bg = tk.PhotoImage(file = "../resources/MainMenuBG.png");
      OpenImg = tk.Label(self.window, image = bg);
      OpenImg.place(x = 0, y = 0, relwidth = 1, relheight = 1);


    self.window = tk.Tk();
    self.window.title("some gui")
    self.window.iconbitmap(); #Icon for window
    backgroundDisplay();
    self.window.mainloop();

   
menu = mainMenu();
menu.menuStart();

The background image will not show and I'm not sure why (the path is correct)

mighty rock
#

Try self.bg = tk.PhotoImage(file="../resources/MainMenuBG.png")

ocean flicker
#

yess it worked, ty!

high venture
#
def addApps():

    for widget in frame.winfo_children():
        widget.destroy()

    filename1 = filedialog.askopenfilename(initialdir="/", title="Select File", 
    filetypes= (("executables", "*.exe"), ("All files", "*.*")))
    filename1.split('/')[-1:][0]
    apps.append(filename1)
    print(f"{filename1}, {apps}")
    for app in apps:
        label = tk.Button(frame, text=app.split('/')[-1:][0], padx=0.5, pady=0.05, bg="#1c1c1c", fg='white', font=("Helvetica 12 bold"), command=infoWindow)
        label.pack()
        label['borderwidth'] = 0
    return filename1

filename = 

anyway to make filename = filename1?

civic heath
#
incorrect_count += 1
img = ImageTk.PhotoImage(Image.open('Images/head.png'))
panel = tkinter.Label(wn, image=None)
panel.pack(side="bottom", fill="both", expand="yes")
if incorrect_count >= 6:
  progress_label.config(text="Oops! Game over!")
  img = ImageTk.PhotoImage(Image.open('Images/right_leg.png'))
  panel.image = img
  game_over = True
if incorrect_count == 1:
  panel.image = img
if incorrect_count == 2:
  img = ImageTk.PhotoImage(Image.open('Images/torso.png'))
  panel.image = img
if incorrect_count == 3:
  img = ImageTk.PhotoImage(Image.open('Images/left_arm.png'))
  panel.image = img
if incorrect_count == 4:
  img = ImageTk.PhotoImage(Image.open('Images/right_arm.png'))
  panel.image = img
if incorrect_count == 5:
  img = ImageTk.PhotoImage(Image.open('Images/left_leg.png'))
  panel.image = img
``` I don't know why it isn't showing the image. Its updating the size but isn't actually showing the image.
royal dove
#

guys i wanted to ask Kivy and QT are only packages for softwares made by python to be considered as products?

heady brook
#

whats the difference b/w QT and PyQt? or are they just the same thing.

lime monolith
#

@heady brook
QT: A widget toolkit for creating graphical user interfaces written in C++
PyQt: A Python binding of Qt

livid lodge
#

Hi, im building a program with tkinter, is there anyway to make Frame object to follow mouse poision? (eg. like we do by draging )?

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1634386394:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

sinful pendant
#

I am making minesweeper (try 2 with proper classes and game modules) so i am arrived at the point where i provide play again feature so which thing is better overwrite the classes or update information contained in them
.
Start game fn

lime monolith
sinful pendant
#

While working with classes i founf that its not easier sometimes

#

Weired results happen sometimes

lime monolith
sinful pendant
#

Imma try to manipulate somechanges to see it new instance with same variable works

sinful pendant
#

I use this for image

obtuse acorn
#

Is there a way to animate short bits of movement without having to call place over and over? I want to draw a pop-up notification on the canvas with the diagram on it

wind plinth
royal dove
#

Which is better for GUI applications Kivy or PyQt?

digital rose
#

I'm trying to convert an entire turtle graphics canvas including parts off scrollbars to a png with ghostscript ```py
import turtle, tkinter, subprocess
turtle.setup(800, 600)
turtle.screensize(3000, 1000)
for _ in range(4):
turtle.fd(100)
turtle.right(90)
canvas = turtle.getcanvas()
_canvas: tkinter.Canvas = canvas._canvas
_canvas.config(width=3000, height=1000)
_canvas.update() # seems to do nothing
print(_canvas.winfo_width(), _canvas.winfo_height()) # want 3000 1000, getting 779 579
_canvas.postscript(file='out.eps')

eps to png with ghostscript

subprocess.run('gswin64c -q -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -r96 -sDEVICE=pngalpha -sOutputFile=out.png out.eps')```

#

The png conversion works fine but it's always 800x600 (or nearly due to border), not 3000x1000 like I want - _canvas.config(width=3000, height=1000) does nothing to the canvas pithink

#

Wait I think I got it ducky_party py canvas.postscript(file='out.eps', width=3000, height=1000, x=-1500, y=-500)
postscript itself has args

#

though it's 2999x1000 lemon_glass

digital rose
civic heath
civic heath
wind plinth
open python
#

In Tkinter I created a function that display a label & a photo , I linked this function with a button , when I execute the code the label is displayed but the photo is empty .
Any solution pleas ?```python
def prin():

    if c.get() == pack1.name:

        pic = tkinter.PhotoImage(file =r"C:\Users\pc\PycharmProjects\QuitSmoking\Marlboro.png")
        l = Label(window,image=pic)
        l.place(x=0, y=90)

        label = Label(window,text=f"The price of a {pack1.name} pack is {pack1.price}DH\n it contains {pack1.nicotine} mg nicotines",bg='#efcb68',fg='#535F6B'
                      ,borderwidth=2, relief="solid")
        label.place(x=385,y=94)
        label.configure(font=("Staatliches", 10, "bold") )
lime monolith
digital rose
#

ignore the fact that i dont have a function called clicked.

digital rose
#

why is my picture not coming up as a background it is just empty no error message?

mighty rock
#

Try text.schoolproj_image = img or root.schoolproj_image = img

#

It has to have its own reference to the image

digital rose
#

Where should I put that?

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1634482146:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

ocean flicker
#

how can i remove this label background in tkinter?

shy timber
#

Using PySimpleGUI
Traceback (most recent call last):
File "C:\Users\ckett\PycharmProjects\Calculator\gui.py", line 4, in <module>
[pygui.Button("Start", justification='center')]]
TypeError: init() got an unexpected keyword argument 'justification'

mighty rock
heady brook
#

is it possible to integrate figma and pyqt by anychance

high venture
#

why is it whenever I click my check box, i flashes white and back to normal? How do I get rid of that "effect"? Tkinter.

round ginkgo
#

is there a base widget i can use that has the config method?

#

i am trying to make a base parent class that houses functions used in subclasses which inherit Frame, Button, Label

#

Ive used baseWidget, Widget, and Misc but they dont seem to work

#

they keep asking for a widgetName,i dont know what that is

balmy depot
#

Why whenever the mouse is hovering over the QLineEdit, the right side is blinking? I use PySide6.

royal dove
#

To be honest i have never seen a real life GUI product made by any python GUI libraries

#

mostly they use electron for interface and python for backend and processing

thorn folio
#

Hey, what's the best (easiest) way to make same looking gui in Python? Is it smth like tkinter? I never really touched ui on "beauty level" if you know what I am talking about

azure talon
#

any tkinter people around?
(note I'm having the same trouble with PyQt)
I'm trying to pop up a short 10sec victory video when a task is complete. a "Good job this 'THING' is done!"
But I can't seem to get the window to close then the player is done playing the video. Everything I've tried thus far closes it half way through playing or doesn't at all. Is there a better way then just putting a 10sec timer on it in case down the line I make them longer? (using tkvideo on the tk version I made)

ocean flicker
sinful pendant
#

In tkinter

azure talon
#

@sinful pendant
No real different then putting a timer on, as when I put longer stuff, I'll have to go back into the code and change it. Really trying for it to recognize it's done it's action.

#

Also other stuff will still be happening. Doesn't after work like a wait?

cobalt idol
#

How can i make a GUI for my project using python

sinful pendant
#

I am also on way of getting malfunction in game app

#

So tried threading and some text editor thingy

#

πŸ˜„

sinful pendant
sinful pendant
#

See this channeltopic there are some of u wanna start woth

azure talon
sinful pendant
#

Yess, just a more function(s)

#

Like in , game monesweeper , as sson as player clicks a mine, after showing all mines, i run endgame function

azure talon
sinful pendant
#

What do u mean by toss it@azure talon

azure talon
#

pop-up then go away

#

my main issue is getting that requires time to complete visually to finish when completed.
@sinful pendant

sinful pendant
#

root.after(5000, root.quit)

#

?

#

Try this on ur window which shows flashing animation

azure talon
#

@sinful pendant
That's no different then what I'm already doing as it requires a programed knowledge of how long it's going to be every time.

sinful pendant
#

Are u displaying different animations on different tasks being done?

azure talon
#

as things are completed. yes

sinful pendant
#

So what ucan do is prepare a dictionary

#

Woth the times, or there might be some method that tells us how long is the video

azure talon
#

still puts me back to changing the code every time I put in a new video or animation in the future instead of having a function that I can drop a video into a location and it can be used.

sinful pendant
#

Aah ,i hope ur code is adjustable woth changes

#

Like, u can make function which pops up window and run,and by giving, arguments for some control

azure talon
#

atm I have a setting that I can change the animation / video that plays. It looks at the files in a folder and I can select from them and it'll play when it needs to. My issue is that it just stays on the last frame on the screen.

sinful pendant
#

πŸ˜…

#

, seems like i misunderstud ur problem

azure talon
#

seems like a strange thing I'm sure, but I am surprised that there's not built in function to end a video when done, I can loop them all day though.

#

another issue is depending on the device it's on, it take a little longer to load / run the video. When that happens the time / after function time amount will cut it short.

rocky dragon
#

how would I block a QTableWidget's itemChanged signal in PySide6? I've tried blockSignals/QSignalBlocker on the table and its parents but the signals still get emitted. I have an auto column resize connected to it but during initialization the constant resizing hits the cpu for a while

median ridge
#

also qt creator

round ginkgo
#
for x in range(2):
    for y in range(2):
        if x == y == 1:
            start_screen.grid(row=1, column=1)
            continue
        frame = Frames(login_window)
        frame.grid(row=y, column=x)
    if x == 1:
        continue
    login_window.grid_columnconfigure(x, weight=1)
    login_window.grid_rowconfigure(x, weight=1)
#

it places start screen on bottom right

#

why

storm flare
#

my tkinter scrollbar is small, how do i make longer?

cobalt idol
#

I haven't make any GUI before can anyone tell me how to start or how can i learn to make one

#

I need it for my project

eager beacon
#

This is assuming that QMetaConnection has made its way into PySide6

storm flare
cobalt idol
cobalt idol
grand forge
#

Can someone help, I am getting something like. Can't invoke wm command,. Application destroyed

young yoke
#

you need to show the code as well

glacial gust
#

Did you call destroy() on your Tk root? As it says, that destroys the entire Tk application, so no more methods will work anymore.

grand forge
#

It's not really a prog

young yoke
#

you need to write all the code before starting the mainloop

grand forge
#

Oh

#

So main loop should be in last line?

young yoke
#
root = Tk()
root.geomentry("880x897")
root.minsize(870,880)
root.mainloop()
grand forge
#

Thank you, I just started learning πŸ˜…

young yoke
#

it's alright

grand forge
#

Bro, here

#

@young yoke

glacial gust
#

geometry, a small typo :)

young yoke
#

yeah

grand forge
#

Thank you ppl :)

young yoke
#

πŸ˜„

cobalt idol
#

Can anyone tell me how can i make a GUI using tkinter for raspberry pi pico

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1634642866:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

mental river
oblique steeple
#

Hello guys! Not exactly sure if this is the right channel for this question but I'll give it a shot.
I would like to program a, let's say, excel sheet with GUI. I describe it like that, because it really is nothing more than a tool to create a database of a lot of electronic devices and their consumption.

Right now, I just type in the name of the device and in the same row, all the different information connected to it, like the amount of kW it needs, the manufacturer, location etc. The goal is to sum up all the energy consumption of all devices.

The problem is, that every device has a unique identification key. This key can vary from project to project. For example it can look like this: 1-01-FRI-0001-PUM-0001. Building 1 - 1.floor - cooling machine - nr. 1 - pump - nr.1.
I would like to make a tool with GUI where I can set the identification key syntax (amount of numbers, alphabetical symbols etc.) and then be able to add different devices which then are sorted after the kind of device e.g Cooling, Heating, air conditioning etc. In the end I imagine there will be a database/table for every kind of devices (cooling, heating, etc.) but with one database where everything is in it, sorted after categories with a filter function

Is python even good for this? Would another program language be better for this kind of job?

royal dove
#

and no there is no library in python that could create a GUI that can be unleashed as a modern product

#

3 packages if you learn you can be best python developer (Javascript/CSS/HTML) for Graphic User Interface, Python for administration of application such as a backend, Java to use as extension in Jpython for functions that needs faster processing. if you can master these mentioned languages you can make any application you want

royal dove
golden terrace
#

I am currently struggling with a scrollbar, that should scroll the Canvas ("c" in this case) down.
The scrollbar appears, but is not scrollable. Any Idea why this is failing?

class ServerList:
    def __init__(self, master):
        self.list_of_elements = []
        c = Canvas(master, bg="white")

        vbar = Scrollbar(master, orient=VERTICAL, command=c.yview)
        vbar.pack(side=RIGHT, fill=Y)
        c.pack(anchor=NW)
        c.config(yscrollcommand=vbar.set)

        server_list = scan_servers("95.156.227.18", 100, 128)

        for server in server_list:
            create_server_entry(c, server)


root = Tk()
root.title("Server List")
root.geometry("600x600")
ServerList(root)

root.mainloop()
golden terrace
#

Anyone?

royal dove
#

hope this helps

golden terrace
#

@royal dove Well, it fixes the unstructured code, which is the result of me testing around. Because any solution, I found, results in the scrollbar appearing, but not doing its job. The bar just fills the whole box and is not movable. Thereby doing nothing.

fading ledge
digital rose
#

@broken crown

#

Mainclass is the parent class

#

And the DISPLAYDATA is the child

broken crown
#

mainclass isn't declared at that point

#

Put the child below the parent

digital rose
#

Ok I'll do it

#

But

#

How can i get access to the mainclass attributes?

#

In the child class?

#

Do i have to do something like,
ClassVariable = mainclass()
?

#

And then ClassVariable.attribute.method()

broken crown
#

You already have them.

#

the child class inherits them.

#

Just create an instance of the child class, and it gets all the properties of the parent class too.

clear crown
#

hi i need help in tkinter

#

so im trying to make this code work but it wont work, idk whats the matter :

def logister():
    def submit():
    username.delete(0, END)
    password.delete(0, END)
    identity.delete(0, END)
    
    logreg = Tk()
    logreg.title('login/register')
    username = Entry(logreg, width=30).grid(row=0, column=1, padx=20)
    password = Entry(logreg, width=30).grid(row=1, column=1, padx=20)
    identity = Entry(logreg, width=30).grid(row=2, column=1, padx=20)
    Label(logreg, text='Username').grid(row=0, column=0)
    Label(logreg, text='Password').grid(row=1, column=0)
    Label(logreg, text='ID (custom 5 digit number)').grid(row=2, column=0)
    submitter = Button(logreg, text='submit your account', command=submit).grid(row=3, column=0, columnspan=2, pady=10, padx=10, ipadx=100)

idk what to do it wont work and im trying to get it work with SQL

clear crown
#

it wont even clear the entry boxes

#

help?

lime monolith
clear crown
#

and thanks too btw

#

respect

dense rock
#

Hi

#

I am using PyQt6

#

and can't find a way to

#

put a icon at the taskbar for my app

#

pls helpp

#

here is a screen shot :

proven basinBOT
#

Hey @fathom cosmos!

It looks like you tried to attach file type(s) that we do not allow (.pdf). 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.

dense rock
#

and I am also using cx_freeze to compile as a executable

sinful pendant
#

Do someone knows that what can be the reason that tkinter not able to display image on button but button size is set as per the image dimensions, but image do t show up its blank, and when we click on button the button doesnt responds

#

Self.images is a dict which contains file path value

#

A dict having theme as key and a small dict a s values in which keys are the numbers and values are respective paths

#

Even that commented img line also gives same result when used

lime monolith
sinful pendant
#

Everytime is use same img 2nd time it went i to garbage, even if i copy paste imag and move it so ewhere else

sinful pendant
#

Cuz its soduko and you know numbers changeπŸ€”

lime monolith
sinful pendant
#

Ohk

digital rose
#

The "client size of a window" means the dimensions of the actual window area, right? Not the window plus border. pithink (in general terms)

mighty rock
#

It's the area without the frame with the close button and everything, where you put new widgets usually

#

Imagine a command prompt window, the entire black rectangle in it is the client area

eager beacon
digital rose
#

Yeah, I'm coming from windows forms.

digital rose
#

Hi, Can you explain me why the min and the max doesn't work?

woeful jasper
#

there are no numbers in your list, only strings

#

you'd have to convert them to integers first to get what you want

digital rose
#

thanks

#

I don't know how could I forgetπŸ˜†

winter peak
#

How to use styles like Material or Universal in Pyside6?

digital rose
flat bough
#

hey yall, I want to make a text-based python game that I can ship as an executable, so I want to use a GUI. It's going to be an RPG game so I want to have a list of message "history", so as lore/story is shown on the screen the player can scroll back up and read the past messages (past 100 or so). Is there a PyQt5 object that lets me display something like this (maybe an object that can store a list of things and display them, each thing in the list being a string with a message)?

storm flare
flat bough
storm flare
#

Each item inside the Listbox can contain your message

#

But you are not using tkinter, and you are using pyqt5, so i cannot help you sorry

eager beacon
#

There is QListView and QListWidget iin Qt

storm flare
#

Is pyqt5 difficult to use?

flat bough
#

pyqt looks nicer than the others I've seen that's why i would prewfer to use it

storm flare
#

Hmm, I prefer tkinter's look

eager beacon
bleak silo
#

i have set the qpushbutton size 30x30 and qlineedit size 220x30 but they dont have same height (pls mention me)

rocky dragon
signal steppe
#

Hi, I'm using QT Designer and I want to know how can I call a new window , without need to import the second .py file in my main code.
I'm having trouble joining the two classes into one file and getting it to work, could someone give me a hand?

The main code:


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):

##code

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

And the second windows:

class Ui_ErrorWindow(object):
    def setupUi(self, ErrorWindow):
 
##code

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    ErrorWindow = QtWidgets.QDialog()
    ui = Ui_ErrorWindow()
    ui.setupUi(ErrorWindow)
    ErrorWindow.show()
    sys.exit(app.exec_())
eager beacon
#

If this is something that happens every time you resize the table you may want to put it in a function

#

then after the function has finished doiing whatever it does reconnect the signal

#

then after the function has finished doiing whatever it does reconnect the signal

eager beacon
#

and you shouldn't make a habit out of writing your code in the .py files generated by pyuic

#

you should create a different file and import the mainWindow from pyuic in there

#

let me find an example

rocky dragon
# eager beacon Roughly like this: ```py sig = self.itemChanged.connect(self.test) # assign the ...

How does the reconnection happen?
I tried this which disconnects it, but it doesn't handle the signal when I change items after that

class MainWindow(MainWindowGUI):
    def __init__(self):
        super().__init__()
        conn = self.table.itemChanged.connect(partial_no_external(self.table.resize_column_to_contents, 0))
        self.sig_v = QtCore.QMetaObject.Connection(conn)
        self.mass_insert([["1", 2., 3., 4]] * 5000)

    def mass_insert(self, data: list[list[t.Any]]):
        self.disconnect(self.sig_v)
        for row in data:
            self.insert_row(row)
        self.table.resize_column_to_contents(0)
        self.table.resize_rows_to_contents()
eager beacon
#

You need to reconnect it manually after you finish with column resize function. I'm not sure if you can reuse self.sig_v for that or not

rocky dragon
#

ah right I misread that

eager beacon
#

It's more work, but you might want to look at using a QTableView instead of a widget if you're going to have 5k rows

#

its far more responsive

rocky dragon
#

The realistic maximum is around 300-500 but the startup delay from the signal being connected is very noticeable even with that, which I'm trying to minimize as it's slow enough already with it loading python and Qt

#

Is there a reason for the QMetaObject.Connection? The connect call seems to return an instance of that already

eager beacon
#

hmm, then you might be able to get away without that if the disconnect works... It might just be required for custom signals

signal steppe
#

@eager beacon like subclass?

eager beacon
#

Yeah, you need to inherit QMainWindow and the UI class

signal steppe
#

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

what should I change here do use two classes?

#

i'm trying to pass the second class in my main code, but Idk what I need to do here

rocky dragon
#

any idea why the QSignalBlocker didn't work? When I tried looking at the sender through self.sender() it was some random QTableWidgetItem

eager beacon
#

something like

from UI_FILE import Ui_MainWindow
from PyQt5.QtWidgets mport MainWindow
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = MainWindow()
    MainWindow.show()
    sys.exit(app.exec_())
signal steppe
#

I dont want to use a secound file to import in my main code

eager beacon
signal steppe
#

I want to call a second class in my main class in the same file

eager beacon
#

I have to go, but you really should use a 3rd file to import the 2 UI files into.. It would make your code a lot easier to work with in the long run

abstract crown
#

I have a chat app in a terminal but i want to make it look better; whats a good libary for this that keeps the terminal style?

#

i was thinking curses but i want to know if there are other options

viral cloak
#

haha i was about to say, lets look at the pinned msgs since were clueless

#

first thing Kivy lol

#

Yay! im learnding! πŸ‘

abstract crown
#

I've used tkinter before and i know kivy is widely used but i like the terminal style of my app rn and i want to keep it that way

bleak silo
#

Hey, i have trying making a app with pyqt5 and i'm just trying working selenium in background but my gui is stop responding

#

i have tried QThread but i couldn't

#

i guess something block threading but i didn't find it

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @tight grove until <t:1635119970:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @final hound until <t:1635126034:f> (9 minutes and 58 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

jade iron
#

linus torvalds says he would rather die on the island that do ui stuff , i also feel the same, do anyone of you feel the same , and if not what do you guys think of people like us

shell sleet
#

Hello ! HELP NEEDED!

signal crow
#

Hello world! Is anyone good in Tkinter?

woeful jasper
#

it's better to just ask a question than asking for an expert

digital rose
#

heyo, does someone have experience with pyuic5 code? I need to close the window, but self.close or self.hide wont work. Tried many things but nothing worked for me

Edit: I found a way, if anyone still needs help:
self.closebutton.clicked.connect(lambda: self.function(MainWindow)) - calling a function and giving the mainwindow argument (the mainwindow has the close function)
and then in the function you just call MainWindow.close

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @nocturne cliff until <t:1635192671:f> (9 minutes and 58 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

brazen thicket
#

But GUI technologies make me sad.

unique forge
#

I believe you can imitate a terminal with kivy

abstract crown
#

I already made it with tkinter

tired elm
#

is there any windows xp type ui for python?

mighty rock
#

I've heard a lot of people saying tkinter looks like Windows XP's style

woeful jasper
#

there are some ttk style themes that look similar to windows xp

rocky dragon
#

Any idea what pyside6 is doing here? After inheriting QObject, staticmethods disappear from the object

class Test(QtCore.QObject):
    def __init__(self):
        super().__init__()
        self.func()
    @staticmethod
    def func(): ...

leads to AttributeError: 'Test' object has no attribute 'func'

digital rose
#

is there a lib that provides asyncio support to tkinter?

sinful pendant
lost scroll
#

Does anyone know how to make python return a value from the tkinter insert widget ?

#

Like, I can do print(my_entry.get())

#

Nevermind I fixed it, it works if I put it inside of a function

eager beacon
#

The example you posted seems to work just fine in 6.1.3

rocky dragon
#

6.2.0

eager beacon
#

oh, let me update and try again

#

well, it works for me

rocky dragon
#

hmm, does it work if you try the snake_case and true_property features? I tried it with it disabled in the module but maybe something bled through from others

eager beacon
#

Oh, probably not.. true_property screws some stuff iirc

#

actually it appears to be snake_case that causes this to happen

rocky dragon
#

strange, with how it's worded I assumed it should only affect the state in the current module

eager beacon
#

I'm not sure how it's supposed to work, but I remember that it did have some issues when 6.0 was released.

#

Apparently there are still some problems with it.

#

I don't know of any sort of workaround that would allow a static method when importing snake_case/true_property 😦

#

I really wish they wouldn't have even added the option. After 5+ years of using PyQt/Pyside it just looks wrong to see Qt methods in snake_case

rocky dragon
#

I'm trying to use it and it does look nicer but there are cases with true property where I'm not sure if something was a set_ method or a property; and for snake_case not all names (e.g. signals) got converted

eager beacon
#

Hopefully it will get sorted out within the next couple of releases. Right now I'm still a little bit uncomfortable starting a new project using Pyside6

#

And you're right, it does look nicer, becauese it looks like all of the other python code you normally see. What it doesn't look like is every other PySide/PyQt app there is, and that can be confusing.

rocky dragon
#

The only other issue I found related to the features was a method where they overloaded on a property so true property ended up overwriting the existing method

#

which hopefully gets fixed soon as there was some discussion on the issue I raised after painstakingly logging in into the jira

eager beacon
#

Haha yeah, reporting the bugs on qt.io can be a pain.

#

if you don't get a quick response, make sure to check on it every few days until someone triages the report

#

they love to stick Wont Fix tags on the reports, especially if you don't include an example

burnt stirrup
#

how do you make it have options and stuff

sinful pendant
#

Ueah it works like the regular one

#

Widgets,and menud

rare hollow
#

can someone draw epycycloids

eager viper
#

I have a question about 3D rendering and such

#

Why is it that Python is considered too slow? Unless I'm mistaken, all of the rendering is happening at machine speed, deep in the undercode. Reacting to user events and then changing the gameworld might be a bit slow but I don't see any reason the rendering itself should suffer

#

Is there something I'm missing?

sinful pendant
#

Help: tkinter (Tk() related)
In my app i want to give my user an option to able to ake a particular frame in new window, so what should iwrite in my_frame.config(?=newroot)

plain elk
# eager viper Why is it that Python is considered too slow? Unless I'm mistaken, all of the re...

It's not too slow. It just a myth being spread by people who don't know what they're talking about, and more often than not, have never made a game. Or the old pygame is the only thing they tried.
Often you need to some math on some data and send that information to the gpu every frame, like moving things, collision, moving the camera. And that can be slower than in other languages. In pypy or cython it would not though, so really that mostly apply to the cpython implementation, not python itself. The fastest python game engines still calls a c++ program and have python bindings for it, so that's a good solution too

eager viper
quick crest
#

Hi everyone, I'm looking forward to build a GUI using python because but I prefer using web technologies for the UI. Kinda like electron for Python.
is there any framework/library to recommend ?

eager viper
#

I've been working on building that very framework for a few years now

#

School has been slowing me down, but I'd like to be done early next year

#

Or at least in beta

#

In the mean time you can check this out. With this you can package the browser and application framework in a python app (presumably bundled with pyinstaller)

#

CefPython lets you call javascript directly from python, and vice versa, so you can establish pretty clear cut communication between the front and back ends

#

But you still have to code the UI in HTML/CSS, attach the event listeners in JS and actuators in JS, and do the meat-and-pototes computation in python

quick crest
#

wow, I'll check it out

eager viper
#

It would be nice if there was a simpler answer

#

HMU if you need anything

unique forge
#

uses HTML and CSS with python

#

a bit like electron πŸ™‚

shell sleet
#

text is overlapping Tkinter canvas HELP!!!

rocky dragon
#

Would the only option for a checkbox item in a QTableWidget be to create a custom delegate? I was hoping to avoid implementing the painting

sinful pendant
#

That will change the pre existing and overlapping wont occur

shell sleet
#

okay thanks

eager viper
#

Noobish question here: are there any 3D rendering libraries for Python similar to Three.js?

#

Or Unity, I suppose. Something that uses meshes with vertices, normals, uvs, etc. and also textures

digital rose
rocky dragon
quick crest
#

Thanks @unique forge and @digital rose. it's really helpful

exotic fiber
#

hey i was wondering whether when wanting to design different screens for a gui (ie, login screen that moves to a main menu, or a high scores screen) should these each be separate classes?

#

in tkinter

#

and from there once you press on a button or a function finishes it calls the next class

digital rose
#

what does user interface eman

#

mean

#

oop

lime monolith
digital rose
#

ok

#

didnt get that but ok

#

kinda got it i think

plain elk
#

user interface is the buttons and stuff on the screen

signal crane
#

how can i close the gui app.close(), then run it again without actually running it, like restart?

mighty rock
#

Have a frame widget that you pour into everything you want to "restart", create a function that packs and configures stuff in that frame and have the frame packed as well, then make a "restart" function that deletes this frame and calls your function that creates and packs this frame

ebon echo
#

v

wind plinth
supple grove
#

Do I have to pay if I make a UI using pyqt5?

wind plinth
wind plinth
green stump
#

I'm trying to override a drag event for a QListWidget with one that attaches an override, in doing that, i have to also redo the pixmap, how do i get the visual coordinates of the QListItem? (considering the scroll and everything)

bright bone
#

pyqt6 op

mystic hornet
#

Hey how to make tkinter Label update text itself every time text change,have counter in another file that counts mouse clicks want to show that in GUI?

vagrant raven
#

Hello, how can i bring scrolling to the text in tkinter?

hazy carbon
#

does anyone knows hoe to work with tkinter? Can't solve the problem for couple of days now... #help-honey

blissful jasper
#

Hi guys, could someone recommend me libraries/frameworks to create beatifuil GUIs?

coarse cargo
#

is there anyone who could help me make a GUI

#

I am new and i need some help

naive cedar
#

Hi all, I'm using Python's tkinter and ttk to make a combobox, but no tutorials seem to cover reading typed entries to auto search and auto drop down the menu as the user types... any ideas on this? kinda like the dropdown autofill/suggestions in Google for example, as I have an insane number of entries for the user to search through.

digital rose
#

whats up fellas, is anyone familiar with QT designer? im trying to add an image, which i completed and when i execute the script its formated like this:

screenshot:

woeful jasper
#

you can install it with pip install ttkwidgets

green stump
#

I have a label with the interaction flag as py label.setTextInteractionFlags(qtg.Qt.TextEditorInteraction)
Is there any way I could get a edit done signal?

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @ripe gazelle until <t:1635752249:f> (9 minutes and 58 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

indigo crane
#

a tiny sidebar in tkinter

#

this one looked a bit good too

frank needle
indigo crane
#

Almost there, trying to make vscode's-like pop up menus in tkinter C:

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @west zealot until <t:1635796527:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

thorn citrus
#

wait is tkinter in built in python

wind plinth
wind plinth
wind plinth
wind plinth
wind plinth
indigo crane
indigo crane
thorn citrus
#

i heard about proxylight

#

a tkinter designer tool

#

but when i try and use figma

#

i dont get how to add buttons

#

or anything

#

the tutorial is just a sped up of him doing the only thing i dont understand

naive cedar
proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @frank jasper until <t:1635897929:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

magic lion
#

Hiiiiii I need to make python quiz and want a layout

manic crystal
#

hey
is there a way to embed those green rectangles in login form, so that they are visible only within this gray rectangle area?
I would like everything outside that gray area to be invisible, to cut the rest of those green rectangles

#

is it even possible in Figma? I tried moving objects to the background, to the front, make them normal, overlay etc. but nothing helps

teal forge
#

hey everyone,
I have a question in regards with Pyglet if anyone has had experience using the module..

I have been able to load my gif to a window that is proportioned according to the gifs image. I am now trying to create a full screen window with the gif to fit the size of the monitor but have been unsuccessful getting error messages and such and at the moment just have the animate gif in the corner not scaled to full screen with a purple background. Below is the code including the original code for the small windowed gif that is commented and below it is the code for the full screen gif

import pyglet
from pyglet.canvas import get_display

# 'Load animation'
# animation = pyglet.image.load_animation('Goober#13427G.gif')
# animSprite = pyglet.sprite.Sprite(animation)

# 'Set width and height of window'
# w = animSprite.width
# h = animSprite.height

# 'creates window dimensions according to WxH of gif'
# window = pyglet.window.Window(width=w, height=h)
# r,g,b,alpha = 0.5,0.5,0.8,.05
# pyglet.gl.glClearColor(r,g,b,alpha)

# @window.event
# def on_draw():
#     window.clear()
#     animSprite.draw()

# pyglet.app.run()

'Load animation'
animation = pyglet.image.load_animation('Goober#13427G.gif')
animSprite = pyglet.sprite.Sprite(animation)

'attempted code to scale'
# H_ratio = max(animSprite.height, display.height) / min(animSprite.height, display.height)
# W_ratio = max(animSprite.width, display.width) / min(animSprite.width, display.width)


' Get display and create a fullscreen window according to screen'
display = get_display()
screens = display.get_screens()
window = pyglet.window.Window(fullscreen=True, screen=display[1])

r,g,b,alpha = 0.5,0.5,0.8,.05
pyglet.gl.glClearColor(r,g,b,alpha)

@window.event
def on_draw():
    window.clear()
    animSprite.draw()

pyglet.app.run()
#

I've been trying to figure out how to get the image to scale to fullscreen but have had no success unfortunately

graceful meadow
#

hello

#

i have a trouble\

#

i can't create Qwidgets in my project by using loop

#

thank you in advance

#

self.pages_creator()
def pages_creator(self):
for i in range(10):
self.cheat_page = QtWidgets.QWidget()
self.stackedWidget.setCurrentWidget(self.cheat_page)

edgy kestrel
#

Making an emoji keyboard for windows with PyQt5, is there a window flag or some other way to not transfer the focus to the newly created PyQt window when it initializes and shows?

#

Picture to explain the idea further, the search bar gets the focus, aka anything that's typed goes there and i would rather have the focus stay wherever it used to be

#

(the grey background text editor is separate application)

edgy kestrel
#

Kinda got it working by getting the hwnd of the pyqt window and the old window and manually switching the focus to the old window after initialization but that seems kinda bodgey way of doing it

runic warren
#

class App(tkinter.Tk):

    def __init__(self, *args, **kwargs):
        tkinter.Tk.__init__(self, *args, **kwargs)
        container = tkinter.Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for f in (Home, Search, Jobs):
            page_name = f.__name__
            frame = f(parent=container, controller=self)
            self.frames[page_name] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame("Home")

    def show_frame(self, page_name):
        frame = self.frames[page_name]
        frame.tkraise()


if __name__ == "__main__":
    app = App()
    app.geometry("800x500")
    app.resizable(height=FALSE, width=FALSE)
    app.title(app_title)
    app.mainloop()
class Home(tkinter.Frame):

    def __init__(self, parent, controller):
        tkinter.Frame.__init__(self, parent)
        tkinter.Frame.__init__(self, parent, bg='#FFFFFF')
        self.controller = controller
        img = tkinter.PhotoImage(file=image_path)
        self.label_image = tkinter.Label(self, image=img).pack()

problem is the image is not visible

#

im assuming that light grey is the view for Label but image is not visible

#

any help is appreciated

lime monolith
# runic warren ```py class App(tkinter.Tk): def __init__(self, *args, **kwargs): ...

keep a reference to the image so it is not garbage collected.

class Home(tkinter.Frame):

    def __init__(self, parent, controller):
        tkinter.Frame.__init__(self, parent)
        tkinter.Frame.__init__(self, parent, bg='#FFFFFF')
        self.controller = controller
        img = tkinter.PhotoImage(file=image_path)
        self.label_image = tkinter.Label(self, image=img).pack()
        self.label_image.img = img
runic warren
#

although correct code would be

#
class Home(tkinter.Frame):

    def __init__(self, parent, controller):
        tkinter.Frame.__init__(self, parent)
        tkinter.Frame.__init__(self, parent, bg='#FFFFFF')
        self.controller = controller
        img = tkinter.PhotoImage(file=image_path)
        self.label_image = tkinter.Label(self, image=img)
        self.label_image.image = img
        self.label_image.pack()
#

also it worked πŸ˜„

teal forge
#

anyone can help with pyglet?

blissful jasper
#

Hi, does someone know how can I show the current screen in a GUI? Which functionality is this or which libraries can do this, thanks

amber roost
# teal forge hey everyone, I have a question in regards with Pyglet if anyone has had expe...

I've written some code recently that stretches the viewport keeping a base aspect ratio, but that should be easily transferred to your gif: https://github.com/Square789/PydayNightFunkin/blob/main/pyday_night_funkin/graphics/pnf_window.py#L24
Since sprites work with a scaling factor, I think (when copypasting and keeping the variable names the same) animSprite.scale_x = (viewport_width / animSprite._texture.width) and the same for the height should be able to do the trick
tgt_wh_ratio would probably also need to be set to the GIF aspect ratio if i didn't take a wrong turn in my thinking

teal forge
amber roost
#

it's effectively just 1280/720

#

Do you want to keep the gifs aspect ratio or do you just want to stretch it to fill out the window?

teal forge
#

if i stretch it the pixels will become distorted im assuming right?

#

if so then id keep the aspect ratio accordingly so it stays true to image and just fills the screen

amber roost
#

that is what this code should be able to do, although i guess it may be too complicated; is your window resizable?

teal forge
#

hm, i replaced the
CNST.GAME_WIDTH / CNST.GAME_HEIGHT variables in

tgt_wh_ratio = CNST.GAME_WIDTH / CNST.GAME_HEIGHT

with my own width and height of the image along with loading my animation and while the code ran nothing happened let me check with debug what occured

amber roost
#

ah right, i probably should've read your sample, my bad
Basically that means you don't really have control over the dimensions of the window though, I don't know if the on_resize handler works with fullscreen windows, but try something like

tgt_wh_ratio = animSprite._texture.width / animSprite._texture.height

@window.event
def on_resize(w, h):
    cur_wh_ratio = w/h if h > 0 else 999
    if cur_wh_ratio > tgt_wh_ratio:
        ...
    animSprite.scale_x = viewport_width / animSprite._texture.width
    animSprite.scale_y = viewport_height / animSprite._texture.height

Although it should be possible to just use animSprite.scale to scale it equally along both axes, but i am too tired to figure out the math for that right now

#

Probably best to use the _texture's width/height since otherwise the sprite will return its scaled width, which is exactly what we don't want when figuring out the correct scaling

teal forge
#

I see

#

I'm a tad more confused trying to relate both codes to make it work but im looking at the pyglet scale documentation that ive read before but going to attempt something with that hopefully something will work with it

teal forge
raw citrus
#

i need to make this button open local file that i choose and open it on the same window not a new window

#

import os
import tkinter as tk
from tkinter import Toplevel, ttk
from tkinter import filedialog

root = tk.Tk()
root.title("GUI")
root.iconbitmap('icon.ico')
root.option_add("*tearOff", False) # This is always a good idea
root.geometry("1000x600")
root.columnconfigure(index=0, weight=1)
root.columnconfigure(index=1, weight=1)
root.columnconfigure(index=2, weight=1)
root.rowconfigure(index=0, weight=1)
root.rowconfigure(index=1, weight=1)
root.rowconfigure(index=2, weight=1)
root.resizable(False,False)# Create a style
style = ttk.Style(root)

Import the tcl file

root.tk.call("source", "proxttk-dark.tcl")

Set the theme with the theme_use method

style.theme_use("proxttk-dark")

#Button Function
def openfolder():
newwindow = Toplevel(Frame1)

d = tk.IntVar(value=2)
Frame1 = ttk.Frame(root, padding=(40,0,0,10))
Frame1.grid(row=0, column=1, padx=0, pady=(50,10), sticky="nsew", rowspan=3)
Frame1.columnconfigure(index=0, weight=1)
Button = ttk.Button(Frame1, text="Open File",style="AccentButton",command=openfolder)
Button.grid(row=1, column=0, padx=200, pady=10, sticky="nsew")

teal forge
#

@amber roost managed to scale the image accordingly to the screen and it works wonderfully(left screen is full screen image),
thanks for the help

amber roost
teal forge
#

i did indeed lol

#

i needed to understand the scaling function first

#

now i have to figure out how to implement it with the displays accordingly

#

this is the code currrenly @amber roost :

'Load animation'
animation = pyglet.image.load_animation('Goober#13427G.gif')
animSprite = pyglet.sprite.Sprite(animation)

'Set width and height of window'
w = animSprite.width
h = animSprite.height

'Scale image to screen'
animSprite.scale_x = 3.2
animSprite.scale_y = 1.71

' Get display and create a fullscreen window according to screen'
display = get_display()
screens = display.get_screens()
window = pyglet.window.Window(fullscreen=True, screen=screens[1])

r, g, b, alpha = 0.5, 0.5, 0.8, .05
pyglet.gl.glClearColor(r, g, b, alpha)


@window.event
def on_draw():
    window.clear()
    animSprite.draw()


pyglet.app.run()
#

my issue is i get this error saying that for example "win32display" has no attribute height when I try to scale it with that

#

thats why i went the route of hardcoding for now

amber roost
#

actually thinking up an example, i got something significantly less convoluted working:

animSprite = pyglet.sprite.Sprite(animation)
SPRITE_W = spr._texture.width
SPRITE_H = spr._texture.height
SPRITE_WH_RATIO = SPRITE_W / SPRITE_H
...
@window.event
def on_resize(w, h):
    wh_ratio = w / h if h > 0 else 999
    if wh_ratio > SPRITE_WH_RATIO:
        spr_factor = h / SPRITE_H
    else:
        spr_factor = w / SPRITE_W
    animSprite.scale = spr_factor

This forces the sprite to the bottom corner though, may not be exactly what you want
If you get an error mentioning Win32Display, you are not accessing windows but displays (which from what i can read on the docs are effectively window containers)

#

the image you sent looks stretched, in which case you don't really need to compare aspect ratios and can just use this directly:

@window.event
def on_resize(w, h):
    animSprite.scale_x = w / SPRITE_W
    animSprite.scale_y = h / SPRITE_H
buoyant fulcrum
#

Hi Guys

#

Could I opinions on how I might make my GUI look better

#

I have a design, but I think the input fields look boring and plain

eager beacon
# buoyant fulcrum Hi Guys

One small change you could make that would make a big difference is to align the labels next to the input boxes to the right.

#

I'd also increase the height of each of the LineEdits by a few pixels

#

adding a border-radius of 2-3 pixels on those inputs after increasing the height would be nice too

#

Theres a lot of empty space to the right on the inputs, maybe think about reducing the overall width of the UI

#

You also don't need to label each button at the bottom with BUTTON, its obvious those are buttons

buoyant fulcrum
#

Thank you!

eager beacon
#

What library/OS are you using?

buoyant fulcrum
buoyant fulcrum
#

I made the basics of what's in the image

fathom vessel
#

Are there any ways to run python scripts using voice assistants. Google assistant would be ideal but I would settle for Bixby or Alexa

unreal rivet
#

anyone have same issue when upgrade to macOS monterey? which is the tkinter windows showing all black when using it.

eager beacon
#

I think you might need to download a version on python from python.org and try using that version to run the app

#

@unreal rivet if you install python with brew i think you will also need to install tk with brew. brew install python-tk

unreal rivet
eager beacon
#

did you install python 3.9 with brew?

unreal rivet
#

is new macOS cause that? I'm remembered that there's no problem in BigSur

eager beacon
#

I mean, maybe... It could be something broken in that version of Tk, or it could be that apple broke something

unreal rivet
#

πŸ€”

eager beacon
#

why 3.7?

unreal rivet
#

cause I'm remembered that openCV or dlib reqiured python3.7 or python3.8, but the in-built python already got python3.9...

#

:😒

eager beacon
#

I'm pretty sure that brew install python-tk defaults to the 3.9 version of TK which would require python 3.9 to run

unreal rivet
#

maybe? I could install python-tk@python3.7 ?

eager beacon
#

I don't think that exists

unreal rivet
#

right.................

#

why? but I used to use tkinter with python3.7 before.........

#

πŸ€”

eager beacon
#

Yeah, In 3.7 tk was bundled with the brew python

#

but there may be something that hasn't been updated for the new OS in that version

#

just try brew install python@3.9 and try to run the tk script with 3.9

#

even if the other libraries aren't supported you should be able to get an idea if it's the Tk/Python version that is causing the issue and go from there

#

I'm guessing that it will work, since you were able to run it through XCode

#

I remember a while back when Mojave introduced dark mode there was a somewhat similar problem with PyQt5

frozen spear
#

any easy gui libaries

wind plinth
#

which library

tardy pulsar
#

Can anyone help me with Tkinter

#

please anyone

pine phoenix
#

Hi guys
I need to delete a line and a line break from Text
Example: self.text.delete(f'{self.index} linestart', f'{self.index} lineend') # + char \n

#search(), insert(), delete() method, Tkinter Text

Thanks

pine phoenix
#

I did it!

modern bay
digital rose
#

how to know type of event in tkinter like when i enter a widget or leave it, both causes triggers the same function but i want the function to be dependent on the type of event so how can i detect that?

#

and how do i create a horizontal paned window in tkinter like side by side and not top to bottom?

#

i tried to do it with 1 paned window and 2 labels but it turned out to be stacked instead of being side to side

mighty rock
digital rose
#

Like when I print(event) it shows something like
<Event Enter blah blah numbers>

#

Or

#

<Event Leave blah blah numbers>

#

But IDK how to use that

mighty rock
#

Bind to these events with a different function

digital rose
#

can I talk about tuis here?

lethal idol
#

yea

slender mica
#

I needs help

#

can someone help me make this

#

this is just one part of it

#

here is the requeriments

proven basinBOT
#

Hey @slender mica!

It looks like you tried to attach file type(s) that we do not allow (.pdf). 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.

slender mica
#

nvm cant send them

#

who can help me?

teal forge
#

Anyone can bring some clarity to my code as to why when I attempt to scale my gif to full screen half the screen is white while the other is the gif(animation)? This is using the Pyglet python module.

Here's my code along with an image of the issue:

'Load animation'
animation = pyglet.image.load_animation('Goober#13427G.gif')
animSprite = pyglet.sprite.Sprite(animation)

# 'Scale image to screen *harcoded*'
# animSprite.scale_x = 3.2
# animSprite.scale_y = 1.71

' Get display and create a fullscreen window while scaling gif to screen'
display = pyglet.canvas.Display()
screen = display.get_screens()

H_ratio = max(animSprite.height, screen[1].height) / min(animSprite.height, screen[1].height)
W_ratio = max(animSprite.width, screen[1].width) / min(animSprite.width, screen[1].width)

animSprite.scale = min(H_ratio, W_ratio) 

window = pyglet.window.Window(width=screen[1].width, height=screen[1].height, fullscreen=True, screen=screen[1])

r, g, b, alpha = 1, 1, 1, .5
pyglet.gl.glClearColor(r, g, b, alpha)


@window.event
def on_draw():
    window.clear()
    animSprite.draw()


pyglet.app.run()
lime urchin
#

Hey if anyone in here has a moment....I just started learning how to use tkinter, and well....I hate it. lmao so is there a more friendly gui that I can write through python? Or just something different?

mighty rock
#

You can try PyQt or kivy

agile matrix
#

well any one can help me in tkinter GUI i dont why my black frame got disappear when i pack red to it

#Import the required library
import tkinter as tk
from tkinter import ttk

#Create an instance of tkinter frame
win = tk.Tk()
win.geometry("800x500")

nb=ttk.Notebook(win)


frm1=tk.Frame(nb,bg='grey',width=800, height=450)
frm2=tk.Frame(nb,bg='blue',width=800, height=450)

nb.add(frm1,text='General')
nb.add(frm2,text='2')

frm_gen=tk.Frame(frm1,bg='black',width=210, height=120)
frm_gen.pack()

nb.place(x=0,y=0)
#frm_pro=tk.Frame(frm_gen,bg='red',width=20, height=12)
#frm_pro.pack()
win.mainloop()

i just commented out that here in my code so when u run that it will show you a black frame in the general tab
but when i add red frame to it black frame just disappear only red frame will display

in short i wanna create frame(red) inside a frame(black)

supple charm
#

Are there any places that share already made tkinter gui snippets?

coarse forum
#

Also wonder that too

loud aspen
lime urchin
loud aspen
#

no prob my dude

limber oxide
#

anyone know a good package for software for software development, I want to add images, buttons, text (with custom fonts (I have the font file in the folder))

supple charm
#

What is the proper way to center items in TK?

#

Managed to get them centered horizontally using columns, but vertically is the issue

wraith plover
#

Have you tried using the justify/anchor?

supple charm
#

Eh couldnt figure out how to make them work

#

    username_label = ttk.Label(root, text='Korisničko ime:',font='Times 15')
    username_label.grid(row=1, column=2, pady=10, sticky='EW')
    username_label = ttk.Entry(root)
    username_label.grid(row=1,column=3, sticky='EW')
    password_label= ttk.Label(root, text = 'Lozinka:',font='Times 15')
    password_label.grid(row=2,column=2,pady=10, sticky='EW')
    password_label = ttk.Entry(root, show='*')
    password_label.grid(row=2,column=3, sticky='EW')
    login_button = ttk.Button(text="Log in!", style="Accent.TButton")
    login_button.grid(row=3, column=2, columnspan=2, padx=5, pady=10, sticky="nsew")```
#

This is the code in question

#

I've got columns declared as py root.columnconfigure((0,1,2,3,4,5), weight=1)

wraith plover
#

can you send me your entire code so that i can find a solution

#

?

supple charm
#

Yeah, just a second

wraith plover
#

check dm's

glacial gust
#

What you may need to do is call root.rowconfigure(i, weight=X) to specify which row needs to resize when the window does. By default it won't stretch at all. Usually you'd set one to have a weight of 1.

silent summit
#

Hi, i have been searching for hours but i cant find the solution to saving my tkinter gui screen as a pdf... can anyone please help

wraith plover
silent summit
#

Im doing a quotation system and planning to save it directly instead of doing it in excel

nova steppe
#

hey, im wondering if anyone here knows how to make a read-only text box in tkinter? thanks,

silver sun
#

actually i was trying to add Label using a list containing strings, and add a click event to it, but it only registers click event for the last element from the list.

for user in users:
            user_label = Label(self.chatApp,font="Whitney 10 bold",text=user,bg="#23272A",fg="#FFFFFF")
            user_label.place(relheight=0.05,relwidth=0.2,relx=0.78,rely=current_rely)
            user_label.bind("<Button-1>",lambda event:self.createNewChat(user))
            user_label.bind("<Enter>",lambda event:user_label.configure(font="Whitney 10 bold underline"))
            user_label.bind("<Leave>",lambda event:user_label.configure(font="Whitney 10 bold"))
            print("binded")
            current_rely+=0.08
            self.searchResultLabels.append(user_label)```

ping if anyone responds
frail agate
#

anyone know a fix to this? using streamlit

errant nymph
#
from tkinter import *
from tkinter import ttk

root = Tk()
root.title("converter")

mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

feet = StringVar()
feet_entry = ttk.Entry(mainframe, width=7, textvariable=feet)
feet_entry.grid(column=2, row=1, sticky=(W, E))

meters = StringVar()
ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E))

ttk.Button(mainframe, textvariable="Calculate", command=calculate).grid(column=3, row=1, sticky=W)

ttk.Label(mainframe, textvariable="feet").grid(column=3, row=1, sticky=W)
ttk.Label(mainframe, textvariable="is equivalent to").grid(column=1, row=2, sticky=E)
ttk.Label(mainframe, textvariable="meters").grid(column=3, row=2, sticky=W)

root.mainloop()

hey so whats supposed to happen here is that 1 button, 1 entry, 3 labels should show up
but the label doesnt show up for some reason. how can i fix this

#

no error, i get this

kindred mist
#

hey hey, i got a little problem with qtpy and input mask. Its possible to set an placeholder text and an inpust mask at the same time?

urban lake
#

I have made a menu i tkinter. But want to import it into another tkinter file, without it creating two windows. Does anyone know how to do that?

stray jackal
#

i use Tkinter , and wonder about flow control for layout , i also consider flow control for disabled kids with minimal movement - i want to learn and cross compare

woeful jasper
rocky dragon
#

Is there any way to easily "sync up" widgets in Qt? I have a layout I add to all the tabs of a TabWidget and I'd like changes in one of the layout's widgets to propagate to others

#

or would I just need to interconnect them

proper oar
# slender mica

Hey not sure if you got an answer or not but this can be done pretty easily in PyQT or PySide

slender mica
spare ice
#

Is it better to use React or Next for the UI of a project that needs a GUI for loading video feeds of collected localhost of ESP32 Camera feeds?
I’m wanting to have wireless cameras setup for monitoring fish tanks, that will also send temperature data, i want to have β€œpages” setup so i can have data per tank β€œpage” displayed….
Also a video feed.

Should someone just create a react app, and have it as the opening folder on a PI? Or, is tkinter better?

wraith grotto
#

I'm having trouble with PySimpleGUI. I'm trying to populate a table with this data:

[{'sku': '12345', 'name': 'Black Lotus', 'qr_url': 'https://integromat122720.s3-us-west-1.amazonaws.com/images/newscanner/qr/12345.png', 'series': 'Unlimited Edition', 'condition': 'LP', 'record_id': 'recphdbalhMswaejy', 'card_index': '2ED__Black Lotus', 'qr_label_url': 'https://integromat122720.s3-us-west-1.amazonaws.com/images/newscanner/qr/file.jpeg'}, {'sku': 'ABC-123-455', 'name': "Gaea's Cradle", 'qr_url': 'https://integromat122720.s3-us-west-1.amazonaws.com/images/newscanner/qr/ABC-123-455.png', 'series': "Urza's Saga", 'condition': 'LP', 'record_id': 'recB2S6UhpYrrZFb3', 'card_index': "USG__Gaea's Cradle", 'qr_label_url': 'https://integromat122720.s3-us-west-1.amazonaws.com/images/newscanner/ABC-123-455/qr_label_ABC-123-455.jpg'}]

I have a headings dict also: headings = ['sku', 'name', 'series', 'condition']

Then for the table I start it with:
[sg.Table(values=listvalues, headings=headings)]

#

But the data are all shown in the first column, not in their respective columns

#

would appreciate any help

wraith grotto
#

i figured it out

#

it doesn't read the keys, so you just have to put in the raw values

#

a list of lists, not a list of key/values

limber oxide
#

Im working on a clock in tkinter canvas (need canvas because I have an image background)

canvas1 = Canvas( root, width = 800 ,height = 600, bd=-2)

canvas1.pack(fill = "both", expand = True)

# Display image
background = canvas1.create_image( 0, 0, image = bg, anchor = "nw")

# Add Text
clockText = canvas1.create_text( 200, 250, text = "Welcome")

def clock():
    hour = time.strftime("%H")
    minute = time.strftime("%M")
    second =  time.strftime("%S")
    suffix = "AM"

    if int(hour) > 12:
        suffix = "PM"
        hour = int(hour)-12
    else:
        suffix = "AM"

    text = str(hour)+":"+minute+":"+second+" "+suffix
    canvas1.itemconfig(clockText, text=text)
    canvas1.after(1000, clock())

When I run this I get this error:

RecursionError: maximum recursion depth exceeded in __instancecheck__

Anyone know how to fix?

sudden coral
#

Maybe you meant to do canvas1.after(1000, clock) instead?

limber oxide
#

Ill try that

#

works

#

tysm

sudden coral
#

Np. That passes the function itself rather than calling it and passing its return value

limber oxide
#

ohh

limber oxide
#

@sudden coral do you know how to scale the text with the window so its a certain percentage (I dont know how big the screen, I will be using is)

sudden coral
#

No, sorry. I am not familiar with tkinter. I was just able to spot that error you had cause it was a more general mistake, not specific to tkinter.

limber oxide
#

ohh ok

native carbon
#

if you don't know the dimensions of the window, it's not hard to get them either:

width, height = window.winfo_width(), window.winfo_height()
#
base_res = 1024, 740

width_perc = (width / base_res[0]) * 100
height_perc = (height / base_res[1]) * 100

scale_perc = ((width_perc + height_perc) // 2) * 100```
limber oxide
#

Ik, the monitor is an old one I have and its a different pc as what im testing

native carbon
limber oxide
#

Ty

#

Also I want to work on any screen

native carbon
#

apparently, yes.

limber oxide
#

Okay tysm, ill test when I get home from school tomorrow

runic warren
#

how to make something like this using Tkinter?

#

I suppose using a for loop and grid would be best?

runic warren
#

πŸ€”

tawdry mulch
runic warren
tawdry mulch
runic warren
#

not very good with tkinter

#

here i what i've so far (before i went for a big break)

#
import tkinter
from tkinter import EW

from src.utils.log import Log


class One(tkinter.Frame):

    def __init__(self, parent, controller):
        tkinter.Frame.__init__(self, parent, bg='#ffffff')
        self.controller = controller

        parent.grid()

        # Title text label
        tkinter.Label(self,
                      text="Application Form",
                      bg="#194159", fg="#ffffff",
                      font=("Noto Sans", 21, "bold"),
                      ).grid(sticky=EW)
        self.grid_columnconfigure(0, weight=1)

        tkinter.Label(self,
                      text="Step 1 - Basic Information",
                      bg="#ffffff", fg="#194159",
                      font=("Noto Sans", 14)
                      ).grid(sticky=EW, pady=16)
silver sun
#

hey so i am trying to add frames inside a Toplevel window, im new to tkinter and is there any way to set a fixed height for the frame? i am using grid for the placements of the frames

native carbon
native carbon
#

if you just want to place the widgets in a similar manner, then yes, grid is exactly what you need.

green stump
#

What signal or event do I have for selection change in PySide2?

eager beacon
green stump
#

I was trying to search for that

#

but they named it selectionChanged

#

took me a while

eager beacon
#

I think thats only available if you're using an itemSelectionModel

#

itemSelectionChanged is the signal thats emitted when the focus changes from one item to another in a list/tableWidget

green stump
eager beacon
#

weird, its listed as itemSelectionChanged in the docs.

green stump
#

maybe it has something to do with the way it's C bindings are made

eager beacon
#

Oh, yeah... don't depend on that for the signals. The stubs aren't generated properly for them, so sometimes they will show up, other times they wont

#

always check the docs

green stump
#

thanks chris!

shy torrent
#

Is there a guide to completely and correctly install PySide6?

With the designer working completely and stuff?

Not talking about specific problems, but just generally a β€žthis is what you have to doβ€œ and /or β€žthese errors are normal and do not mean you installed it wrong or missing somethingβ€œ

rocky dragon
#

I think a normal pip install should work

shy torrent
#

Starting the designer, the extra example widgets arent in there and previewing python code does not work (the last one could be normal from what I remember)

I know it needs to do something with the env vars, but finding that info doesnβ€˜t really work

rocky dragon
#

ah I wasn't aware there was more to the designer than the basics as I don't use it

shy torrent
#

Its not that I need it, it is more that this is the stuff that I see that errors and makes me suspicious that stuff that I not see could error as well. So I want to make sure that my setup is completely done right.

shy timber
#

Kivy question:
Tkinter has a function where when you grid something you can place it in a specific row e.g. .grid(column=2)
I want to create a row with 2 buttons and only have one widget like this

     text
button button

How could I do this in kivy?

tribal path
#

What do you mean 2 buttons but 1 widget... example looks like 3 widgets as well

daring arch
#

Please tell me what to do in this situation? I did not find it in Google. I apologize in advance if I wrote to the wrong channel

rocky dragon
#

How would I go right aligning or auto scrolling text in a QStatusBar? I have a relatively narrow window and want to display information like network errors to the user through it, but those can be longer and the relevant part of the message is on the right

eager beacon
#

If it were me and I was feeling lazy I would just use a timer connected to a method that sets the text and in the method use slicing to remove letters from the front until the entire message has been scrolled.

eager beacon
rocky dragon
#

ah, was hoping to avoid implementing something like that as it usually ends up being more complicated than it has any right to be but guess I'll bite the bullet; at least it's non critical and easy to replace the status bar with

eager beacon
#

The method that uses slicing to show less and less of the string everytime the timer fires should be pretty simple to implement and should look alright. You might need to use a fixed width label to prevent the text from moving further to the right when the string gets too short

rocky dragon
#

was hoping to also mix in some kind of a "i'm busy doing something" indicator so I could do that with the repaint

eager beacon
#

I've seen a couple different repos on gh that have circular progress bars, you could just use one of those, or just use a label with a timer to animate some slashes/pipe to make it look like its spinning

rocky dragon
#

Yeah the simple text one was the first thing that came to mind, just something to keep the user aware that things are happening while it's waiting for a long running job

#

Another problem I'm having is that I couldn't find how to get a colour set through a QTableWidgetItem.setForeground in a QStyledItemDelegate's paint method

eager beacon
#

I'm not sure I understand.. Why are you trying to use setForeground when you can use the paintEvent?

rocky dragon
#

I mark items as "done" by setting their colour to grey through setForeground, then for some coloumns I have a custom item delegate for checkboxes

#

within the item delegate's paint event I couldn't find a way to access the colour set by setForeground

#

well I badly copied it but the missing methods are only for the focus rect and figuring out where to put the checkbox

eager beacon
#

Ohhh, okay. the delegate is only the checkbox.. I thought each item was drawn from a delegate.

#

I'm not sure how do do it from there, maybe a signal to fire when its checked thats received in the QTableWidget?

#

I've only used delegates a few times and I don't think I've ever tried what you're doing, but I'll double check to see if I have some code after I get my kid in bed.

rocky dragon
#

I've looked through the docs a couple of times now and I'm not sure if I'm missing something obvious or if it's something complicated. But there has to be the way as the defaults handle it just fine

limber oxide
#

Anyone know how to use a custom font on linux and windows for tkinter?

eager beacon
#

Ohh, okay.. I read that wrong the first time... If you just want to get the color you've already set then its just: index.data(Qt.TextColorRole).color()

waxen thunder
#

anyone know how to make a gui that updates from a webpage and displays things like stock prices etc?

runic warren
#

RxPy maybe

#

atleast thats what i would use but there other ways u can implement auto-update

waxen thunder
#

ty i'll try to get this working. it's been a goal of mine to create a small application that basically is an alternative to tradingview because i hate that you have to sub to tradingview to get good charting

runic warren
#

thats what they said bout Elon Musk 😏

waxen thunder
# eager beacon Thats an ambitious project

yeah and tbh i'm not sure i can do it. i started learning python a few weeks ago, but i have 3 years experience in java so it's really just learning syntax and different names. i have no time frame on when it's gonna be finished but idrc. i wanna make it donation based like ad block or even just a one time payment and sell ad space instead of doing a subscription to get the most basic services

#

the only reason i'm switching is because java is so antiquated that i don't wanna be left behind

#

and the reason i'm doing application based approach instead of web based is because webull moved into the application space and has kinda dominated the game since they started

green stump
eager beacon
waxen thunder
deep tulip
#

Help me please, i have created my own function, but terminal says os doesen't have 'mkfifo', what i need to do to repair that?

def buildverssion(version, src):
path = os.path.join(".ver",version)
os.mkdir(path)
path = os.path.join(version, src)

worksheet = Scaffold(version,src)

worksheet.getversion()

os.mkfifo(path)

buildverssion("1.0","atributes.json")

#

but i get that output

#

AttributeError: module 'os' has no attribute 'mkfifo'

green stump
lime monolith
azure current
#

What should I choose for my gui application? dearpygui or pyside/pyqt

rough lotus
#

What about plain old boring and built in tkinter?

sick carbon
waxen thunder
#

idk why but the rxpy import isn't working for me

wind crane
#

Peace be upon you, where is the Arab technical support for tkinter?
i need technical support for tkinter

#

Please, answer me privately

rocky dragon
digital rose
#

Is there a way to open a python software using a windows shortcut?

#

like if I wanted to open a tkinter project I made with a shortcut such as ctrl + shift + g

brazen thicket
# digital rose Is there a way to open a python software using a windows shortcut?

Copy the full path to your python file (shift-right-click on the file, "save as path")
Somewhere in a folder, right-click in the empty space, "New", "shortcut".
Type python and the path to your file.
Save and exit.
Alt-double-click on the new shortcut to see its properties.
In "Target", you should see that the path to python has been filled in. If not, replace it with the full path to python.exe.
Target should look like "C:\python310\python.exe" "C:\scripts\myscript.py". Basically it should be a valid command-line call.
Delete the content of "Start in" (or change it to the folder that contains your script, ie what you want the CWD to be).
Click OK.
Double-click the shortcut to test it works.

Now, if you want to assign a keyboard shortcut to it... I didn't manage to make it work, but this is the theory:
In the shortcut Properties, highlight "Shortcut Key" and enter the keybind you want.
Apparently this will only work if you register the shortcut in the Start menu:
In Windows Explorer, put this in the address bar: %appdata%\Microsoft\Windows\Start Menu\Programs
Copy your shortcut into that folder.
Reboot (or log out and in).

hollow blaze
#

Hello everyone. Anyone experienced in tkinter....?

plain elk
#

I'm not, but lots of people are. Why do you ask?

green stump
rocky dragon
#

How could I nicely handle the first slider_change this receives? It's ran before the parent is fully constructed so it ends up with the initial tooltip label being placed somewhere at the top after being mapped to parent https://paste.fuelrats.com/neciroqaxu.py

sinful pendant
#

If i place my frames using place layout manager then will i be able to place widgets on that frame?

green stump
#

When you use QLabel.setTextInteractionFlags(qtg.Qt.TextEditorInteraction) to make a label editable, is there any signals to connect when the editor is destroyed?

winged fossil
#

hey guys

#

in wxpython is this best way of creating a new window ? like you would new window for settings or something

old sky
#

best GUI Library for python?

young sedge
# old sky best GUI Library for python?

simpliest to use... SimpleGUI, just the best to use PyQT6/PySide6 (the only drawback is complicated licensing situation, which makes big problem for commercial probjects)

young sedge
# old sky and GTK?

dunno. but it looks like having visual editors, which is already high plus in my opinion. License looks nice, not restrictive, docs look rich.

#

I would have tried it I guess

old sky
#

ok...

#

thanks

digital rose
#

can anyone help me with on how i can use a button to open a text. i coded the button but i dont know how i can make it work like a button that opens something. in python btw

woeful niche
#

Any suggestions on improving this structure wise?

digital rose
#

Can I get constructive criticism on this

Its the first time I've attempted to add material design into my project :)

#

||waitt, am I using this channel correctly?||

pallid arch
#
import sys
from PyQt5 import QtCore, QtGui, QtWidgets,uic

class TestGUI(QtWidgets.QMainWindow):
    def __init__(self):
        super(TestGUI, self).__init__()
        self.myui =  uic.loadUi('SPTMain.ui', self)
        self.NewTab.clicked.connect(self.handleAddTab)

    def handleAddTab(self):
        contents = QtWidgets.QWidget(self.myui)
        layout = QtWidgets.QVBoxLayout(contents)
        self.tabWidget.addTab(contents, 'Tab One')

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = TestGUI()
    window.show()
    sys.exit(app.exec_())
#

Actually It adds blank tab... Kindly guide me how can I add new tab as my ui (duplicate of my .ui file in new tab)

pallid arch
#

where should I mention my qwidget (ui file) in new tab of qtabwidget so that it adds my ui...

supple charm
#

What would be the proper way to add a button event to a tkinter button? Currently i have:

def fetch_login():
  username = username_label_entry.get()
  password = password_label_entry.get()
  login.attempt_login(username, password)

login_button = ttk.Button(text="Log in!", style="Accent.TButton", command=fetch_login)
login_button.bind('<Return>', fetch_login)```
But it is throwing me an error: `TypeError: fetch_login() takes 0 positional arguments but 1 was given`
#

Do i need to create an additional function which would take keypress as an argument, and then execute the function i need or?

woeful niche
woeful niche
supple charm
#

But i noticed something weird even with binding

#

Enter wont work untill i click on button manually once

woeful niche
#

hmmm

#

what was the <return> supposed to check again?

supple charm
#

Just execute a function

#

So both Return key and mouse button on button should do same thing

woeful niche
#

hmm

#

so like it checks of any keypress?

#

I make my buttons like this, and they work fine

#

ill try using ur code

#

yea return doesnt work for me either

supple charm
#

πŸ€”

charred aspen
#

uh, is there any way to have rich tables be the same width regardless of contents?

#

yes there is btw, min_width and max_width on Table.add_column

eternal scroll
#

Hello does anyone know how to make the background color of the Label white?

digital rose
digital rose
eternal scroll
digital rose
wary grotto
#

tkinter discussions here right?

indigo crane
frail parcel
#

I'm using PySide2 and have a main app and a worker thread.
I was wondering how I can get the thread to safely trigger a function in the main class from the main thread.
I've been looking in to using QSlots and QSignals and things but I haven't found anything that works.
Any help is appreciated!

frail parcel
#

found a viable workaround, so it's all good now :)

bold prism
#

idk this is raleted with this channel but what is wrong?

#
import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
import time

class MyApp(App):
    def build(self):
        return Builder.load_string(
"""
Label:
    font_size: 32"""
    )
    def on_start(self):
        Clock.schedule_interval(
            self.update, 1
        )
    def update(self, *args):
        h = time.strftime("%H")
        m = time.strftime("%M")
        s = time.strftime("%S")
MyApp().run()
#

app is opening but there is just black a screen

#

it should show the time

wary grotto
tribal path
#

you'd need to in some way to update a text attribute in that label

bold prism
obsidian maple
#

Hello, I was wondering how can I add a background in a ttk.notebook ?

#

I tried this but my bg isn't at the screen when I run the script

wary grotto
wary grotto
#

Then you can use bg to change it's colour

wary grotto
obsidian maple
#

Well I just wanna get an UI with buttons and tabs with a background image

#

It doesn't get me an error msg

#

It just put a white bg instead of my image

wary grotto
#

Ohh like that you meant, then idk I haven't started using images yet... Sry

ionic finch
ionic finch
#
import tkinter as tk
from tkinter.filedialog import askopenfilename
import pandas as pd

def import_csv_data():
    global v
    csv_file_path = askopenfilename()
    print(csv_file_path)
    v.set(csv_file_path)
    global df
    df = pd.read_csv(csv_file_path)
    print(df.head())

def showMean():
    calcMeanNA = Button(root, text = "NA_Sales", command = calcMean("NA_Sales"))
    calcMeanNA.grid(row = 4, column = 0)
    calcMeanEU = Button(root, text = "EU_Sales", command = calcMean("EU_Sales"))
    calcMeanEU.grid(row = 8, column = 0)
    calcMeanJP = Button(root, text = "JP_Sales", command = calcMean("JP_Sales"))
    calcMeanJP.grid(row = 12, column = 0)
    calcMeanglb = Button(root, text = "Global_Sales", command = calcMean("Global_Sales"))
    calcMeanglb.grid(row = 16, column = 0)
#     resultLabel.config(text = "The Mean is: " + str(meanRes))

def calcMean(columna):
    x = df[columna]
    mean = x.mean()
#     CalcmeanBtn = Button(root, text = column, command = showMean)
#     CalcmeanBtn.grid(row = 4, column = 0)
    resultLabel.config(text = "The Mean of "+ columna +" is: " + str(mean))

# def display():
    
root = tk.Tk()
root.geometry("500x500")

tk.Label(root, text = 'File Path').grid(row = 0, column = 0)
v = tk.StringVar()
entry = tk.Entry(root, textvariable = v).grid(row = 0, column = 1)
tk.Button(root, text = 'Browse Data Set', command = import_csv_data).grid(row = 1, column = 0)

meanBtn = Button(root, text = "Mean", command = showMean)
meanBtn.grid(row = 4, column = 0)

# num_list = df.select_dtypes(include = np.number).columns.tolist()
# 
resultLabel = Label(root, text = "Result: -", font = (None, 10))
resultLabel.grid(row = 2, column = 0, columnspan = 3, sticky = "nwes", pady = 7)

tk.Button(root, text = 'Close', command = root.destroy).grid(row = 1, column = 1)

root.mainloop()
#

In this, when I run it and browse the file and click on mean, it shows me the mean of global sales only

Like what i wanted to do was When I click on the mean button the 4 columns would appear with button and when I click on them, the mean would be displayed of each..

near sierra
#

Quick question, I'm trying to add an .ico image to a Tab (ttk.notebook). The code runs fine, but it doesn't show the .ico. Does anyone know what it's going wrong, please? Thanks

`from tkinter import *
from tkinter import ttk
import os

root = Tk()

icopath = os.getcwd() + '\Config\Icos\Bot.ico'

tab_control = ttk.Notebook(root)
tab_control.pack(expand=1, fill='both')

tab1 = ttk.Frame(tab_control)

tab_control.add(tab1, text='TAB TEXT', image = icopath, compound = LEFT, padding = 15)

root.mainloop()`

digital rose
#

Hmm

digital rose
digital rose
#

The output I mean

ionic finch
#

Just after running the code

#

After browsing the file and clicking on mean button

digital rose
#

Ok so what do you want to happen when it click mean?

ionic finch
#

it should display these 4 buttons..
And when I click on each of them it should display their mean
Like when I click on NA_Sales, it should display mean of NA_Sales, same for EU_Sales and others..

digital rose
#

Ok

ionic finch
#

Right now what is happening is
When I click on mean button , automatically it is showing mean of global sales and the 4 buttons are not working

digital rose
#

Ok

#

Hold on

ionic finch
#

sure

digital rose
#

So what you need to do is detect the output when the buttons are clicked like you did when you coded the detection of the "mean" button.

Then you need to calculate the mean fkr that, and display it in a label

Pack the calculated data and display it next to the buttons

digital rose
ionic finch
digital rose
#

Ok

ionic finch
ionic finch
#

What I need to do? in the code part?

digital rose
#

I'm not sure

#

I barely have experience with tkinter I'm just going off knowledge that I know already

#

Sorry I couldn't help

ionic finch
#

no worries

hollow wadi
kindred dome
#

Does anyone know how you can change a ttk.Progressbar's background colour? I've searched everywhere and have only been able to change the actual progress part (that is usually green) to a different colour, rather than the real background. It looks really weird against the dark mode aesthetic I have in my program.

hollow wadi
#

sorry dunno, but it looks really cool. I've tried using themes for my tkinter and it really slowed down.

kindred dome
#

Yeah I guess it's not too bad as it's a fairly small part of the program at the bottom. I suppose there isn't a way to do it as many of the Tkinter programs I've seen aren't "modern" in the sense that they have a dark mode anyway, so it may have just never been developed.

hollow wadi
#

surely they are not taking good care for 'aesthetic' parts of it.

kindred dome
hollow wadi
#

yes that works, I've almost tried all of them

#

but the 'app getting really slow' part made me abandon themes

#

some do slow the app while the others do not

kindred dome
#

Yeah. I think since the rest of my program is just using colour codes that I manually put in, the themes shouldn't slow too much, hopefully...

hollow wadi
#

I think it has to do with nudging in 'svg' files in

#

your way won't affect the performance I guess

#

looks neat, and it does not seem to slow down the program too.

kindred dome
#

That does actually look pretty useful. However I'm about 24 hours into banging my head against the wall trying to figure out colour codes so I'm just going to reserve this for another program I make rather than replacing all the stuff I did πŸ˜„

hollow wadi
#

Yes that kind of work deserves a medal, don't let that go away

naive furnace
hollow wadi
#

thanks for the link. I would definitely try it on next design. it looks very good

naive furnace
#

Do people always use wildcard import from tkinter import * with tkinter?

noble lion
#

I'm rather new to tkinter but I have been using "import tkinter as tk"

naive furnace
#

Yeah, I do that, too

ionic finch
#

If there are "x" number of columns in a database and I want to create "x" buttons and when I click on them it would show the mean of each

#

How to do that?

gaunt willow
#

how do you get the number for the line in which the insertion cursor in the Text widget (Tkinter)?

gaunt willow
#

i hate discord

mighty rock
#

That's the thing

#

Oh the line

gaunt willow
#

Yes-

mighty rock
#

line insert maybe?

#

Oh, with the index method

#

I'm pretty sure it exists let me check

#

There you go:

Text.index("insert linestart")
wary grotto
#

guys a small doubt, is there any difference between a 'class()' and a def function()'? if there is then can sm1 pls tell me the difference because i see many people use class() in their videos on yt but I don't see the need to...

near sierra
obsidian otter
#

Never did anything with a gui really, I want to make a sorting visualizer, can someone recommend me what to use please? preferably something I can use to later extend and do other algorithms too. Should I use tkinter?

cobalt idol
#

Hey can anyone tell me how can i call multiple function using a for loop

sinful pendant
#

What u can do is that
func = [f1, f2, f3] for i in func: i()

hollow wadi
hollow wadi
wary grotto
#

thanks dude

spare ice
#

With β€œtasks”, would it be that i should create a task, that will run different functions on my UI for creating a note? I have a simple Pi Zero with a react UI, that I’m running, and i have a button that i want to β€œset up” a new note. Sooooo, is that where i run a β€œtask” that will cause automation to create the note when the button is pushed?

supple charm
#

Does anyone have experience with Eel?

hollow wadi
#

It tastes good

mild cedar
#

how can i make those buttons to the end

#

and if i try to resize the window with mouse

#

the button resize accordingly

#

i want to kee the width but want length is as the windows size

mystic jetty
#

hi! how could i make something like this in python, if it even is possible?

mild cedar
#

like the process bars?

#

@mystic jetty

mystic jetty
#

yeap

#

they are on multiple lines and i think theyre updating asynchronously

#

@mild cedar

mild cedar
#

yeah well that is easy you need to so hard code on tracking all downloaded and total bytes

mystic jetty
#

but how do i update multiple lines on the terminal at the same time?

#

i though you could only use \r for one line

mild cedar
#

wait

mystic jetty
#

inst \n line break?

#

like how to dinamically update stuff on the terminal lol :D

mild cedar
#

you are rght

#

\n just work for the last line

digital rose
#

no?

mystic jetty
#

yeah lol

#

what

digital rose
#

its the same line

mild cedar
#

may be use cls or clean

#

πŸ˜›

mystic jetty
#
print("foo\nbar")

foo
bar

#

no but thats gonna clear the whole screen

mild cedar
#

yeah

mystic jetty
#

eh

#

like

#

this is a code

#

for

#

loadbar

#
def progress_bar(seconds, prefix="[*] Waiting: "):
    for i in range(seconds+1):
        percent = 100.0 * i / seconds
        sys.stdout.write('\r') # this is to clear the output ON the same line
        sys.stdout.write(f"{prefix}[{'=' * int(percent / (100.0 / 30) ):{30}}] {int(percent):>3}%")
        sys.stdout.flush()
        sleep(1)

this prints
[*] Waiting: [================== ]

#

but that is just one line,
what i want to do is:
update multiple lines at the same time.
as you can see im using the \r to clear the line here, but that words just on this line,
how can i make it clear other lines

hollow wadi
mild cedar
#

i tried everything nothing is working

hollow wadi
mild cedar
#

oh

#

thanks

teal rivet
#

Hello im using pysimpleGUI and i have a window with a background and i want to add 2 pictures (they are flags so the user can choose language) so they can continue to another window with their language. anyone got a guide or knows approximately how to do that?

mild cedar
#
def main():
    def test():
        print(key.get())
        if key.get() == "test":
            lic.destroy()
            Application().mainloop()

    lic = tk.Tk()

    tk.Label(lic, text="Enter Key"
        ).grid(row=0, column=0, pady=25, padx=15)
    key = tk.Entry(lic)
    key.grid(row=0, column=1, pady=25, padx=15)
    tk.Button(lic, width=10, height=2, text="Submit", command=test
        ).grid(row=0, column=2, pady=25, padx=15)

    lic.mainloop()

main()
#

can anyone do the same in better way

#

or likke in class inheritance

#
class Application(tk.Tk):
    def __init__(self):
        super().__init__()
#

here is my application class

#

i am trying to make a licence window

#

first pass the licence before open the main app window

#

rn its working as i want it to be

ionic finch
sour rain
#

is kivy faster or react native?

#

not sure where to ask this

rocky dragon
#

I'd expect react native to be faster considering its size and kivy being a wrapper around opengl that then needs to packaged for the platform

wary grotto
#

Guys, I have a doubt, how do we use the time import in tkinter, because whenever I try to use it, it never works!

gilded grail
#

newsapp-abipravi.netlify.app how is my UI

wary grotto
#

no no ik how to import time, but when i try to use it in a code, for eg, some tkinter code, time.sleep(3), some other tkinter label to appear after 3 seconds, what happens is that the entire code gets paused for 3 seconds and then comes onto screen, but what i want to happen is that a label first appears when the code is run, and then afterwaiting for 3 seconds, a second label should appear, not all at once...i hope you understand what i am trying to tell you

hollow wadi
wary grotto
#

Thanks a lot

#

@hollow wadi

#

will surely try that!

hollow wadi
#

good luck

supple charm
#

Using Eel, how do i set it to take full screen dimensions?

spare ice
#

Is QT or Tkinter better to use for microcontrollers? Or, how about node?

indigo crane
#

made some improvements to the custom tkinter popup menus :)

#

and also i tried making a custom diff viewer

digital rose
#

hey everyone,
can anyone please tell me how to customise title bar in tkinter

indigo crane
#

in your case, simply call .overrideredirect(True) on root, and add your custom title bar object, that will do

digital rose
#

`from tkinter import *
from tkinter import font

root = Tk()

def move_window(event):
root.geometry('+{0}+{1}'.format(event.x_root, event.y_root))

root.overrideredirect(True) # turns off title bar, geometry
root.geometry('400x100+200+200') # set new geometry

make a frame for the title bar

title_bar = Frame(root, bg='white', relief='raised', bd=2)

put a close button on the title bar

close_button = Button(title_bar, text='X', command=root.destroy)

a canvas for the main area of the window

window = Canvas(root, bg='black')

pack the widgets

title_bar.pack(expand=1, fill=X)
close_button.pack(side=RIGHT)
window.pack(expand=1, fill=BOTH)
Label(window, text='TEXT', font='Lucida 40 bold', fg='black').pack()

bind title bar motion to the move window function

title_bar.bind('<B1-Motion>', move_window)

root.mainloop()`

indigo crane
mighty rock
#

How should I iconify a window?

#

Just move it off the screen?

#

I also need an icon of an app appearing in the taskbar

indigo crane
ionic finch
#

How to show data in table format from a csv file in tkinter?

indigo crane
#

or use a bunch of labels on a grid, that works too

indigo crane
wraith plover
#

How do i change pygame application icon?

indigo crane
#
icon = pygame.image.load('icon.png')
pygame.display.set_icon(icon)
hollow wadi
iron knot
#

hey guys

indigo crane
sinful pendant
#

How do i remove/colour the outer while part of canvas

#

There is a white gap between canvas and bordee

eternal scroll
#

Hello is it possible to for example, when the user clicks the button it will change pictures

#

so I know how to use pictures as buttons but how could i configre the button when its clicked to change to another image?

#

anyone?

sinful pendant
#

U can put all images in list then u can iterate, them using index suck that the 'next' button will increase index value by one and then the image retreshes

ionic finch
#

How to display top 10 records from a csv file in tkinter?

kindred dome
#

Is it possible to change the colour of this flashing bar in entry widgets?

#

Oof, that image isn't great, you've got to look really close. If you can't see it, then it's the little bar that shows you where you are in the text when you click on it.

#

Nvm figured it out. It's this:

Entry(root, insertbackground="#FFFFFF")
digital rose
#

is there anybody familiar with PyQt can tell me How can i use 2 QTimer in a single script?

wary birch
digital rose
#

i tried, It crashes

wary birch
#

I'm really far from an expert, but my guess is that when the first timer emits the signal and you have it do something, the second timer gets "stuck" because you may be doing everything in the main thread. Perhaps you could try doing the task for each timer in separate threads?

#

I also need some help in case someone can give me a hand. I've been at this for hours and I can't spot the mistake. I'm sorry for barging in @digital rose

https://stackoverflow.com/questions/70057999/how-to-start-and-stop-a-camera-feed-with-opencv-and-pyqt5

digital rose
#

πŸ˜… i can't be a much help in this problem, i am not familiar with those

eager beacon
#

@digital rose what was the error message?

indigo crane
#

for example ```py

def change_icon():
btn.config(image=another_image)

btn = tk.Button(parent, image=first_image, command=change_icon)

indigo crane
indigo crane
#

settings highlightthickness=0 during the instantiation may not help, you will have to use .config()/.configure() method

indigo crane
#

the idea of creating a custom treeview that can hold more than just labels is getting interesting

sinful pendant
#

Using tcl?

indigo crane
sinful pendant
#

@indigo crane there is still a poxel space on right and bottom

#

I filled hightlightcolour with same screen colour

#

Oops sry for a ping, i just pinged u without thinking myself firstπŸ˜…

eternal scroll
#

Does anyone have like any starting code if I want to make different pages and in differnet files?

indigo crane
#

try these bd=0, highlightthickness=0, relief='ridge'

indigo crane
indigo crane
eternal scroll
#

we can use different classes

#

I saw this off somewhere

#
class Page2(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        label = ttk.Label(self, text="Page 2", font=LARGEFONT)
        label.grid(row=0, column=4, padx=10, pady=10)

        # button to show frame 2 with text
        # layout2
        button1 = ttk.Button(self, text="Page 1",
                             command=lambda: controller.show_frame(new_main_flixgen.Page1))

        # putting the button in its place by
        # using grid
        button1.grid(row=1, column=1, padx=10, pady=10)

        # button to show frame 3 with text
        # layout3
        button2 = ttk.Button(self, text="Startpage",
                             command=lambda: controller.show_frame(new_main_flixgen.StartPage))

        # putting the button in its place by
        # using grid
        button2.grid(row=2, column=1, padx=10, pady=10)
#

But I want the classes to be in different files

#

coz I'm planning on having alot of code and it wont all fit