#user-interfaces

1 messages · Page 79 of 1

modern bay
#

Idk

#

I didn’t write it

tawdry mulch
modern bay
#

I’m just wondering about that one specific part

tawdry mulch
wanton dust
#

I attempted to store a non-tkinker variable within the button widget. I was kind of stomped when I was trying to solve my issue.
But now that you asked, I realized I could solve it another way.

wanton dust
proven basinBOT
tawdry mulch
# wanton dust Yes.

Kay, anyway the user was asking for any improvement, anyway this is how I would make an tic tac toe, not sure if brute force is the best way...

wanton dust
tawdry mulch
wanton dust
ivory ember
#

from your code it appears you're subclassing QMainWindow from QtGui? It should be from QtWidgets. Try that and let me know if it works.

hoary pine
#
def linenumber():
    line = mylist.get(1.0,END)
    print(line,len(line))
    infol.config(text=len(line.splitlines()))```

```py
mylist =  Text(root)
mylist.pack(side = "bottom",fill=BOTH,expand=1)
root.after(10,linenumber)```
the problem:It prints  and do the root after only one time
split coyote
#

For some reason every time i install any module it always says "No module named...." whyyy

#

the modules r in the directory theyre supposed to be like any other ive installed

#

but theyre the only ones that dont work

tawdry mulch
hoary pine
#

it only do the loop one time

tawdry mulch
hoary pine
#

ok

tawdry mulch
#

Outside just do lineumber()

hoary pine
#

thank you

#

it worked

#

@tawdry mulch
How to detect which line the player cursor in Text

tawdry mulch
#

Keep in mind you can always google your questions, where most of beginner questions are fixed. For now, you need text_widget.index('insert').

#

Read the docs too, it has everything you will need to move from beginner squad

hoary pine
#

i am not beginner but ty

tawdry mulch
hoary pine
#

i have been around 9 months in programming

#

and that is my way to learn new things

#

learning some basics

#

and then making projects and learn

tawdry mulch
hoary pine
#

but this is what you think but not what i think

#

i cant say am pro

#

but am good

tawdry mulch
dire tinsel
#

i try to do a scrollbar in tkinter but only the scrollbar is appear and not the label :

global pagechoix_screen
    pagechoix_screen = Tk()
    pagechoix_screen.geometry("450x500+0+0")
    pagechoix_screen.resizable(0,0)
    pagechoix_screen.iconbitmap("icon.ico")
    pagechoix_screen.title("Recherche")

    main_frame = Frame(pagechoix_screen)
    main_frame.pack(fill=BOTH, expand=1)

    my_canvas = Canvas(main_frame)
    my_canvas.pack(side=LEFT, fill=BOTH, expand=1)

    my_scrollbar = Scrollbar(main_frame, orient=VERTICAL, command=my_canvas.yview)
    my_scrollbar.pack(side=RIGHT, fill=Y)

    my_canvas.configure(yscrollcommand=my_scrollbar.set)
    my_canvas.bind('<Configure>', lambda e: my_canvas.configure(scrollregion=my_canvas.bbox("all")))

    second_frame = Frame(my_canvas)

    my_canvas.create_window((0,0), window=second_frame, anchor="nw")


    

    Label (second_frame, text = "Oxygen", bg = "#283838", fg = "#bd1414", width = "300", height = "2", font = ("Airstrike", 30)).pack()

    Label (second_frame, text = "").pack()
    Label (second_frame, text = "Plusieurs résultats obtenus :", fg = "black", width = "300", height = "1", font = ("Bahnschrift SemiBold", 18)).pack()
    Label (second_frame, text = "").pack()

    results = collection.find({"nom": siterecherche})

    for result in results:

        Button (second_frame, text = result["ortho"] + " - " + emailfinal + "\n(" + result["username"] + ")", cursor = "hand2", command = lambda result=result:pagechoixtopagemdp((result)), relief = "groove", font = ("Bahnschrift SemiBold", 13), fg = "black").pack()
    
    Label (second_frame, text = "").pack()
    Button (second_frame, text = "Quitter", cursor = "hand2", relief = "groove", width = 15, height = 1, font = ("Bahnschrift SemiBold", 10), command = quitterpagechoix).pack()
brave belfry
#

is there anyone here with experience in pyqt? I'm attempting to make a desktop app and more or less everything except the GUI is done (from a previous project). I am not sure how to structure the GUI files as it all just becomes spaghetti. Any advice would be appreciated.

digital rose
#

in python tkinter , how do i trigger other gui app using 1st one?

tawdry mulch
digital rose
hazy willow
merry quartz
hazy willow
hoary pine
#

uhh help

#

i want to know the line number that the cursor hovering on

wanton sorrel
noble star
#

I would know some good stuff for video playing, in tkinter

hazy willow
hazy willow
proven basinBOT
#

@split barn Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!

hoary pine
stone walrus
#

Do you know some advantages for kivy? why should I use it?

#

What is the best gui module for Python?

tawdry mulch
wooden stirrup
#

Pyqt5 pyqt6

noble star
#

Hey

#

is it possible to loop over images and get like a video

#

with tkinter

tawdry mulch
hallow kettle
noble star
#

@tawdry mulch any solution ?

#

pls

tawdry mulch
noble star
#

this one python cv2image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) img = Image.fromarray(cv2image) imgtk = ImageTk.PhotoImage(image=img)

tawdry mulch
noble star
#

I hove a while loop

tawdry mulch
noble star
#

no, it's not a single image

#

let me share the code

#
def video_player(self):
        frame_counter = 0
        color_actif = (255, 127, 80)
        color_static = (0, 255, 255)
        thickness = 1
        radius = 5

        cap = cv2.VideoCapture(self.video)

        frame_datas = []

        while(cap.isOpened()):

            ret, frame = cap.read()
            if ret == False:
                break

            # cv2.imshow('video', frame)

            # if cv2.waitKey(25) & 0xFF == ord('q'):
            #     break

            for s in range(self.results_datas.shape[0]):
                if (self.results_datas[s][8] == frame_counter):
                    frame_datas.append(self.results_datas[s])

            for c in range(np.array(frame_datas).shape[0]):
                frame = cv2.circle(frame, (int(np.rint(frame_datas[c][1])), int(
                    np.rint(frame_datas[c][0]))), radius, color_actif, thickness)

            cv2image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
            img = Image.fromarray(cv2image)
            imgtk = ImageTk.PhotoImage(image=img)

            # my_image = ImageTk.PhotoImage(Image.open("images/img.jpg"))
            # # self.canvas.delete("all")
            # self.canvas.create_image(0, 0, anchor='center', image=my_image)

            # # Setting the image on the label
            # self.video_playing_space.config(image=imgtk)
            time.sleep(0.1)  # 0.1 for 10 frames/sec
            # self.canvas.update()  # Updates the Tkinter window

            frame_datas.clear()
            print(frame_counter)

            frame_counter += 1

            # print(frame_counter)  # <------- To delete after tests
            # return frame_datas

            cap.release()
            cv2.destroyAllWindows()```
tawdry mulch
noble star
#

canvas or frame

#

as it's possibee

#

possible*

tawdry mulch
# noble star canvas or frame

A Label makes more sense, anyway append those images onto a list, make the list global, then loop through this list and then show it in a label, you could show it inside the code itself, but you see, time.sleep() will freeze the GUI

noble star
#

when I implemented it on structural programm it works with a simple label, that I config in each iteration

#

but on OOP, in a class

#

I don't works

#

here is python video.config(image=imgtk) time.sleep(0.1) frame1.update() # Updates the Tkinter window

tawdry mulch
#

As I said avoid time.sleep()

noble star
#

like I have too much FPS

tawdry mulch
#

Use root.after()

#

Show me the function with config again

noble star
#

which one ?

noble star
#

you would me to use root.after()

#

and show to result ?

tawdry mulch
#

No without that, the old codes that does the update, with loops and config() all

noble star
#

here is ```python
path = open()

frame_counter = 0
color = (255, 127, 80)
thickness = 1
radius = 5

pause = False

Frames = video_to_images(path)
trajectories = np.array(processing(Frames))

cap = cv2.VideoCapture(path)

frame_datas = []

while(cap.isOpened()):

    ret, frame = cap.read()
    if ret == False:
        break

    for s in range(trajectories.shape[0]):
        if (trajectories[s][8] == frame_counter):
            frame_datas.append(trajectories[s])

    for c in range(np.array(frame_datas).shape[0]):
        frame = cv2.circle(frame, (int(np.rint(frame_datas[c][1])), int(
            np.rint(frame_datas[c][0]))), radius, color, thickness)

    cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
    img = Image.fromarray(cv2image)
    imgtk = ImageTk.PhotoImage(image=img)

    # Setting the image on the label
    video.config(image=imgtk)
    time.sleep(0.1)
    frame1.update()  # Updates the Tkinter window

    frame_datas.clear()
    print(frame_counter)

    frame_counter += 1

cap.release()
cv2.destroyAllWindows()```
#

video is just a Label

tawdry mulch
noble star
#

okay thnx

#

I got something

#

with another technique

tawdry mulch
noble star
#

but wait lol

#

let me show you the result

#

why the image is not completely displaying

tawdry mulch
#

You mean not taking entire space?

noble star
#

yes, and my video is more large then this

tawdry mulch
#

Dont know, might be something internal

#

For the space, I have to see your Label creation

noble star
#

I used canvas

#

self.canvas.create_image(20, 20, anchor='center', image=imgtk)

tawdry mulch
#

maybe anchor='nw'?

noble star
#

for 20, 20

#

it's the starting x and y no ?

tawdry mulch
#

x,y coordinates, starting depends on how your anchor is set

noble star
#

🥳

#

it works

tawdry mulch
#

Great

hallow kettle
#

I’m having some Qt problems, is anyone available to help?

wooden stirrup
#

Lots of public stuff here

#

All free and on YouTube

sharp tinsel
#

How in the world can I update columns in PySimpleGUI?

#

I have rows I want to remove and add a complete set of new ones

calm wolf
#

When using PyQT5, is there a way to change an already set Keyboard shortcut? I looked everywhere, and I couldn't find anything

#

Preferably using the KeySequenceEdit button provided

ember dragon
#

is there a way to add list of songs in tkinter?

tawdry mulch
ember dragon
#

like insert mp3 files

#

and then i can play them later

tawdry mulch
#

Not with tkinter, you should use pygame or something else @ember dragon

ember dragon
#

ok, thanks i will check it

ember dragon
tawdry mulch
ember dragon
#

alright

hazy willow
#

wait you could do mp3 files with pygame?

#

that's cool

tawdry mulch
digital rose
#

Is QT free?

hallow kettle
#

Is there official pyqtgraph animation for real time plotting, or do you have to implement threading?

dire tinsel
#

someone know how can i add a font into an exe who was convert with pyinstaller ?

native scarab
native scarab
dire tinsel
#

mmm yes but i'm not going to have the font which i want in that way

sterile dove
#

I have two questions about tkinter, how would I get the "Separator:" label and it's corresponding combobox on the same line, and while my horizontal scrollbar works, visually it shows that it takes up the whole bar. I'll post a snippet in a second.

#
modules_box.pack(ipady=20, fill="x", expand=True)
modules_scrollbar = ttk.Scrollbar(self, orient='horizontal', command=modules_box.xview)
modules_scrollbar.pack(fill="x")

separator_label = ttk.Label(self, text="Separator:")
separator_label.pack(fill="x", expand=True)
separator_box = ttk.Combobox(self, textvariable=separator)
...
separator_box.pack()```
sterile dove
#

I imagine I use tkinter's grid() function for the former, but I'm kinda shaky on how it works per se.

sterile dove
#

Nevermind, I got it to work with grid() and Frame()

quick relic
#

hi can some help me about an issue i had while creating a custom title bar with PySide6

#

this is error msg "Function: 'globalPos() const' is marked as deprecated, please check the documentation for more information.
self.dragPos = event.globalPos()"

#

this the code

worthy ridge
#

https://doc.qt.io/qtforpython-6/PySide6/QtGui/QMouseEvent.html#PySide6.QtGui.PySide6.QtGui.QMouseEvent.globalPos @quick relic

#

@quick relic to summerize use gloalPosition()

safe barn
#

hey, which UI library should i use if i want to show a camera feed(img/frame placeholder) and 2 logs

icy flower
#

Please suggest me any imporvement and give a review

safe barn
safe barn
# icy flower Please suggest me any imporvement and give a review

icons in the header are not on the same height/same size
icons are not the same style/ same line thickness/weight (especially the discover icon)

image looks scaled too wide in my opinion (this is because that the description, favourite/comment icons, profilephoto, title/subtitle are in a different box) i dont have this with instagram because it scales to the full width of your device

make a dark theme ;) or even better a dracula theme

i would not make the name and title not the same size (make title 12 and the subtitle 11/10)
place the title/subtitle directly beneath eachother

Not:
TITLE

subtitle

Do:
Tittle
subttile
ember dragon
#

def list_box():
    listbox = Listbox(window,bg='grey',font=('constantia',13))
    listbox.insert(1,'test')
    listbox.pack()

window = Tk()

window.geometry('600x400')
window.config(bg='black')
button1 = Button(text='Button',bg='white',command=list_box)
button1.pack()
window.mainloop()``` i have this code, when you click on the button it display a list, if you click again it will make another one, how can i make it that if you click again the list disappears
ember dragon
tawdry mulch
#

Create the listbox in the main block then do an if and check if the widget is on the placed, then remove the widget or place the widget

#
from tkinter import * 

def list_box():
    if listbox.winfo_ismapped(): # If not placed....
        listbox.pack_forget() # Place
    else:
        listbox.pack() # If placed, then forget

window = Tk()

window.geometry('600x400')
window.config(bg='black')
button1 = Button(text='Button',bg='white',command=list_box) # Create it just once
button1.pack()

listbox = Listbox(window,bg='grey',font=('constantia',13))
listbox.insert(1,'test')

window.mainloop()
analog iron
#

What is best termbox alternative?

#

If it exists?

noble star
#

why tkinter Entry returns me AttributeError: 'NoneType' object has no attribute 'input'

tawdry mulch
hazy willow
#

Ok so, I am trying to import a png file into my glinted ui

#

I know it’s supposed to be in the same file

#

But I keep getting error message

noble star
#

here is my code

self.fps = StringVar()
def fps_manager(self, text):
        self.fps_entry.set(text)

self.frame_up = Button(
            fps_frame, image=self.up_icon, command=lambda: self.fps_manager("new"))
        self.frame_up.grid(row=1, column=0)

        self.fps_entry = Entry(
            fps_frame, width=5, justify=CENTER, textvariable=self.fps)
        self.fps_entry.grid(row=1, column=1) ```
noble star
tawdry mulch
noble star
#

so.. is there any solution ?

tawdry mulch
#
self.fps_entry = Entry(....)
self.fps_entry.grid(row=1,column=1)
#

But even then keep in mind, self.fps_entry dont have set(), self.fps has set()

noble star
#

Yes you're right

noble star
#

It's not working

tawdry mulch
noble star
#

But, look I still it from here xD

tawdry mulch
noble star
#

Yeah

#

lol

tawdry mulch
#
def fps_manager(self, text):
    self.fps.set(text)
noble star
#

you are right

#

exactly bro

#

thank you

#

nice

#

a last thing

#

for self.fps = StringVar()

#

could we affect a default value ?

tawdry mulch
noble star
#

yes like self.fps = somethng

noble star
tawdry mulch
#

Prolly you need self.fps = StringVar(value='whatever string')

noble star
#

let me try it

tawdry mulch
#

Cool

noble star
#

is discord made by Next.js ?

noble star
#

What are the supported opperations on IntVar ?

tawdry mulch
noble star
#

TypeError: unsupported operand type(s) for +=: 'IntVar' and 'int'

#

yes like +=

tawdry mulch
ember dragon
#

i have a listbox, but instead of making a submit button i want to submit the choice with double click, how can i do that?

noble star
#

Is this code true

def fps_upper(self):

        self.fps = self.fps.get() + 1
        self.fps.set(self.fps)```
#

🤔

#

No it's not correct

lime monolith
noble star
#

Yeehhh

ember dragon
ember dragon
#

like this

#
root.bind'<Double-Button-1>',func2)```
ember dragon
#

the second one overwrite the first one i think

#

the first does not occure

#

but if i removed second, it works

tawdry mulch
#

First of all, there is prolly a syntax error

ember dragon
#

no no

#

i just typed wrong

tawdry mulch
#

2nd of all bind to the listbox

ember dragon
#

dont mind it

#

so i create a function for the listbox?

tawdry mulch
ember dragon
#

ooh, i will try it now

#

it worked!

tawdry mulch
ember dragon
#

thankss again

proven basinBOT
#

Hey @tawdry mulch!

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

tawdry mulch
#

Here is a little something made with tkinter

floral meteor
#

what do u think is better pyqt or kivy?

worthy ridge
#

Qt

maiden roost
#

is it possible in tkinter to automatically press a button once a set amount of digits are put in by the user in a entry box

tawdry mulch
maiden roost
tawdry mulch
ember dragon
junior oyster
#

hey could you please dm me an invite?

plush stream
#

Sure thing

atomic lagoon
#

why does this scrollbar extends full as in i want it to have some particular length

#

and second thing is that when i scroll down the data doesnt show smoothly

#

pls help thanks

#

scroll bar commands

frozen current
#

hello everyone, i am making a minecraft server manager in python, and in a minecraft server, there is a .properties file that contains all its properties. i would like to make a graphical editor out of it, i made this using a loop and tkinter, but this is only to show what i want to do, could you please give me some hints?

#

maybe a class ?

tawdry mulch
# atomic lagoon

Usually you would bind to the self.window, because that expands right

frozen current
# tawdry mulch Hints about what?

about generate entry from all the key in the file, and update it after modification on the gui, but @atomic lagoon tell me how to doing that in dm

tawdry mulch
frozen current
#

yeah the problem was to get the entry after the loop

tawdry mulch
frozen current
#

Im gonna try later, but it look like

tawdry mulch
#

If not, just create a list, then append all the entries to the list. So later you can loop through the list and get the values

frozen current
#

this is what PyKing proposes

ember dragon
#

i used bind on a listbox, when i click the list appears, but when i click again the items in list appears twice

hoary cypress
#

Hello, I just found out about PyQT5 and QT Designer, read its documentation but it lacks proper understanding of the package.

Can I get help on how QT Designer works and get the UI imported to a python file?

ember dragon
#
import os
import pygame
from pygame import mixer
from pygame import *
import time
cur_dir = (f'{os.getcwd()}\music')
print (cur_dir)
# get number of items
arr = os.listdir(f'{os.getcwd()}\music') # list items

print (arr)
number_files = len(arr)
l = []
f = range(number_files+1)
for s in f:
    l.append(s)
    
fs = l[1:]

def submit(ran):
    #global f
    f=(lb_beet.get(lb_beet.curselection()))
    print (f)
    pygame.mixer.init()
    os.chdir(cur_dir)

    pygame.mixer.music.load(f)

    mixer.music.set_volume(0.9) # optional
    mixer.music.play()

    while pygame.mixer.music.get_busy():
        time.Clock().tick(10)

def fun1(event):
    f=(listbox.get(listbox.curselection()))
    if f=='beet':
       lb_beet.place(x=100,y=0)
       #doub['state']='disabled'
    for nums, names in zip(fs,arr):
        print (lb_beet.size())
        lb_beet.insert(nums,names)

    #f.bind('<Double-Button-1>',submit)

#print (max(l))
def fun2(event2):
    print ('sa')
root = Tk()

def pause(is_paused):
    global paused
    paused=is_paused

    if paused:
        pygame.mixer.music.unpause()
        paused=False
    else:
        pygame.mixer.music.pause()
        paused=True

global paused

paused = False

width, height = root.winfo_screenwidth(), root.winfo_screenheight()
##010209
root.config(bg='#010209')

listbox = Listbox(root,bg='grey')
listbox.place(x=0,y=0)
listbox.config(height=38)
listbox.insert(1,'beet')

#root.bind('<Double-Button-1>',fun1)
lb_beet = Listbox(root,bg='#010209',fg='white')
lb_beet.config(height=38,width=100)
doub=listbox.bind('<Double-Button-1>',fun1)
listbox.bind('<Double-Button-1>',fun1)
lb_beet.bind('<Double-Button-1>',submit)


label = Label(root,bg='#242424')
label.place(x=0,y=615)
label.config(height=16,width=250)
root.geometry('%dx%d+0+0' % (width,height))
pause_im=PhotoImage(file='pause.png')
pause_bt = Button(image=pause_im,command=lambda: pause(paused))
pause_bt.place(x=640,y=650)

root.mainloop()```
#

it will work if you have music folder in current directory

#

and there are songs in it

hoary cypress
# tawdry mulch You can ask here

I want to know how the designer can link signals to widgets, and is it possible to make adding widgets dynamically by user input in the designer itself, and how the code extraction works

ember dragon
tawdry mulch
#

To get the code, there are 3 ways, I think. 1 is to go to Form on the top of the designer and view python code, the 2nd is to directly use the ui file, the 3rd is to convert from ui to py manually

#

1st is the easy as it is within the designer, the 2nd is also nice, because any changes made to the ui in the designer will directly reflect in the main python program fast

tawdry mulch
ember dragon
#
def fun1(event):
    f=(listbox.get(listbox.curselection()))
    if f=='beet':
       lb_beet.place(x=100,y=0)
       #doub['state']='disabled'
    for nums, names in zip(fs,arr):
        print (lb_beet.size())
        lb_beet.insert(nums,names)```
#

if you double clicked it will list the songs

#

if you clicked again the loop will repeat

tawdry mulch
#

ok then add lb_beet.delete(0,'end') before the loop starts?

ember dragon
#

i will try

#

it worked nicee

tawdry mulch
ember dragon
#

it loops through the files

#

in the folder

#

and display them

#

and the if statement, u may choose other thing than beet, if u chose something else

#

it displays songs from another folder

#

and so on

#

like album

tawdry mulch
#

Hmmm I see

junior oyster
#

Hey guys, I'm trying to implement Qthread with multiple checkboxes as shown here

#

check box 1 will run method 1 and check box 2 will run method 2

#

here's the code

#
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import QtWidgets
import time

class MyWorker(QObject):
    method_1 = pyqtSignal()
    method_2 = pyqtSignal()
    enable_button = pyqtSignal()
    disable_button = pyqtSignal()
    finished = pyqtSignal()

    @Py#7454qtSlot()
    def method_1(self):
        print ('method_1 started')
        time.sleep(2)
        print ('method_1 finished')
        self.finished.emit()

    @Py#7454qtSlot()
    def method_2(self):
        print ('method_2 started')
        time.sleep(2)
        print ('method_2 finished')
        self.finished.emit()

class MainWindow(QtWidgets.QMainWindow):
   def __init__(self, *args, obj=None, **kwargs):
                super(MainWindow, self).__init__(*args, **kwargs)
                self.setupUi()
                self.setupThread()
       
   def setupUi(self):
    self.setGeometry(100, 100, 600, 200)

    self.checkbox_1 = QCheckBox('Check box 1', self)
    self.checkbox_1.setGeometry(150, 75, 300, 30)
    self.checkbox_2 = QCheckBox('Check box 2', self)
    self.checkbox_2.setGeometry(350, 75, 300, 30)

    self.button_1 = QPushButton("Button 1", self)
    self.button_1.resize(200,40)
    self.button_1.move(175,150)
    self.button_1.clicked.connect(self.run_inference)

   @Py#7454qtSlot()
   def enable_button(self):
    self.button_1.setEnabled(True)

   @Py#7454qtSlot()    
   def disable_button(self):
    self.button_1.setEnabled(False)

   def setupThread(self):
    self.thread = QThread()
    self.worker = MyWorker()
    self.worker.moveToThread(self.thread)

    self.worker.enable_button.connect(self.enable_button)
    self.worker.disable_button.connect(self.disable_button)

    self.thread.start()
    self.thread.finished.connect(self.enable_button)
#
@Py#7454qtSlot()
   def run_inference(self):
        if self.checkbox_1.isChecked() == True:
            try:
                self.button_1.clicked.connect(self.worker.method_1)
                #self.worker.method_1()
            except:
                print('method_1 error')
            
        if self.checkbox_2.isChecked() == True:
            try:
                self.button_1.clicked.connect(self.worker.method_2)
                #self.worker.method_2()
            except:
                print('method_2 error')


app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
#

it kinda works, the issue is that I don't know how to connect a worker with a method

proven basinBOT
#

Here's how to format Python code on Discord:

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

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

junior oyster
#

I'm connecting the push button to my methods but I know that's not right since I have 2. When I try to connect self.worker with my method_1 it works but the UI freezes meaning qtread is not being used. Is there a way to do this?

   def run_inference(self):
        if self.checkbox_1.isChecked() == True:
            try:
                self.button_1.clicked.connect(self.worker.method_1)
                #self.worker.method_1()
            except:
                print('method_1 error')
willow kindle
#

How do I center using grid when I only have one column on tkinter?

#

I'm so lost rn

tawdry mulch
willow kindle
#

I managed to do it using pack

tawdry mulch
willow kindle
#

Is it tho?
I find it way more complicated.
Using pack() and some Frames feels more straight forward

tawdry mulch
#

The best way to manage is to combine pack() nad grid() like that

hazy willow
#

Hey, can someone help me install pygame on my computer? I tried to watch youtube videos contaning it but i get the error message when i put "python3 -m pip install pygame==2.0.0.dev6"

#

sudo easy_install pip

#

python3 -m pip install pygame==2.0.0.dev6

digital rose
#

my pygame overlay library, the text is a bit screwy and idk why

#

it seems to be drawing it multiple times

spark prism
#

oml

#

u made that?

digital rose
#

yeah

#

if you're not tabbed into whatever it's overlaying over it will stop drawing & hide the overlay

#

Nerdie send the code somewhere so i can see why multiple times

#
await overlay.handle()
                await overlay.draw_text(Vector(10, 0, 30, 30), 'red', 'Welcome Nerdie!', tahoma_font)
                await overlay.draw_text(Vector(10, 20, 30, 30), 'green', '', tahoma_font)
                await overlay.draw_text(Vector(10, 40, 30, 30), 'blue', f'Bhop: {self.cheat_settings.get_value("bhop")}', tahoma_font)
#

the code for that

#

with really bad indenting

digital rose
digital rose
tribal path
#

Tried added prints to confirm its being called just twice? And have you traced though what could be calling the function this is in

nimble wasp
tawdry mulch
tawdry mulch
noble star
#

hi guys

#

I got an error during returning 2 values on class

#

here is the error

#
  File "/home/desktop23/anaconda3/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "home.py", line 137, in analyze
    testObj = results(datas_result, self.filename).video_player()
  File "/home/desktop23/Development/Projects/PFC/spermatozoïdes_analyzer/Software/results.py", line 213, in video_player
    if (self.results_datas[s][8] == frame_counter):
  File "/home/desktop23/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py", line 2800, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/desktop23/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2648, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1618, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1626, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 0```
digital rose
#

bruh UI in python

#

🤣

#

TUI should be for python but GUI lol

noble star
#

I don't really know, I'm actually coding a GUI with tkinter and .. voila

noble star
tawdry mulch
noble star
#

I don't think

tawdry mulch
#

Then you can ask for help in help channels

noble star
#

Ahh okay

#

thankx

tawdry mulch
molten zealot
#

Hey guys, I was participating in a hackathon at my school where I had to make a GUI Application. I have used TKinter and made an app similar to Notepad. I would love if you guys would go and have a look at my project and maybe suggest me something. https://github.com/iDCoded/D-Pad

GitHub

A basic, generic use text editor using TKinter (Python) - GitHub - iDCoded/D-Pad: A basic, generic use text editor using TKinter (Python)

tawdry mulch
molten zealot
#

Ohh okay, thanks for your suggestions. I have a look

tawdry mulch
molten zealot
#

Great! Thanks a lot man.

tawdry mulch
spark prism
#

wow

tawdry mulch
spark prism
#

tbh idk I just said wow to remove the ping

distant swift
#

I want to connect a function to my QThread. When I used self.thread.change_value.connect(self.function) it showed me an attribute error. What am I suppose to use instead of change_value. Please help me. Ping me on reply.

distant swift
tight ice
#

anyone here use ursina?

tawdry mulch
blazing pine
digital rose
#

lol*

#

it's just an overlay

molten zealot
digital rose
#

lets be honest here

#

who tf doing uis in python

blazing pine
#

as a maintainer of pyqtgraph, I do, and so do a bunch of my users (many of which are in experimental labs). Anyone that wants to do interactive stuff involving numpy arrays....

digital rose
#

i hope someone doesnt introduce you to c#

blazing pine
#

what makes you think I haven't written code in C# before? it's a fine language; it doesn't have access to the pydata ecosystem which really is second to none.

plush stream
spark prism
#

im downbad for some front end tkinter programmers rn

distant swift
#

Is there anyone here who is expert in QThread and its signals and slots ?

blazing pine
cunning holly
#

hey guys

#

can someone help me with flutter, Im trying to install it on vs code and its saying that it can't locate the sdk file

stoic pebble
#

Hello guys. Can somebody give me a quick tip on how to lock mouse input from the user, but the script can move the cursor? I am using pyautogui, and I want to make it so pyautogui can move the cursor, put the user can't. Anybody got an idea? (don't worry, I'm making a silly prank to show to my friends, not a malicious app, I will make it so you need to go through an input continue yes/no before the script actually executes, also I hope I used the right channel.)

sturdy skiff
blazing pine
#

@sturdy skiff you are likely using the wrong coordinate system; which happens all the time so don't be surprised... for my use-cases, I typically do

# isinstance(self, ListView) is True here

localPos = self.mapFromGlobal(event.pos())
index = self.indexAt(localPos) 
sturdy skiff
#

I’ll try it out and lyk thanks! Although self.sender().pos() has been working except in this one case

#
row = self.get_sender_row()

local_pos = self.mapFromGlobal(self.sender().pos())
print(self.table.indexAt(local_pos))
#

output

<PySide6.QtCore.QModelIndex(-1,-1,0x0,QObject(0x0)) at 0x7fc027666280>
activated by row 1: index = 1, status = True, text = Sold
#

The first line of output is from mapFromGlobal, weirdly giving negatives and the second line is from self.get_sender_row() which uses self.sender().pos(), giving me the right row all the time except in one case @blazing pine

blazing pine
#

so self.sender().pos() is likely not giving you global coordinates ...EDIT: well maybe

#

in this case, what type is self.sender()?

sturdy skiff
#

<class ‘PySise6.QWidgets.QComboBox’> in both the working cases and the one faulty one

blazing pine
#

don't you need the coordinates of the mouse position (or mouse event more specifically) not the combo box itself?

sturdy skiff
#

I need the row because I’m duplicating the row and a combo box element is in one of the columns

#

the top is before i click the duplicate button

blazing pine
#

right, my point is when you're calling self.sender().pos() you're not getting the position/index your mouse is over, you're getting generic information about the position of the QComboBox. If you want to get information about what the mouse is over/clicking on, you need to look at the mouse event position.

sturdy skiff
#

wouldnt a qpushbutton sender pos and mouse event position on the button essentially give me the same thing?

blazing pine
#

sure, but there is only one element of a qpushbutton... or only one index; so you can't really get it wrong there

#

w/ QComboBox, you need more than just the fact that a QComboBox got clicked, you need to know which index was clicked on

sturdy skiff
#

The root of the problem is when I duplicate the combobox, i set the current index to whatever the original's is and this calls the function i set to currentIndexChanged. It duplicates in the right position but it randomly gives me that 0, 0 point after which the function set to currentIndexChanged uses thus unexpectedly modifying the first row

#

seems like my best bet is ignoring the function set to currentIndexChanged if its called from the duplicate function

blazing pine
#

sorry this sort of thing I struggle to grasp mentally without a dummy example replicating the issue.

#

generally speaking position mapping and conversion from one coordinate system to another (global, local, device, scene) can easily be messed up

#

(I always wished QEvent.pos() contained a "coordinate system" attribute so you can know what coordinate system the numerical values are represented from ....

sturdy skiff
#

thanks for explaining how a lot of the positioning works, will def be helpful in the future

blazing pine
sturdy skiff
#

ill def take a look, thanks for your time again!

nocturne breach
#

can someone help me over #help-kiwi ? I'm having an issue with pygame where the main menu is skipped when the code runs

willow kindle
#

Is there a way to reduce loading times when using .pack() and .pack_forget() ?

hoary cypress
#

I need help related to PyQT5. It's a stupid one, but I don't really know as a beginner on how to fix it :

Issue : I have added images in the UI using QT Designer app. NOTE : The images are in a different folder as that of the file. I, then, converted the .ui to .py and added the simple following code for the window to show :

import sys

from PyQt5.QtWidgets import (
    QApplication, QDialog, QMainWindow, QMessageBox
)

from UI import Main_Window #UI is the folder where the converted file is saved

class Main_Window_Class(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Main_Window.Ui_MainWindow()
        self.ui.setupUi(self)
    
if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = Main_Window_Class()
    win.show()
    sys.exit(app.exec())

Also, another thing to note, the generated file do have the path of the images. I don't know what's the issue here..

#

The path is located as follows in the generated file :

icon.addPixmap(QtGui.QPixmap("../Resources/Enter.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
digital rose
#
MainWidget:

<MainWidget>:
    Button:
        text: "heelo world"  ```
   "message": "Kivy files require #:kivy !",
```py
from kivy.app import App
from kivy.uix.widget import Widget
class MainWidget(Widget):
    pass

class ThelapApp(App):
    pass


if __name__ == '__main__':
    ThelapApp().run()
ThelapApp().run()```
wooden stirrup
#

Seems odd but it's way better to not to

#

Can just load ui in directly makes updating easier and live development possible without converting to python all the time

proven basinBOT
#

src/main/python/qvpnstatus/main.py line 72

mainwindow_ui = appctxt.get_resource("ui/mainwindow.ui")```
wooden stirrup
#

Can see how I load icons ui etc with lambdas

#

Reusable stuff I use in all my pyqt5 projects first link is for my custom skeleton copier with poetry and fbs for pyqt5 apps rapid prototyping

proven basinBOT
#

src/main/python/qvpnstatus/settings.py lines 23 to 30

# Create ui files path from app path and setup lambda to make it easy to use
ui_dir = os.path.join(app_path, 'ui')
ui_path = lambda name: (os.path.join(ui_dir, name))
ui_loader = lambda name, parent: uic.loadUi(ui_path(name), parent)

# Setup Qsettings for app name
app_settings = QtCore.QSettings('qvpnstatus', 'QVpnStatus')
config_data_dir = Path("qvpnstatus/QVpnStatus")```
wooden stirrup
#

I spent long trying to use the resources stuff and they like nuked it I think in pyqt6 iirc so I've been just dynamically loading the stuff I need like in the above which works nicely with fbs or pyinstaller etc

hoary cypress
# wooden stirrup Shouldn't need to convert ui to py

I do have to convert them to py. Acc to my knowledge, designer can only perform certain sets of functions and for using custom ones, you have code it, so its kind of necessary in this case to convert it to py

wooden stirrup
#

You can load ui object and then add your custom code to that widget

#

I did that for my terminal

#

Just add placeholder qwidget

#

And after ui loaded load your custom code onto it

hoary cypress
#

so will it work if I have to work with dynamic widgets and toggles?

wooden stirrup
#

No need to do it all that way just for the custom stuff

#

Yeah

#

Totally the whole convert to to py pyuic bs is time wasted

#

Spent months ducking with that only to find out its not needed at all lol

hoary cypress
#

cool I'll try it

#

thanks

wooden stirrup
#

I'm in pool atm but I can show you snippets when near pc if your need more clarification

#

Do all you can in ui file

#

Then add your custom stuff after that is loaded

hoary cypress
wooden stirrup
blazing pine
#

the ui -> template .py files for each set of supported bindings is always a thorn in my side (we do this in pyqtgraph). I think there are some bindings we support that don't have the ability to load ui files directly ...can't remember the specifics tho (I want to say pyside2 5.14.0 -> 5.14.2.2)

wooden stirrup
#

Pyside can do it too just slightly different syntaxes let me find you the example

#

I think that's what your looking for possibly?

#

Towards bottom difference between pyqt5 pyside2

#

That site and author is gold he's very nice and dope tutorials

hoary cypress
#

Is using .close() for closing a window good practice or there are better methods or it's the only method?

blazing pine
#

.close() is a perfectly valid/good method...

#

I know this is stretching the limit of "user-interfaces" but does anyone know how I would assign an array of line widths; for example I'm using


# handle array of colors
glEnableClientState(GL_COLOR_ARRAY)
glColorPointerf(self.color)

# currently only handles one line width :(
glLineWidth(self.edgeWidth)

# draws all my lines after passing an array of them
glDrawElements(GL_LINES, edges.shape[0], GL_UNSIGNED_INT, edges)

EDIT: for the record I'm a super-n00b when it comes to openGL; I'm working on expanding functionality in pyqtgraph

trail heron
#

For pyqt5 do you guys recommend using the designer or hard coding?

blazing pine
#

I don't think one way or the other is "better", it's a matter of what you're comfortable with

trail heron
#

Alright thanks, ill try both

blazing pine
hoary cypress
#

what is the best way to change the icon image using its checked property

#

without using custom pushbuttons

vale ivy
#

Hi, is there anyone here good with tkinter? I need help with a little something

ivory ember
cedar sail
#

Im trying to get python and git setup on pydroid3 IDE and termux on my phone, I'm following this guide but this step confuses me. Can someone give me more insight about the "go to my web service and create a package" means?

I'll have to copy the text since there's no files

Here:

Your first start
Take your favorite web hosting service, create a package in it. Copy the link to clone it. Then go on your device and open Termux. run the command cd /emulated/storage/0/programming/, your are now in your programming folder. Clone your repo with the following git clone https://web-hosting.com/myRepo (replace the link with the one you copied). When it's done, open your pydroid3 app, and open your cloned repo. Don't forget to add your package in the iiec_run.py.

I'm pretty new to using git so and I'm not exactly sure what this is doing here and what I actually need to do.

#

Yes exactly

wooden stirrup
wooden stirrup
#

I'd have to dig through my other app when on desktop to find you an example I know I have one for saving qsettings for actions checked state should be reusable

#

Some snippets

self.qIcon = lambda name: QtGui.QIcon(os.path.join(self.app_icon_path, name))


# Get absolute path to current dir app is running from even when frozen
app_path = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])))

# Create app icons path from above and setup lambda to make it easy to use
app_icon_path = os.path.join(app_path, 'images')
qIcon = lambda name: QtGui.QIcon(os.path.join(app_icon_path, name))


self.topdockWidget_view_action.triggered.connect(
            lambda visibility: self.toggle_visibility_widget('topdockWidget_view_action', visibility))
        self.leftdockWidget_view_action.triggered.connect(
            lambda visibility: self.toggle_visibility_widget('leftdockWidget_view_action', visibility))
        self.dnschecksdockWidget_view_action.triggered.connect(
            lambda visibility: self.toggle_visibility_widget('dnschecksdockWidget_view_action', visibility))
        self.rightdockWidget_view_action.triggered.connect(
            lambda visibility: self.toggle_visibility_widget('rightdockWidget_view_action', visibility))



    @staticmethod
    def value_to_bool(value):
        return value.lower() == 'true' if isinstance(value, str) else bool(value)

    def toggle_visibility_widget(self, widget, state):
        self.settings.setValue(str(widget), state)



browser.titleChanged.connect(lambda _, i=i, browser=browser: self.setTabIcon(i, terminal_icon_inactive) if (
                "WebSSH" in browser.page().title()) else self.setTabIcon(i, terminal_icon))
#

You can kinda get the idea of how you can use the checked state and if you use another lamba to set the Qicon for the button background or whatever or label pretty easily

#

actually i think you could probably do it too with QTCSS active properties too potentially

blazing pine
#

Signals connected to lambdas that reference self can cause Python reference count issues. In PyQtGraph we removed all usages there.

#

I think the issue was only prevalent in one set of bindings, can't remember if it was the PyQt or PySide bindings, but the issue was "silent" enough that we just removed that design pattern everywhere

wooden stirrup
#

Interesting. There's definitely lots of ways to accomplish the same objective so it's always trial and error and lots of testing to find right one ;)

blazing pine
#

We tried using functools.partial with no success either 😦

wooden stirrup
#

The only one I recall was thinking qsettings wrote immediately to disk even with cache disabled but it didn't lol

#

Damn now that's rough that's one of the other usual gotos

#

I tried to avoid globals but still have to use them for some things cause other stuff even with sqlite can have state issues at times

#

Saving widget states is royal pita for anything besides just positions and size

blazing pine
#

I wish I could remember which bindings it was; can probably track it down if I dig through the issue tracker/closed pull requests

hoary cypress
#

Uhh guys, I need ideas related to PyQT5 dynamic widget creation and placing of them. I do know how to create labels dynamically, but I am kind of confused on the placing and scrollbar settings stuff.

Actually, I have a space in my app (text browser) and I want to add the label on it on the top, left side (Its the easy part).

But, the hard part, I want one more widget to be created right just below the first one created, but on the right side. But, the label has adjust size property, so it will get scaled by the text.

For placing :
I am thinking of getting x on left and right side. Create the first label (which will be in the fixed position), and for the second label, I am thinking of placing the label in x-axis already planned, and add (1-2) values in the y-axis obtained from the first label.

For scrollbar :
I still don't know how to use it properly. Specifically, I will be using vertical scrollbar. I don't know how to make the system know that the label has surpassed the y-level and vertical scrollbar has to be shown and the 'maximum' to be adjusted acc. to the reach of the label.

Any ideas on how to improvise the placing thing, and help in the scrollbar thing.

#

And also, do labels have a fixed property for limiting x-axis (width) to a value

tawdry mulch
tawdry mulch
trail heron
#

Anyone know of any good pyqt tutorials/docs

wooden stirrup
# trail heron Anyone know of any good pyqt tutorials/docs
Python GUIs

Use Qt Designer to effortlessly build your application UI. When laying out your Qt GUIs it can be quite a tricky task to place every widget in the right position on your forms.

Python GUIs

Use Qt Designer's drag and drop interface to design your GUI. This tutorial requires Qt Creator to be installed — you can download it free from the Qt website.

Python GUIs

Learn how to use custom widgets in your PyQt5 applications when designing with Qt Designer. Qt Designer is a great tool for designing PyQt5 GUIs, allowing you to use the entire range of Qt5 widgets and layouts to construct your apps.

blazing pine
vale ivy
#

This is not working, can someone point something out.

swift halo
#

@vale ivy Did you mean root = Tk()?

vale ivy
trail heron
#

is it possible to use css with tkinter?

#

or any similar design ways

#

its so difficult to make tkinter look nice

oak saffron
wooden stirrup
#

Yeah qt had css style sheets which is real nice not given kivy a try in awhile but that is good to know

vale ivy
#

Does anyone here know how to create multiple labels with a loop?

vale ivy
#

I want to create labels that hold images

#

i want to be able to loop through a folder and display all the images on a window

#

To test it out, i make all the bg a different color

#

but the images dont show#

lime monolith
vale ivy
lime monolith
tawdry mulch
wraith aspen
#

I want to make a really quick and basic front-end for adding entries of DnD miniatures to my postgres database.
In its most basic form, it only needs to navigate to a folder and display a selected .jpg image from that folder, and take text input in predetermined fields. Eventually; get lists from the database and display those list in drop down menus, sanitise input, shortcuts, etc.

A TUI would be cool, but I think I need a GUI because of the image thing (there is a really cool program in Rust for displaying images in the terminal but ...). Tk is fine for now but Kivy or DPG looks really good.

Questions:
If I am still a novice, and I want to get just something functional up really quickly, should I build a basic program using Kivy or DPG (docs from both look fairly complicated to me)?

If I use Tk, is it easy to upgrade to Kivy or DPG in the future and are there any pitfalls I should be aware of, or ways to make the Tk code more modular?

vale ivy
#

😫

tawdry mulch
vale ivy
#

I made a class for the images but still not working

tawdry mulch
vale ivy
#

thats basically what i done

#

the class where create_label is for the whole page

tawdry mulch
vale ivy
#

The class that is for individual images has self.

wraith aspen
tawdry mulch
#

See first of all, stop posting images of code, just paste the code itself, so we can copy it and modify and paste back

vale ivy
#

will do

tawdry mulch
tawdry mulch
vale ivy
#

class App(tk.Frame):
def init(self, master=None):
super().init(master)
self.master = master
self.pack()
self.counter = 0
self.colour = ["red", "blue"]

def create_lable(self,img):
    img1 = Image.open(img)
    resized = img1.resize((100, 100), Image.ANTIALIAS)
    img2 = ImageTk.PhotoImage(resized)
    Lable_name = tk.Label(self.master,image=img2,bg=self.colour[self.counter])
    Lable_name.pack()
    self.counter+=1
    #Lable_name.place(x=row, y=column, anchor='center')
#

####################################

#

class for window

#

####################################

#

class Page:
def init(self, page):
self.page = page

#

################

#

class for individual images

tawdry mulch
proven basinBOT
#

Here's how to format Python code on Discord:

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

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

vale ivy
#
class App(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.counter = 0
        self.colour = ["red", "blue"]

    def create_lable(self,img):
        img1 = Image.open(img)
        resized = img1.resize((100, 100), Image.ANTIALIAS)
        img2 = ImageTk.PhotoImage(resized)
        Lable_name = tk.Label(self.master,image=img2,bg=self.colour[self.counter])
        Lable_name.pack()
        self.counter+=1
        #Lable_name.place(x=row, y=column, anchor='center')
tawdry mulch
#

Perfect

#

@vale ivy Now try this:

def create_lable(self,img):
        img1 = Image.open(img)
        resized = img1.resize((100, 100), Image.ANTIALIAS)
        self.img2 = ImageTk.PhotoImage(resized)
        Lable_name = tk.Label(self.master,image=self.img2,bg=self.colour[self.counter])
        Lable_name.pack()
        self.counter+=1
        #Lable_name.place(x=row, y=column, anchor='center')
vale ivy
#
    def __init__(self, page):
        self.page = page
wraith aspen
vale ivy
#

Ok, the last image is showing now

tawdry mulch
#

@vale ivy Hmmmm something wrong with the code prior of the way you are storing this, paste the entire code in the site below

#

!paste

proven basinBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

tawdry mulch
lime monolith
#

Only the last image has a reference if you are calling the create_label method twice

#

Self.img2 gets overwritten

#

If you keep a reference on the pointer to the label instead it should be ok

tawdry mulch
#

Storing in list is the solution to those cases(sometimes), but its better to see the whole code because there are plenty of other mistakes here too

vale ivy
#

I would like to thank my mom

#

my dad

#

and my friends in python discord

lime monolith
vale ivy
#

@tawdry mulch thank you

#

@lime monolith thank you

oak saffron
wraith aspen
oak saffron
tawdry mulch
# wraith aspen Yeah, I joined the DPG discord a few hours ago to have a quick look. You're a mo...

Well the reason why people prefer tkinter is just that it is simple to use and has all(or atleast most) of the tools required to make a modern or a complex UI, because the UI and backend will both be in python, and ofc you can itself guess that python is not a front end language per se so the GUI will also have its own par looks, but this shouldnt be an issue because none of these GUI frameworks are natively made with python

wraith aspen
#

Using a simple built-in and maintained library is a strong selling point.
Realistically, I shouldn't put too much time into anything at the moment. Despite my aversion to a minimal viable product (why do anything unless you're gonna do it well?), it's actually a pretty good model for this industry.
I might give DPG a couple of hours after lunch and see if I can get the most basic things up and just fall back to tk if it involves anything more than modifying a patchwork of code from online tutorials.

tawdry mulch
oak saffron
#

Yes

tawdry mulch
wraith aspen
#

But also: tk for docs and self-learning; Kivy looks very popular here and there are a lot of people; DPG is still young, but that can be a good thing when enthusiasm is high (and it's a better fit for updated version of stuff (prob)).

tawdry mulch
ivory ember
#

did u try something with QSizePolicy?

sturdy skiff
#

lol what

ivory ember
safe dirge
#

Hey I want to make my own interface through python as a learning curve and looking to make something like this. I’m looking into tkinter, would that be best for it?

sturdy skiff
#

nvm 2nd constructor needs horizontal and vertical, idk the 1st

safe dirge
tawdry mulch
# safe dirge

Are you a beginner? Then use tkinter to study the basics concepts of a UI first, move onto PyQt to make such modern UI

regal pulsar
#

Do i need to separate my main code from my window code (using tkinter) Cause i'm trying to make my button toggle on and off a while loop

#

My first thought was putting the while loop stuff on a separate thread but... that doesn't feel right

#

(please ping me when responding)

regal pulsar
#

Google says multithreading...

#

Guess i'm gonna do that

digital rose
#

@slender iron asd

oak saffron
hoary cypress
#

I need help with QScrollArea for PyQT5. I added some labels in the ScrollArea with Qt Designer but the scroll bar isnt showing. Setting it to always show, scrollbar doesn't let me scroll. Any ideas why is this happening?

#

P.S.: I just drag and dropped the labels in the scroll area

glass ferry
#

yo

#

I need help

#

with pyqt5's context menu\

#

Everything except the context menu works

#
def __init__(self, app):
        super(Ui, self).__init__()
        uic.loadUi('./lib/mainapp.ui', self)

        self.EntryTime.setTime(defaultTime)
        self.thread = QThread()
        self.obj = background.Counter()

        icon = QtGui.QIcon()
                
        icon.addPixmap(QtGui.QPixmap
        ("icon.png"), QtGui.QIcon.Selected,
         QtGui.QIcon.On)

        self.setWindowIcon(icon)

        # Create system tray app
        self.tray_icon = QSystemTrayIcon(self)
                  
        self.tray_icon.setIcon(QIcon
        ("icon.png"))
 
        '''
            Define and add steps to work with 
            the system tray icon
            show - show window
            hide - hide window
            exit - exit from application
        '''
        show_action = QAction("Show")
        quit_action = QAction("Exit")
        hide_action = QAction("Hide")
        
        tray_menu = QMenu()
        tray_menu.addAction(show_action)
        tray_menu.addAction(hide_action)
        tray_menu.addAction(quit_action)
        self.tray_icon.setContextMenu(tray_menu)

        #events
        self.removeEntry.clicked.connect(self
        .removeEntryfunction)
        self.addEntry.clicked.connect(self
         .compileEntryData)
        self.runbutton.clicked.connect(lambda: 
         self.run(app))

        self.show()
#

the menu doesn't show up when I right click

glass ferry
#

it works if I execute with the file

#

I made a class object

#

with QSystemTrayIcon inside another file

#

and when I execute it. It works

#

But when trying to execute it from my main gui\

#

it doesnt

tight ice
#

uhhh

unreal dirge
#

Good morning everyone, just a quick Python question, would anyone know of a package handling interactive maps such as folium or leaflet on JS that could be embedded into PyQT and handle live updates on data?

orchid tartan
#

Sup, I'de like to do some gui devolopement with python. Is there and projects i can try?

tawdry mulch
orchid tartan
#

Aght thanks :)

radiant dirge
#

is there a way to reduct the vertical margin on an QHBoxLayout? I tried with setContentMargin(0,0,0,0) but it seems to only apply 0 to left and right margin, vertical spacing remains

regal pulsar
#

How (using tkinter) can i limit the amount of characters in my entry box?

molten zealot
#

Well there is no straightforward way of doing so. But here is my take:
You can use set().
Example:

entry = StringVar() # Store the text in the   Entry box.
entry.set(entry.get()[:9]) # here, 9 is the range.
#

@regal pulsar , I have given the basic code to help you understand how it will work.

regal pulsar
#

Thanks

paper copper
#

After tkinter's replacement with a third-party theme, the program opens very slowly and how to resolve it

#

It used to take only 3 seconds, but now it takes 10 seconds

#

the exe file opens really slowly too.

tawdry mulch
paper copper
tawdry mulch
paper copper
#

The tk and ttk themes are a little ugly.

tawdry mulch
paper copper
#

Thank you anyway.

#

I can't find the answers on google.

#

so strange

tawdry mulch
paper copper
#

You have a point.

#

I ran it again just now.

#

It took 20 seconds for the program to start.

#

too slow

#

Don't you think so?

#

Something must be wrong

tawdry mulch
paper copper
#

@tawdry mulch I use " from ttkthemes import * "in my code.There are many themes in this moudle.Maybe I should import only one theme ?

tawdry mulch
wooden stirrup
wooden stirrup
# tawdry mulch which framework?
import sys
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QDialog, QPushButton, QVBoxLayout, QApplication, QSplashScreen
from PyQt5.QtCore import QTimer


class Dialog(QDialog):
    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)

        self.b1 = QPushButton('Display screensaver')
        self.b1.clicked.connect(self.flash_splash)

        layout = QVBoxLayout()
        self.setLayout(layout)
        layout.addWidget(self.b1)

    def flash_splash(self):
        self.splash = QSplashScreen(QPixmap('/home/user/PycharmProjects/WizardAssistant/src/main/icons/Icon.png'))

        # By default, SplashScreen will be in the center of the screen.
        # You can move it to a specific location if you want:
        # self.splash.move(10,10)

        self.splash.show()

        # Close SplashScreen after 2 seconds (2000 ms)
        QTimer.singleShot(20000, self.splash.close)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = Dialog()
    main.show()
    sys.exit(app.exec_())

tawdry mulch
wooden stirrup
#

but yeah i didn't know about it as first either but its super cool

tawdry mulch
wooden stirrup
#

That's honestly just a test snippet

#

I don't use that example in production code :)

#

I just save handy examples that are self contained for times where I want to share

tawdry mulch
#

Perfect !

wooden stirrup
#

Also qsound ;)

brazen shoal
#

Epilepsy Warning

#
import os, time

class app:
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self.grid = 0

    def wipe(self):
        self.grid = [["█" for _ in range(self.height)] for _ in range(self.width)]

    def __str__(self):
        full = ""
        for i in range(self.height):
            row = ""
            for j in range(self.width):
                row += f"{self.grid[j][i]} "
            row += "\n"
            full += row
        return full

    def set_pixels(self, posX, posY, val):
        try:
            self.grid[int(posX)][int(posY)] = val
        except IndexError:
            pass

    def redraw(self):
        print(self)
        self.wipe()
        os.system("cls")
        time.sleep(0.025)
            
app = app(70, 40)

pX = 1
pY = 1
vX = 2.4
vY = 0
aX = 0
aY = 0.4

radius = 1
app.wipe()
while True:
    vX += aX
    vY += aY
    pX += vX
    pY += vY

    
    if pX > app.width-radius:
        vX = -abs(vX)
    if pY > app.height-radius:
        vY = -abs(vY)
    if pX < radius:
        vX = abs(vX)
    if pY < radius:
        vY = abs(vY)


    if pY > app.height+10:
        pY = 0

    app.set_pixels(pX-radius, pY-radius, " ")
    app.set_pixels(pX-radius, pY, " ")
    app.set_pixels(pX-radius, pY+radius, " ")
    app.set_pixels(pX, pY-radius, " ")
    app.set_pixels(pX, pY, " ")
    app.set_pixels(pX, pY+radius, " ")
    app.set_pixels(pX+radius, pY-radius, " ")
    app.set_pixels(pX+radius, pY, " ")
    app.set_pixels(pX+radius, pY+radius, " ")


    app.redraw()

Bouncy Ball :>

wooden stirrup
brazen shoal
#

its crazy that there is and ascii character for this: █

swift halo
verbal storm
#

sorry

glass ferry
#

tkinter vs pyqt5 which is better

#

Pyqt5 has more features?

#

Ui designer is a plus

molten zealot
# glass ferry tkinter vs pyqt5 which is better

Tkinter is really beginner friendly and a lot can be done easily. It is great to start out but does not have too many advanced features, don't worry though, it has just enough features to get your job done.
Tkinter is a great starter choice in my opinion. I have started out with Tkinter.
If you choose Tkinter, I have multiple resources for you too, which includes YouTube videos and even Book PDFs.
But PyQton the other hand is much more advanced, has many additional features which might not be needed every time but it is great to have them.
And as you have mentioned, QT Designer is a really big plus point of Qt. It makes designing much more easier and efficient.

glass ferry
#

it depends is the short answer

oak saffron
swift halo
#

well, electron apps give me windows 2k vibes because of how slow they get sometimes 🙂

#

I ran VSCode on a decent (for 2012) laptop, wasn't the smoothest

molten zealot
oak saffron
tawdry mulch
wooden stirrup
# swift halo well, electron apps give me windows 2k vibes because of how slow they get someti...

this man the worst part is every electron app has it's own chromium which is both good and bad cause if it installed like a chromium library independently if chrome was not installed it would make them lighter weight and also ensure that the browser component stayed up to date and all the other electron apps could use the same one. I'm sure they will solve it in the future. Webview was really nice for that reason in past. But having like 300MB+ plus just to run a local website for an app is pretty intense. Even with PyQT5 and QtWebengine bundled my binaries are small as hell. Packaging for Mac duplicates some stuff otherwise it would be tiny

distant swift
#

I got error while using thread in kivy. Please help me to fix it

tt.start()```
actually when I call this the entire gui get stucked
tawdry mulch
lofty pond
trim crown
#

If you dont want to use lambdas I suggest using partialinstead

#
search_with_query = partial(self.search, query)
Thread(target=search_with_query)
mossy karma
#

Thread has an args parameter already. so Thread(target=self.search, args=(query,))

wraith aspen
# tawdry mulch While the _most official_ docs(PDFs) are a great help, most YouTube videos on tk...

That's a bit surprising. Thought tkinter was pretty static and defacto.

Youtube videos are a bit of a weird one for programming to me. There's (virtually) no vetting process for anyone can make them and the languages get updated so fast a video doesn't age well. Videos for established programs are often a safe bet (Vim... some databases), and videos about abstract concepts or fundamentals (Corey Schafer's Python videos) can be pretty good. So, that's a pity there aren't decent videos on tkinter.

tawdry mulch
# wraith aspen That's a bit surprising. Thought tkinter was pretty static and defacto. Youtub...

It is just that the main reason tkinter is recommended to beginners is that it has the basic concept of event loop that is used in higher level GUI, so understanding with tkinter is easier than on any other higher level framework, then most videos just show how to code or write code not explaining the concept or the reason behind it. Not to mention alot of people even show bad coding practices, bla bla

wraith aspen
#

Ah, yeah, I see that. At tech, we did event loops for a CLI first, actually it was more like a TUI (but nothing like the CodeJam stuff), and tk was left for the last few weeks with flask and ... something else, just to show where the language could go.
That's one of my dislikes for the minimal viable product model, as long as it works, bad coding practices are less of an issue. I've def been guilty of them. But the world is really losing patience as a whole.

tawdry mulch
wraith aspen
tawdry mulch
#

Okay I should stop being conclusive with just < 20 years of experience in life 😛

wraith aspen
radiant dirge
#

what's the best way to pass additional information to a Signal in Qt? For example, when I dynamically create a menu:

        for player in team.players:
            act = QAction(player.position, mnu)
            mnu.addAction(act)

I want to pass the 'player' object.
I could create a subclass of QAction with a custom Signal but was wondering if there's an easier solution with less code?

mossy karma
#

pass it into what exactly?

#

into the slot that'll get called when the action is selected?

radiant dirge
#

yes

act.triggered.connect(self.playerClicked)
#

so in self.playerClicked I know what player is clicked on

mossy karma
#

a lambda should suffice

radiant dirge
#

ah so each instance gets their own slot

mossy karma
#

lambda: self.playerClicked(player)

#

each instance of what?

#

you can reuse a method as a slot as many times as you want

radiant dirge
#

so how do I use the lambda in the slot?

mossy karma
#

just pass it as the argument to connect

#

also addAction can take a slot as a second argument

#

to save some time

radiant dirge
#
act.triggered.connect(lambda: self.playerClicked(player))
#

like this, seems to work fine. thx!

mossy karma
#

yep

#

no worries

radiant dirge
#

seems the lambda function doesn't work. It always returns the same object:

    act.triggered.connect(lambda: self.playerClicked(player))


    def playerClicked(self, player: Player):
        print(player)
#
<Player object at 0x00000130B628F280>
<Player object at 0x00000130B628F280>
#

although I clicked on different items

#

that's the reference to the last object in the list, no matter on what item I click

#

ah a bit of googling gave me the solution:

act.triggered.connect(lambda state, x=player: self.playerClicked(x))

The x=player bit is important in this lambda

digital rose
#

looking clean catstare

misty canopy
#

are these weekday names in some other language?

#

Wo, So pithink

digital rose
#

oopsey

frosty spear
#

wednesday was originally called woden's day or odin's day

#

and for sonday idk

#

maybe someone who doesn't know english well typing that

digital rose
#

just typed fast idk

tawdry mulch
sturdy skiff
nova tangle
#

What is Consilium?

#

I need an advice. What's the best program for making GUIs?

digital rose
#

it means “advice, plan” and it’s a planner

#

pyqt is the best to use in my opinion as you’ve got qt creator

nova tangle
obtuse thistle
#

kivy is probably friendlier than qt, but i haven't actually used qt

nova tangle
#

Ok, I guess I am going to try Kivy

tawdry mulch
#

easy? beautiful? perfomance?

nova tangle
#

The best with I can start

tawdry mulch
nova tangle
#

Oh

#

I'm confused right now XD

tawdry mulch
#

You said best to start with? Then it is tkinter. Beginner friendly

nova tangle
#

Ok, thank you

tawdry mulch
#

PyQt and Kivy both have steeper learning curve

prime creek
#

Personally, I switched from PyQt to PySide since it's officially supported by Qt

prime creek
#

Is there a reason why y'all choose to use PyQt over PySide?

#

Just curious

tawdry mulch
#

I mean basically its the same thing itself...

prime creek
#

Fair enough

#

I just wanted to make sure I'm not missing something

#

You have no clue how many hours I've poured into researching different bindings/libraries

nova tangle
tawdry mulch
tawdry mulch
prime creek
#

I'm creating embedded software for my job so I'm always looking for the most 'proper' route

#

In an ideal world I would be using C++ but I was hired with the constraint of it being written in Python and now here we are

prime creek
#

21

tawdry mulch
nova tangle
#

I'm 15

tawdry mulch
#

im 4 :c

nova tangle
#

Sus

prime creek
#

It's an internship really but I'm technically supposed to be graduated already and they are just waiting to hire me once I do

prime creek
#

I don't regret using Python since it's an amazingly dynamic language

tawdry mulch
prime creek
#

I'm one of 3 maybe 4 people in the entire company that can code

#

And I'm the only one working on this massive project 😭

nova tangle
prime creek
#

Building control/automation software for a temperature-vacuum chamber

tawdry mulch
#

What's the API

digital rose
#

it just depends on whatever you want to do with coding

prime creek
tawdry mulch
prime creek
#

Ah, I'm building for a raspberry pi that communicates to two hardware controllers over GPIO (one is controlled over modbus RS-232 protocol and the other over ascii serial commands)

tawdry mulch
prime creek
#

It all fits in a control box with relays and such cause there are a ton of peripherals to control

tawdry mulch
#

But hey I have 0 knowledge, not even into a university yet🤦 so not gonna judge the difficulty

prime creek
#

I avoided rudimentary frameworks cause that's a ton of boilerplate code to write myself

#

Qt gives me all of the basic tools and things like a state-chart XML module which lets me model the controllers externally

prime creek
#

It's like reading several textbooks and then figuring out how to actually build something

#

LOTS of documentation skimming and at times I even had to go to the C++ source code to figure out what the hell was going on internally since documentation can sometimes fail you

#

When I started here in the winter of 2019, I literally spent a month staring at a screen trying to figure out:

  1. How to code Python, lol
  2. How to build a GUI and which framework to use
#

I ended up having literally a blank screen with a few widgets displayed by the end of it and those idiots still hired me back

#

Anyways, there's my wall of text and hopefully some useful information for some of you

tawdry mulch
paper copper
#

@tawdry mulch The slow opening of the program may be due to a problem with the module.

#

After I changed another theme module, the opening speed became faster.

paper copper
#

ttkbootstarp

#

I used a moudle called ttkthemes before

rapid solstice
#

what are those

#

actually nvm i will search it myself

tawdry mulch
paper copper
#

😀

wraith aspen
sudden coral
#

But... all web pages are user interfaces. So you're saying they're all icky?

twin rapids
#

how do i add a mp3 music running on a python prgram?

#

ping me if you know

tawdry mulch
prime creek
#

Got some tautologies going on in here

tawdry mulch
#

Lol

tawdry mulch
twin rapids
prime creek
#

Is it even possible to play sounds from a terminal program?

#

AFAIK you can only trigger ANSI bell sounds if the shell even supports it

twin rapids
#

ive heard about subprocess

prime creek
#

I honestly don't know I'm not familiar with the packages you're using

twin rapids
#

i only use os and time and thats it

#

ive tried mpg123 but it shows terminal text

#

i dont want that

#

is it possible to make a tkinter terminal?

prime creek
#

Its a GUI framework so you most certainly can

twin rapids
#

oh

#

ok

#

ima see how

prime creek
#

Wait though

twin rapids
#

yea?

prime creek
#

You should be able to play sounds with pygame, why aren't you able to?

twin rapids
#

it shows error

prime creek
#

You don't need to make your own terminal program also, so ignore what I said before cause I was being stupid

#

If it showed an error, did you try searching for an answer on google?

twin rapids
#

i just found another idea

#

wut

merry quartz
#

<@&831776746206265384> this

merry quartz
twin rapids
#

oh ok

prime creek
#

What was a scam?

twin rapids
#

btw another question how do i change xterm background and colors

#

nvm found it

tawdry mulch
jaunty gate
#

Hello guys i have a qiestion, is there a way to develop gui in python by using css or css frameworks like bootstrap or tailwind?

tribal path
#

!pypi eel

proven basinBOT
#

For little HTML GUI applications, with easy Python/JS interop

rancid rapids
tawdry mulch
#

People often forget that python isnt a language designed for making apps

#

But sure you can use Kivy ig, was there a version of PyQt that does this too?

distant swift
#

Someone please help me to fix this:

When I tried to convert my kivy to apk in google colab (buildozer), first I uploaded my files including a python file, a kv file and two ttf font files. After I ran !buildozer init I got error. then I removed threading from requirements and tried again. The code ran without error . I downloaded the apk. Then it happened. I can't even installed the app in my mobile. Now I'm mad

Ping me on reply

winged fossil
#

kivy for android is just madness

#

i almost made me kill myself.

distant swift
#

The problem comes when we take all the effort and time to create a kivy app and at last when we realize our app won't work as a true mobile app instead just a program my veins will blast!

tribal path
#

Cant even install sounds like an os side issue; if the build completed fine. Tried installing via adb and see what it reports back as to why it wont install

distant swift
distant swift
winged fossil
#

Adb helps u connect windows with android

digital rose
winged fossil
#

You can use python library ppadb

#

Its really convenient

digital rose
tribal path
#

Would need adb logcat to debug the crash

winged fossil
soft bone
#

How do I add a pad between them?

#

when I add a pack(padx=1) they appear vertically

#
DayEntry= ttk.Entry(app, width=3, font=("Arial",18,""),
                 textvariable=day)
DayEntry.place(x=30,y=20)
DayEntry.pack(pady=20)

hourEntry= ttk.Entry(app, width=3, font=("Arial",18,""),
                 textvariable=hour)
hourEntry.place(x=80,y=20)
hourEntry.pack(pady=20)
  
minuteEntry= ttk.Entry(app, width=3, font=("Arial",18,""),
                   textvariable=minute)
minuteEntry.place(x=130,y=20)
minuteEntry.pack(pady=20)

secondEntry= ttk.Entry(app, width=3, font=("Arial",18,""),
                   textvariable=second)
secondEntry.place(x=180,y=20)
secondEntry.pack(pady=20)
#

using tkinter btw

digital rose
#

Can you use PIL or tkinter to stretch image when expanding and maximizing the window>

#

?

soft bone
#

@digital rose expand= True

#

btn.pack(expand= True) I guess

digital rose
#

Im using canvas

#

its anchored nw

soft bone
#

oh sorry

digital rose
#

fill both and expand true

#

though it doesnt stretch right?

soft bone
#

It should

#

Idk about images tho but I guess it should

distant swift
distant swift
digital rose
#

@soft bone I cant get to expand past original size. So I wasnt sure if you could.

soft bone
#

It may help you

twin rapids
#

acer c733

#

4 gb ram

#

32 gb strage

#

storage*

tawdry mulch
tawdry mulch
tawdry mulch
twin rapids
#

@jaunty haven from tkinter import tk

shell blade
#

anyone know how can i play audio from online source using py??

tawdry mulch
shell blade
shell blade
#

i mean i can open the streamable link on chrome

tawdry mulch
#

I am not sure if you can stream like that....Is this a music player? @shell blade

shell blade
#

no its just a link that leads to mp3 file which you can stream using chrome

#

i just wanned to knwo if there's a way i mean people said i can use pyaudio but i couldnt find any valid souce about that

tawdry mulch
shell blade
#

nope i mean its just like discord py..but instead of streaming it on a voice channel i wanned to run that on local machine

shell blade
#

i can run with vlc but that wont work on python script so technically cant 😦

tawdry mulch
shell blade
eager viper
#

I could use some guidance

#

I'm working on a graphics library, and I'm kinda lost in the weeds

#

I spent the last few weeks working on what I'm starting to think is a lemon

#

So its back to the drawing board, and I could use, in the very least, someone to discuss the project with

tawdry mulch
shell blade
#

just say your issues people will come to help

eager viper
#

I'm working on an actual graphics library

#

It's supposed to enable standalone Python applications via webgraphics

#

Pure-python control over the DOM

#

In short; wxPython is used to create OS-native windows, and a framework called cefPython (an HTML renderer) is embedded inside each window. The HTML being launched in a window is parsed using beautifulsoup and a 'proxy dom' is generated. Using properties, changes to the dom are transmitted to Javascript via the their shared runtime (cefpython) and presto chango, pure-python webgraphics

#

And the theory is sound. I've built a working prototype in the past for personal use, but now I'm trying to refine it into something other's can use

#

And I just spent about a month trying to split each window off into its own process to increase performance. Big mistake.

#

So I'm going back to the drawing board, and I'm lowering the bar significantly. I'd like to start by limiting the number of windows to one. However, I do want a multithreaded approach so that user-defined callbacks listening for events from the renderer can execute without slowing down rendering

#

😐 Now that I say it out loud though — I'm betting both these libraries already have measures in place to keep rendering going smoothly

#

This is an example of an ultra-basic version of what I'm after.

#

I suppose I'll start with just one window and one thread, and focus on just getting the proxy DOM and basic widget controls up and running. I'll worry about the bells and whistles later, I guess...? Anyone have any thoughts?

#

Anyone have, like, any thoughts at all on the matter?

wooden stirrup
#

Got a demo up of your customizations we can git clone and run?

ripe elk
#

hi! I was a bit confused PyQt listwidgets. Is it possible to insert something besides a string, like an object with a to string method?

ripe elk
#

another question - if I'm using PyQt, how do I stop widgets from moving? I want to stop some wierd widget shifting whenever I update an image and i can't

ripe elk
#

a custom object

eager viper
#

Is it possible to derive the name of a PyInstaller bundled application at runtime?

#

*On Windows/Linux. You can derive the name of the application by looking at the name of the .app bundle, on OSX

pastel blaze
#

I'm trying to insert an image to a treeview but no luck. Here's my code

from tkinter import *
from tkinter import ttk
from PIL import Image, ImageTk

root = Tk()
root.title("App")
style = ttk.Style()
tree = ttk.Treeview( root , column=("c1","c2","c3") , show='headings'  , height = 10 , )
tree.pack(  side = LEFT, fill = BOTH )
scrollbar_tree_select_movie = Scrollbar( root )
scrollbar_tree_select_movie.pack(side = RIGHT, fill = BOTH )
tree.config(yscrollcommand = scrollbar_tree_select_movie.set)
scrollbar_tree_select_movie.config(command = tree.yview)
tree.heading("#1", text="Icon" )
tree.heading("#2", text="Name" )
tree.heading("#3", text="Year" )
img = ImageTk.PhotoImage( Image.open("the-matrix-movie-poster-xs.jpg")  )
tree.insert('' , 2, image = img , values=('The Matrix','1999') )
root.mainloop()
eager viper
#

So I'm working on a graphics framework/library for Python

#

Recent changes have forced me to reconsider the whole architecture, and so I'm playing around with how I want the API to look/feel

#

Here's two possible options.

#

I've done my best to comment them but feel free to ask any questions. Was just hoping for some input

tawdry mulch
pastel blaze
#

I tried looking it up and saw countless threads on stack overflow but none worked for my case

#

I was thinking to put it outside the tree but it looks bad and unaligned. I can align it with the text but there'd be cases where there's more rows

#

I got it to look like I want but I don't understand the code at all

#

Looks like they used OOP and I have no experience in it. Can I convert it back without using classes?

import tkinter as tk
import tkinter.ttk as ttk

class App(ttk.Frame):

    def __init__(self, parent=None, *args, **kwargs):
        ttk.Frame.__init__(self, parent)
        self.parent = parent

        # Create Treeview 
        self.tree = ttk.Treeview(self, column=('A','B'), selectmode='none', height=7)
        self.tree.grid(row=0, column=0, sticky='nsew')

        # Setup column heading
        self.tree.heading('#0', text='Icon', anchor='center')
        self.tree.heading('#1', text='Name', anchor='center')
        self.tree.heading('#2', text='Year', anchor='center')
        # #0, #01, #02 denotes the 0, 1st, 2nd columns

        # Setup column
        self.tree.column('A', anchor='center', width=100)
        self.tree.column('B', anchor='center', width=100)
        self.tree.column('#0', anchor='center', width=100)
        # Insert image to #0 
        self._img = tk.PhotoImage(file="the-matrix-movie-poster-xs.png") #change to your file path
        self.tree.insert('', 'end', image=self._img,
                         value=("The Matrix", "1999"))


if __name__ == '__main__':
    root = tk.Tk()
    root.geometry('450x180+300+300')

    app = App(root)
    app.grid(row=0, column=0, sticky='nsew')

    root.rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)

    root.mainloop()
#

looks like the fix was to remove the option of showing headings

tawdry mulch
idle nest
#

Hii everyone, need help in finalizing UI... Can you please vote. If any suggestions please could you let me know I will surely fix it

warped crow
# idle nest

feel like the confirm button should be a bit more green?

#

the black gives it a blocky look

idle nest
#

Hmm, let me fix it and share the screen shot

#

How about this approch? I changed the background from gray to White and changed buttons to White + Black

pastel blaze
native scarab
#

Hi, i'm currently trying to code a game in python, but I have a little problem with my graphic interface : I'm trying to create a sprite using a Canvas and to apply an Image on it, but the Canvas background stay white. And because I have a background on my GUI, it's a problem. Does anybody know how to make a Canvas transparent?

#

Thank you!

native scarab
#

yes

tawdry mulch
#

What does transparent mean? What do you want to see through it

native scarab
#

my GUI background

tawdry mulch
native scarab
#

this is just an example, but it should aloud you to understand...

atomic knoll
#

or 10

native scarab
#

cause opacity=0 arg return me an error...

atomic knoll
#

gonna have to check the manual on that im not sure

#

it might also be asking for a % value

winged fossil
#

in wxpython getupdate button downloads a 100mb file. but the ui freeze till the download is complete.

   def getupdate(self,e):
       self.update_btn.Disable()
       self.update_btn.SetLabel("Updating")
       threading.Thread(target=run_update).start()
       wx.Exit()
#

its very annoying

icy flower
fair turret
#
prawcore.exceptions.ResponseException: received 401 HTTP response


fair turret
uncut pawn
#

I am trying to use a text widget and store each an every word there and try and find it in every .txt file I have if the word was in file Green.txt the words need to change color

uncut pawn
#

no sorry

#

my question is how can I do that

#

lol

pastel blaze
#

any idea how I can align the picture in the center? U can see it too far to the right

tawdry mulch
tawdry mulch
pastel blaze
#

That's true I increased the width and it aligned well but It doesn't fit tight like I want it to. Do you reckon if I remove the width option that it'd fit? I guess only one way to find out

#

here's how it looks when I remove the width option

tawdry mulch
winged fossil
#

guys my wxpython program ui freezes when downloading 100mb file.

ionic moat
#

You're probably hanging the event loop when downloading the file