#user-interfaces
1 messages · Page 79 of 1
Yea well you asked for it
I’m just wondering about that one specific part
Not sure y
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.
is that your code?
Yes.
Hey @tawdry mulch!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
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...
Cool, I appreciate it. I told myself that I won't look at other solutions until I manage to finish, no matter how "dirty" the code is. However I'm soon finished, and will take a look then. Thanks!
I am not sure if that is the best attitude, but I do it too, I believe it can atleast make sure we put in a genuine effort from our side
It's the attitude that gives the most satisfaction when finished, at least in my experience. But I do agree, it's not an efficient way at all. This project was more to see if I were able to find solutions on my own, in terms of problem solving.
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.
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
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
which module, what is ur IDE(if any)
what root?
i mean
root.after(10,linenumber)
it only do the loop one time
Put it inside the function
ok
Outside just do lineumber()
thank you
it worked
@tawdry mulch
How to detect which line the player cursor in Text
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
right,i just found it but i didn't think that it we're the right answer
i am not beginner but ty
Hmmmm these types of questions are beginner based
an kind of medium
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
idk man I'm jus 1 year into python and I still would say myself in the beginner transition
okay
but this is what you think but not what i think
i cant say am pro
but am good
I can't be the judge of that, so...🤷♂️ Hope you are good 😄
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()
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.
in python tkinter , how do i trigger other gui app using 1st one?
Usually using a button that is linked to a callback
thanks for the suggestion i ll try
Damn, that's really well made
Thanks
can you share github link of this project ?
I would know some good stuff for video playing, in tkinter
what do you mean by the line number the cursor hovering on?
I don't have github lol
@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!
when some one typing code in IDE i want to know what the line i am on
Do you know some advantages for kivy? why should I use it?
What is the best gui module for Python?
You are typing right? Not hovering, but I believe you can still get the line number
Pyqt5 pyqt6
The easy way to create desktop applications. Take your first steps building GUIs with Python.
For rapid prototype this is sweet
https://gitlab.com/mikeramsey/copier-poetry-fbs
gif prolly
Thank you for your response. I changed QtGui to QtWidgets and now I am getting a “QWidget: Must construct a QApplication before a QWidget”. I am assuming this is because I am not constructing the widget inside the main function. Is it possible for the MainWindow class to call on the Graph class and add the plot widget as the central window?
Which format of image
this one python cv2image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) img = Image.fromarray(cv2image) imgtk = ImageTk.PhotoImage(image=img)
It is an image, how do you expect to animate it
I hove a while loop
It is a single image right? How will it look like a video
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()```
hmmhmm? So where do you want to show this image? Which widget
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
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
As I said avoid time.sleep()
I puted that cause it works really fast, we can't see the video
like I have too much FPS
which one ?
This
No without that, the old codes that does the update, with loops and config() all
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
Okay, try changing while ..... to if then add root.after(100,func_name) inside this if at the bottom, then remove time.sleep(0.1)
Happy as long as it works 😄
but wait lol
let me show you the result
why the image is not completely displaying
You mean not taking entire space?
yes, and my video is more large then this
Dont know, might be something internal
For the space, I have to see your Label creation
maybe anchor='nw'?
x,y coordinates, starting depends on how your anchor is set
Great
I’m having some Qt problems, is anyone available to help?
Learn how to create professional user-interfaces for your Python apps.
Lots of public stuff here
All free and on YouTube
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
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
is there a way to add list of songs in tkinter?
yes? but what do you mean
Not with tkinter, you should use pygame or something else @ember dragon
You can check out https://github.com/nihaalnz/MPlayer/blob/main/mplayer.py to see how I implemented
Or see this answer https://stackoverflow.com/a/68359266/13382000
ok, thanks i will check it
but should i switch or continue using tkinter for the gui?
nono you can use tkinter for GUI and pygame for the music mixer
alright
there are more modules for this, but nothing that gives you flexibility like pygame and also it is threaded
Is QT free?
Oh wow, that’s cool
Is there official pyqtgraph animation for real time plotting, or do you have to implement threading?
someone know how can i add a font into an exe who was convert with pyinstaller ?
in my opinion, it would be easier to change the font in your program before convert it
i don't understand
i think that you should modify the font with python code line and convert it to exe after
mmm yes but i'm not going to have the font which i want in that way
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()```
I imagine I use tkinter's grid() function for the former, but I'm kinda shaky on how it works per se.
Nevermind, I got it to work with grid() and Frame()
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
https://doc.qt.io/qtforpython-6/PySide6/QtGui/QMouseEvent.html#PySide6.QtGui.PySide6.QtGui.QMouseEvent.globalPos @quick relic
@quick relic to summerize use gloalPosition()
hey, which UI library should i use if i want to show a camera feed(img/frame placeholder) and 2 logs
Qt
Please suggest me any imporvement and give a review
thank you
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
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
i did it already!
You mean the listbox should disappear?
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()
why tkinter Entry returns me AttributeError: 'NoneType' object has no attribute 'input'
Thank sir
First of all entry does not have input method I think, then your Entry() is not because you do Entry().pack() or grid or whatever
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
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) ```
I changed that by "set"
Yeah that's what I found on internet
so ya
so.. is there any solution ?
I said right?
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()
Yes you're right
That's what I tried
It's not working
As I said here....#user-interfaces message
But, look I still it from here xD
You did not copy it correctly
def fps_manager(self, text):
self.fps.set(text)
you are right
exactly bro
thank you
nice
a last thing
for self.fps = StringVar()
could we affect a default value ?
"affect"?
yes like self.fps = somethng
allocate or assign
Prolly you need self.fps = StringVar(value='whatever string')
Cool
is discord made by Next.js ?
thankss
What are the supported opperations on IntVar ?
operation?
you will have to use get()
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?
Is this code true
def fps_upper(self):
self.fps = self.fps.get() + 1
self.fps.set(self.fps)```
🤔
No it's not correct
self.fps = self.fps.get() + 1```
will overwrite the instance of `IntVar` with the result
use
```py
def fps_upper(self):
self.fps.set(self.fps.get() + 1)```
Yeehhh
use bind
yea, but i could only use it once, i am not sure how to use another one of it
another?
What is wrong?
the second one overwrite the first one i think
the first does not occure
but if i removed second, it works
First of all, there is prolly a syntax error
2nd of all bind to the listbox
listbox.bind('<Double-Button-1>',func1)
Cool 😄
thankss again
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.
Here is a little something made with tkinter
what do u think is better pyqt or kivy?
Qt
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
Yes, actually if you think too much, pressing a button --> Calls a function, so instead of pressing a button, just call the function when the digits are entered
I’m still extremely new to coding so bear with me. I understand the point you are trying to get across, but I don’t know how, yet , to call a function just by the computer seeing there is 7 digits and to run a definition. So how I type to call this function? And thank you for your input!
Functions are called by using () after their name, anyway, if your extremely new, the best way to learn is to show the code you are using, rather than complicate it with words
that's cool
hey could you please dm me an invite?
Sure thing
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
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 ?
Usually you would bind to the self.window, because that expands right
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
if you looped through and made those entries and bla bla, it looks fine
yeah the problem was to get the entry after the loop
solved right?
Im gonna try later, but it look like
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
this is what PyKing proposes
i used bind on a listbox, when i click the list appears, but when i click again the items in list appears twice
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?
How come, show the code
You can ask here
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
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
the for loop repeats and print the list again
In my 1 month experience with this, I have never seen anyone do the signaling in the designer, I do not think there is an option for it, afterall, it is just a designer, it is not aware of the function we can use/make. Code extraction just creates a code of your project, basically like ui --> py file
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
which part creates the issue?
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
ok then add lb_beet.delete(0,'end') before the loop starts?
cool thanks
Cool, usually you need the for inside the if, I do not know what you need here, but usually it is like that
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
Hmmm I see
I don't use pyqt but a search brought this up https://doc.qt.io/qt-5/designer-connection-mode.html
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
!code
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.
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')
Show the code please, usually sticky='news' or something
I managed to do it using pack
Cool, but always better to use grid().
Is it tho?
I find it way more complicated.
Using pack() and some Frames feels more straight forward
If you are ready to use grid() inside of the frame, then it is nice
The best way to manage is to combine pack() nad grid() like that
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
my pygame overlay library, the text is a bit screwy and idk why
it seems to be drawing it multiple times
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
do you mind if i just dm you the python module?
Sure but im too tired for this so id probs be as useful as a dinosaur playing basketball
alright 1 sec
Tried added prints to confirm its being called just twice? And have you traced though what could be calling the function this is in
Can u help with that? I mean, I'm working on a school project and I've done everything using the grid() method, but I don't like how it looks and I want to switch to pack() but am not quite sure how to do it.
Ig he made the overlay, not the game....
Show the code, please. If you are asking about making it flexible, it can be done using weight
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```
Is this related to UI?
I don't really know, I'm actually coding a GUI with tkinter and .. voila
Where do I post it ?
is this error due to tkinter?
I don't think
Then you can ask for help in help channels
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
First thing I see, global on the main block, it does no good, you can remove it
Ohh okay, thanks for your suggestions. I have a look
Then if opened_file_address != "": is same as if opened_file_address:
Great! Thanks a lot man.
root.quit() does not really close the app. It just exits the mainloop() working behind, if you want to exit the mainloop and close the app, use root.destroy()
Other than that and some missing features like the 'Show sidebar' button, the rest seems fine and well built 😄
wow
Whats so wow 🤔😂
tbh idk I just said wow to remove the ping
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.
Wow, I want to learn how to make cool games like this.
anyone here use ursina?
I do not think the user made the game, it was csgo, but the overlay is the text on top of it
Hi @hallow kettle pyqtgraph maintainer here, while there is some multiprocessing support baked into the library, it's not actually used often. Generally the library expects you to call your plotitem's setData method with the data you want to update; you shouldn't need threading on its own (unless you're doing a lot of processing on the data coming in, in which case that's another story)
l9l
lol*
it's just an overlay
Hey, the Show Sidebar does work.
If you right-click anywhere on the Sidebar, you will get an option to collapse it, and to get it back again, you can go to View > Show Sidebar
Mm, whatever it looks good
Somebody help me.. pls...
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....
i hope someone doesnt introduce you to c#
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.
What's wrong with it?
im downbad for some front end tkinter programmers rn
Is there anyone here who is expert in QThread and its signals and slots ?
not an expert but I use QThreads in my project (and pass data in/out via signals/slots)
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
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.)
https://stackoverflow.com/questions/44195766/getting-wrong-row-index-after-clicking-on-button-in-qtablewidget-cell-in-python
Anyone know the solution to this question? I have the same problem
@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)
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
so self.sender().pos() is likely not giving you global coordinates ...EDIT: well maybe
in this case, what type is self.sender()?
<class ‘PySise6.QWidgets.QComboBox’> in both the working cases and the one faulty one
don't you need the coordinates of the mouse position (or mouse event more specifically) not the combo box itself?
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
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.
wouldnt a qpushbutton sender pos and mouse event position on the button essentially give me the same thing?
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
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
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 ....
no worries, ill either see if i can somehow get the function set on combobox.currentIndexChanged to not call when manually changing the index (combobox.setCurrentIndex(idx)) or just do this method im replying too
thanks for explaining how a lot of the positioning works, will def be helpful in the future
FWIW it's not like I had this memorized, I had to look at one of my own Qt applications to see how I did it (searched for "indexAt").
pyqtgraph's TargetItem has a ton of conversions between coordinate systems, you may or may not find useful: https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/graphicsItems/TargetItem.py
ill def take a look, thanks for your time again!
can someone help me over #help-kiwi ? I'm having an issue with pygame where the main menu is skipped when the code runs
Is there a way to reduce loading times when using .pack() and .pack_forget() ?
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)
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()```
Nvm fixed it
Shouldn't need to convert ui to py
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
src/main/python/qvpnstatus/main.py line 72
mainwindow_ui = appctxt.get_resource("ui/mainwindow.ui")```
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
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")```
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
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
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
so will it work if I have to work with dynamic widgets and toggles?
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
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
not a problem, I'll figure it out
My pleasure hope that saves you alot of hassle nothing like being able to mod ui file in qt designer and restart gui in pycharm to test without that extra steps ;)
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)
Pyside can do it too just slightly different syntaxes let me find you the example
@Luca the tutorial doesn’t have PySide2 code, so it doesn’t really help. @Adri1G the main problem is you’re using Qt.py but not setting which Python Qt API to use and so it is defaulting to PyQt5. See the Requirements section here for possible values. To set that in your code, you can just import os and then set the value on os.environ. The f...
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
Is using .close() for closing a window good practice or there are better methods or it's the only method?
.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
For pyqt5 do you guys recommend using the designer or hard coding?
I hard-code out of habit, easier to migrate your code to different bindings if you need to
I don't think one way or the other is "better", it's a matter of what you're comfortable with
Alright thanks, ill try both
I guess I would phrase it as the better way is the way you actually use 😄
what is the best way to change the icon image using its checked property
without using custom pushbuttons
Hi, is there anyone here good with tkinter? I need help with a little something
I prefer hard-coding
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
Qt designer for everything that can be done
Lambda for signal checked state which toggles qicon
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
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
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 ;)
We tried using functools.partial with no success either 😦
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
I wish I could remember which bindings it was; can probably track it down if I dig through the issue tracker/closed pull requests
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
great
beginners to grasp the basic concept of ui and experiment around with it
prolly ego 😛
Anyone know of any good pyqt tutorials/docs
References:
https://forum.learnpyqt.com/t/using-fbs-for-packaging-while-creating-the-gui-with-qt-designer/183/3
https://build-system.fman.io/qt-designer-download
https://www.learnpyqt.com/tutorials/qt-designer-gui-layout/
https://www.learnpyqt.com/tutorials/first-steps-qt-creator/
https://www.learnpyqt.com/tutorials/embed-pyqtgraph-custom-widgets-qt-app/
https://www.learnpyqt.com/tutorials/packaging-pyqt5-apps-fbs/
https://learndataanalysis.org/category/python-tutorial/python-pyqt5/
https://www.youtube.com/playlist?list=PL3JVwFmb_BnRpvOeIh_To4YSiebiggyXS
Overall:
https://www.learnpyqt.com/tutorials/
https://github.com/pyqt/examples
@David_Boutelier @martin I was able to get this working now and here is minimal example of how i did it. Hopefully this is helpful for other people this should be the default way to develop so fast now to prototype and test new widgets along with actual functionality. The code stub. I tried to take as much out as possible but leave enough in ...
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.
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.
not going to personally vouch for the content, but we (pyqtgraph) get a lot of web traffic from here: https://www.pythonguis.com/
@vale ivy Did you mean root = Tk()?
thank you! looking at the same thing for to long made me blind
is it possible to use css with tkinter?
or any similar design ways
its so difficult to make tkinter look nice
Just use another library ^^ like Dear PyGUI or QT or Kivi
Yeah qt had css style sheets which is real nice not given kivy a try in awhile but that is good to know
Does anyone here know how to create multiple labels with a loop?
Yes sure
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#
The images are probably being garbage collected, do you keep a reference to them?
No, I just assume they will stay there because Im making a new label with a different image
Add
Label_name.img2 = img2
Anyway you will need self.img2 = ImageTk.PhotoImage(....)
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?
if it is as simple as you say, tk alone will be fine
Did you try what was said here?
Did you say self.img2 = ... ?
Awesome, I was hoping as much. The tk docs are great and it's only local, I care not about anything pretty at the moment. Thanks boss, it's always good to get a bit of feedback.
See first of all, stop posting images of code, just paste the code itself, so we can copy it and modify and paste back
sorry, its because it's messy😅
will do
Not the entire code, just the code in the images you posted
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
Please follow:
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.
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')
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')
def __init__(self, page):
self.page = page
just note label and lable when calling that function btw
@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
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.
yea shouldn't name variables confusing like that...
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
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
Good job mum and dad
Dpg is quite easy and you can ask more questions on the DPG Discord server ( you can find it on the Github page )
Yeah, I joined the DPG discord a few hours ago to have a quick look. You're a mod there: Hi!
It looks like DPG is fairly overkill for anything I need at the moment but if this suite of DnD tools gets really big then it could be used for 3d printing which needs the 3d rendering of models... and it would be good to learn something a bit more complex than tk.
You are always welcome on the other side 🙂
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
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.
Modern ? I honstly disagree
Which part? Modern GUI with tkinter?
Yes
It is not easy, but it is possible
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)).
@oak saffron Anyway here is something that I came across a few months ago https://paste.pythondiscord.com/bocacewana.rb That is quite like a replica of a GUI made in QT Design Studio using qt quick and qml
Will check it out
did u try something with QSizePolicy?
setSizePolicy(QtWidgets.QSizePolicy.Expanding)
lol what

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?
nvm 2nd constructor needs horizontal and vertical, idk the 1st
Are you a beginner? Then use tkinter to study the basics concepts of a UI first, move onto PyQt to make such modern UI
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)
@slender iron asd
Okey doesn't look that bad ^^ still no fan of tkinter 🙂 but i think thats matter of taste
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
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
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
Great, thank you!
uhhh
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?
Sup, I'de like to do some gui devolopement with python. Is there and projects i can try?
calculator is a great start, then image viewer, then show data from other website using API(weather apps), then a management system like library management and so on...
Aght thanks :)
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
How (using tkinter) can i limit the amount of characters in my entry box?
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.
Thanks
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.
consequences
Well for this to work, you would have to call the function, each time something is typed right?
The program still works, but it opens slowly.
Yea I know, I have been suffering too, prolly it takes time to load the theme
how can i make it fastly
The tk and ttk themes are a little ugly.
Dunno
It takes time to load the theme, what can you do about it? I don't think there is anything you can do to speed up the process, but what you can do is, create a splash screen
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
wrong? It is how it is
@tawdry mulch I use " from ttkthemes import * "in my code.There are many themes in this moudle.Maybe I should import only one theme ?
Try it, I do not think anything is going to change
splash screens are awesome when i finally found out how to do mine i ended up solving the slow startup so now i barely get to enjoy it lol
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_())
Never knew there was a QSplashScreen, great
If you try out my app can see it in a real application context
https://wizardassistant.com/install/
but yeah i didn't know about it as first either but its super cool
I wouldn't use timers with real applications(but I just did :P), I would start the splash screen on a separate thread, and then check if the main window has ever been open, if it has, then close the splash screen. Just a concept, never tried in a real time application
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
Perfect !
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 :>
Going to have to try this
its crazy that there is and ascii character for this: █
I think Thonny uses tkinter, check it out: https://thonny.org/
Doesn't look bad to me
sorry
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.
it depends is the short answer
It looks ok, but i have instant a windows 2k vibe. Probably is it my mind ^^ and don’t get me wrong i mad a few projects in Tkinter ^^ but i see always that 2k vibe in it ^^ somewhere somehow… 😂
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
Okay...
absolutely true ! but i think that is something i like about DPG. it runs on the GPU. so it is almost everytime smooth as f 😄
While the most official docs(PDFs) are a great help, most YouTube videos on tkinter sucks...
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
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
Maybe its not supposed to be multi threaded
threading.Thread target takes a function/lambda, and from your code, you are running the function, so you would do:
tt = threading.Thread(target=lambda: self.search(query))
tt.start()
If you dont want to use lambdas I suggest using partialinstead
search_with_query = partial(self.search, query)
Thread(target=search_with_query)
Thread has an args parameter already. so Thread(target=self.search, args=(query,))
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.
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
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.
Lol yea, but bad practices are really harmful on long run, I have seen some YouTube video do it, and dozens of people just blindly follow it, and later on some issue arises because of it and they ask it on stackoverflow and they point to the video. I myself was following great practices that lead to SQL injections...
Yikes. I'm working on something with postgres at the moment and I am not confident. But since my stuff is very local, there's not a lot of risk; I just find my bad practices embarrassing. I should put them out there and learn from feedback though.
Learning through feedback - one of the best ways to learn and correct your own mistakes
Okay I should stop being conclusive with just < 20 years of experience in life 😛
It's a fine line between confidence, arrogance and stubbornness. But any one of those three is going to get something done (as long as there's no dissent).
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?
can you elaborate on what you mean by want to pass the 'player' object?
pass it into what exactly?
into the slot that'll get called when the action is selected?
yes
act.triggered.connect(self.playerClicked)
so in self.playerClicked I know what player is clicked on
a lambda should suffice
ah so each instance gets their own slot
lambda: self.playerClicked(player)
each instance of what?
you can reuse a method as a slot as many times as you want
so how do I use the lambda in the slot?
just pass it as the argument to connect
also addAction can take a slot as a second argument
to save some time
act.triggered.connect(lambda: self.playerClicked(player))
like this, seems to work fine. thx!
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
Yup, you've encountered late binding closures: https://docs.python-guide.org/writing/gotchas/#late-binding-closures
oopsey
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
just typed fast 
got it, thanks
looks neat and simple👌👌, PyQt? Is it responsive?
https://stackoverflow.com/questions/44264852/pyside-pyqt-overlay-widget is there an easier/simplier way to do this? I have a QWidget on top of another QWidget and need the bottom QWidget to have a transparent black background as in the link
Woah, beautiful
What is Consilium?
I need an advice. What's the best program for making GUIs?
it means “advice, plan” and it’s a planner
pyqt is the best to use in my opinion as you’ve got qt creator
They told me that Kivy GUI is really good too.
kivy is probably friendlier than qt, but i haven't actually used qt
Ok, I guess I am going to try Kivy
What do you mean by best
easy? beautiful? perfomance?
tkinter it is
You said best to start with? Then it is tkinter. Beginner friendly
Ok, thank you
PyQt and Kivy both have steeper learning curve
Personally, I switched from PyQt to PySide since it's officially supported by Qt
@nova tangle Check this
I mean basically its the same thing itself...
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
Did
lol I havent got into PyQt, just doing projects, copying code bla bla 😛
perfect!
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
How old are you
21
wow, weird constraints, because python is not a GUI language
I'm 15
im 4 :c
Sus
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
good luck!
Thanks! Also, all of the dudes that work there are actual boomers and are mainly just electrical engineers so I was told to use Python since it's readable
I don't regret using Python since it's an amazingly dynamic language
oh that makes sense now, one for the boomers
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 😭
In the future, when I will be in the coding mood, I'm going to learn other languages like C# and JavaScript.
Building control/automation software for a temperature-vacuum chamber
What's the API
it just depends on whatever you want to do with coding
Wdym, other than Qt?
How do you communicate between the chamber and the UI
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)
You will know when you grow up, but anywya don't learn all the languages, pick a field and learn the languages needed for that field only🤷
It all fits in a control box with relays and such cause there are a ton of peripherals to control
Ah nice, I've seen people use tkinter with raspberry pi too
But hey I have 0 knowledge, not even into a university yet🤦 so not gonna judge the difficulty
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
My university knowledge was essential for understanding theory and design patterns which allowed me to figure out the proper path to choose when I was confronted with a problem, but learning this stuff is definitely a struggle that you really just have to work through on your own
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:
- How to code Python, lol
- 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
Yup, I'll keep this in mind while choosing a path 👍
@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.

theme module?
both are diff
oh thnx
😀
I've only dabbled but JS is an absolute nightmare. If it wasn't so integrated with HTML and CSS (permission-wise, CORS stuff), I would have given up within the first week.
Webpages as user interfaces are a bit ick. They're the WinXP of UIs.
But... all web pages are user interfaces. So you're saying they're all icky?
Just like how you would play an mp3 using python
Got some tautologies going on in here
Lol
You would use pygame for some control over the audio, like play or pause it, else you can use playsound. Rereading your question, you asked for python and I magically read tkinter out of somewhere, hence my tautolically submissive message. Applogies 😄
but what do i go if the program is a terminal game?
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
ive heard about subprocess
I honestly don't know I'm not familiar with the packages you're using
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?
Its a GUI framework so you most certainly can
Wait though
yea?
You should be able to play sounds with pygame, why aren't you able to?
it shows error
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?
<@&831776746206265384> 
a scam, ignore
oh ok
What was a scam?
playsound can play audio quickly
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?
!pypi eel
Wow! I had no idea there's a whole bootstrap style themes for tkinter. Useful. Is there something similar for KivyMD? What's the best way to build a python app for mobile?
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?
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
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!
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
adb? I don't know what is it. Please explain
I tried it in bluestacks4 too. It got installed but can't open it, a black screen appears with a label loading and suddenly disappears
Adb helps u connect windows with android
Excuse me. What os are you using??
Wait is this a chrome book.?
Would need adb logcat to debug the crash
I tried to make an app before...first i tried kivy but it was nightmare.
I switched to android studio..it was hard and slow but there is lot of help out there related to java and android studio and eventually it works. Its still a pain though. Android in general is hard to work with.
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
Can you use PIL or tkinter to stretch image when expanding and maximizing the window>
?
oh sorry
mm, let me try
that's true. Android studio is hard but at least it works. In it first xml will get us mad after java will. For me its too hard
@soft bone I cant get to expand past original size. So I wasnt sure if you could.
I'm not sure I never worked with canvas but since its tkinter Yep it should expand
It may help you
yes a chromebook
acer c733
4 gb ram
32 gb strage
storage*
no it wont
Yes PIL or even what you said should work, given that the window is fullsize
whats the original size
maybe fill='both' too
@jaunty haven from tkinter import tk
anyone know how can i play audio from online source using py??
Download the audio then play it
but it would create latency..i mean click thn w8 for it to download thn play
What is this audio?
youtube video's audio source using ytdl
i mean i can open the streamable link on chrome
I am not sure if you can stream like that....Is this a music player? @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
Does the user have the option to play from any other link?
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
Hmmm not sure, try vlc
i can run with vlc but that wont work on python script so technically cant 😦
I mean python has a vlc binding, install it and try
k I'll try thanks you so much ☺️☺️..and thank you for all the replies
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
graphics project?
just say your issues people will come to help
Here's hoping
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?
Got a demo up of your customizations we can git clone and run?
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?
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
which object?
a custom object
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
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()
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
Have you checked how to insert images into treeview?
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
Then y don't you implement that in your main program?
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
feel like the confirm button should be a bit more green?
the black gives it a blocky look
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
That's what I did lol. I had the error of including that option is all
Great
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!
Transparent like?
yes
What does transparent mean? What do you want to see through it
my GUI background
Show a screenshot please
easiest fix is set opacity to 0
or 10
what is the Tkinter argument name?
cause opacity=0 arg return me an error...
gonna have to check the manual on that im not sure
it might also be asking for a % value
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
prawcore.exceptions.ResponseException: received 401 HTTP response
Why am i getting this Error ? | i am Making a redddit bot | i have entered right Credentials as well
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
Cool
any idea how I can align the picture in the center? U can see it too far to the right
I think, picture does not come in a column, what you have done is hacky way around the fact that you made use of the first column and expanded its width. Now what you can do is expand its width even more
You should have a foundation, I can help you with the errors on the way
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
Looks fine to me...but not the efficient way I guess
guys my wxpython program ui freezes when downloading 100mb file.
You're probably hanging the event loop when downloading the file

