#user-interfaces
1 messages · Page 10 of 1
misread it
was making a minimal example to reproduce :P
nahh i edited it xd its my bad
I get 95.92433628318584 from running it
is there anyone online right now that has lots of knoledge of pyqt6?
you should begin by asking your question
???
One step closer 🥳
How does this work exactly?
need help, can someone help me center
Does this help?
tui.header("Simple Data Presentation")
tui.title("Progress Bar")
tui.progress("Shows a bar: 1/10", 0.1, 1)
tui.progress("Shows a bar: 1/3", 1, 3)
tui.progress("Shows a bar: 1/2", 1, 2)
tui.title("User Interactions")
yesno = tui.yesno("Are you happy?")
if yesno:
tui.status(StatusEnum.Good, "Yes you are")
else:
tui.status(StatusEnum.Bad, "No, you are not happy.")
tui.print()
tui.title("Does also work with base bool / and + INT ")
tui.status(yesno, "Bool result")
tui.status(10 + yesno, "Int result: On/Off = 10+Bool")
tui.print()
tui.title("Call by dict")
for key in dict_status:
# It requires specificly INT or BOOL, since i'm just parsing key's here, they're 'any' (or str) and wont work
# So I had to fallback using EVAL, eventhough that is not recomended.
tui.print(f"tui.status({key}, 'Some text'", f"[ {eval(dict_status[key]).value} ]")
tui.print()
tui.title("Call by Enum")
for se in StatusEnum:
tui.status(se, f"tui.status({se}, 'Message to user')")```
uughhhh....in less than 20 words?
Its a framework that allows to print left, center and right oriented text using a theme for different presentation
interesting
I'm sorry for the stupid question, but why?
(feel free not to answer)
I love console, and think we're missing a proper "TUI" (aka that does not try to mimick a GUI).
Though, I think it's like 20-25 years "too late" 😅
goal is to simplify console output,and make it more... appealing.. to endusers, while keeping it simple to use for coders
yeah, that's cool
thank you 🙂
Pseudocode:
# I'm using ``// 2 * 2`` to make it an even int number.
width_work = dialog.width // 2 * 2 / 2
width_box = input_box.width // 2 * 2 / 2
# Asuming anchor for input_box is lower left:
input_box.pos = width_work - width_box```
// 2 * 2 / 2 looks slightly weird to me anyway, since it's just //2 but as a float
global add_to_cart_popup
add_to_cart_popup = flet.BottomSheet(
content = flet.Column([
quantity_dropdown := flet.Dropdown(
hint_text= "Enter the quantity",
options = []
),
flet.Row(flet.TextButton("Confirm"), flet.TextButton("Cancel", on_click= dismiss_popup))
]),
open = True
)
quantity_dropdown.options.extend(range(1, int(product[1]["stock"]) + 1))
page.overlay.append(add_to_cart_popup)
```my bottom sheet isnt really showing
this is all the code i have relating to that
what could be the cause?
(general advice on avoiding global variables)
;-; yea i pretty much didnt know about the fact that i can use oop until i was deep into the project, so it's pretty much just nested functions, and i cant pass arguements cuz flet sucks so i pretty much have to communicate any and all data through globals
You can use lambdas as callbacks
These lambdas can accept any number of arguments and / or even ignore originally passed "event" argument
Like
ft.Button(..., on_click = lambda e: myclickhandler(e, f, g))
👀 that's smart no one told me about this
btw if u know what's the e thing that's always passed on button clicks?
Idk if its really like that, but if it is the "e" contains the click event information - stuff like at which coords mouse click happened etc.
I have no idea so you should look the on_click in docs
i seeee i thought it just passed the whole page or some thing so i could avoid nested functions but looks like am out of look lol
The correct way to use references to parents in flet is to assign them to variables first and then append their children
Instead of
ft.Column(ft.Row(ft.Button(...)))
use
col = ft.Column(...)
row = ft.Row(...)
btn = ft.Button(...)
row.append(btn)
col.apppend(row)
i usually just have the children in it while assigning it to the variable 💀 my current code is full of bad practices lemme get this one working, and then i will work on optimisation while following good practices
only whenever required
yea nesting would have worked awesome if flet provided an alternate way to reference controls, like for example by name, so then this name can be used anywhere inside children to reference any parent
that's where walrus operator shines ✨ ||if i understood what you meant correctly||
Yes but such code looks trashy
💀 idk but walrus operator looks cool to me
walrus operator for all good it does reduces readability which can be a big issue when combined with the way black formats parantheses and like 10 level deep nesting
that's true, btw do you know about any good formatter in vs code... autopep8 isnt really helping with all these bad practices and unneccessary nesting
The correct (and often most efficient) way with frameworks like flet is to make small reusable components, you should try doing that whenever you see duplication and certain repeating patterns
At this point its black or nothing, unfortunately. I do have certain conflicts with the decisions it takes, but I can easily turn it off for a few lines of code or a block
yea i took care of that but it's all nested function so i probably will have to work on it
If your components are reusable then for every component, the function that creates and returns it should be in the module scope
naw but i didnt think of the lambda approach so i couldnt pass page outside the function as easily and it would all just end up being a headache
does the formatter affect syntax highlighting?
guess i will have to switch back to something else cuz it aint colouring the module name and class name and stuff
Syntax highlighting is an IDE concern, black has no way or need to get it
seems something else
then it must be my stupid lap not loading the stuff 💀
i have pylance idk it happens quiet a lot to me though whenever i open vscode it takes like 10 mins to complete syntax highlighting
yea use preview
should fix that
And make sure it isn't accidentally scanning your entire venv by any chance
lemme try tho i thought it was cause my ram usage remains so high
btw have you enabled any of the linters from python extension?
um what are those
Like flake8 or mypy?
pycodestyle, pydocstyle and the worst registered offender pylint?
Check if you have, disable those, they slow everything down
nope pylance, python, autopep8 and black are the only extensions i downloaded
These stuffs are enabled from inside the python extension
i dont think i have any
i've accidentally created a shield.
Hi, did anyone of you installed python and electron on windows? Which environment do you suggest? visual studio? Is it true, it’s a bit a nightmare to compile an electron project on win?
(Or, is there a tool you suggest for cross platform gui?)
Electron uses javascript its not a nightmare to use
You can easily make desktop apps with it
And easily build for win, Mac, linux
Personally I will suggest Tauri it uses rust as a backend and js on the front-end
Electron is well a mem hog and takes a lot of mem so I will suggest Tauri it uses wayy less mem than Electron
ah yea it took quiet long but i figured it out, it was quiet easy with the help of oop i was just being dumb back then
thank u so much for the help otherwise there was no chance i could think of this
sorry for the random ping
Hi all. Can you please tell me how to fix the background of the button so that it is green? When you run the code, the background of the button is gray and only the borders are green.
from tkinter import *
from tkinter import ttk
root = Tk()
b_tk = Button(text="Hello Tk")
b_ttk = ttk.Button(text="Hello Ttk")
b_tk.config(background="#b00",
foreground="#fff")
style = ttk.Style()
style.configure("TButton",
background="#0b0",
foreground="#fff")
b_tk.pack(padx=10, pady=10)
b_ttk.pack(padx=10, pady=10)
root.mainloop()
@digital rose you don't seem to have made your button use the style you created
His button style is green. And in the end, only the borders are green. If you remove the style, the green borders will disappear. Tell me, please, why is there a gray area inside the button?
@digital rose it's actually working fine on my device
I haven't installed a screenshot functionality yet, but it's displaying green background color, and when I hover over it, the color changes into grey
😕 Eh. Thank you
guys, im doing a CLI suggestion kinda tool, for click CLI apps
i've made some changes to the bottom bar, but idk which one to choose
i just need some suggestions and some UX review on which one to choose
but here are the differences that i see between both of these
-
the first one is just indicating the number of arguments that a parameter can get, so that less number of function calls are happened to update the bottom bar, compared to the latter one
-
this one btw, updates more frequently to indicate the number of arguments that a parameter can accept, and indicate the remaining number of arguments it needs
this is the click code (group, and the subcommand shown in the video)
@click.group(invoke_without_command=True)
@click.pass_context
def cmd_group(ctx):
print('lvl1')
@cmd_group.command()
@click.argument("val", type=click.BOOL, nargs=4)
@click.option("--val1", type=click.BOOL, help="Some boolean optional arg")
@click.pass_context
def bool_type_arg(ctx: 'click_repl.ReplContext', val, val1):
print(ctx, val, type(val), val1)
@cmd_group.command()
@click.pass_context
def repl(ctx): # this is the command that im calling from the command line
click_repl.repl(ctx)
cmd_group()
so, which one should i choose to use?
(just ignore the bandicam watermark pls, also ping me on reply, i don't want to miss ur answers)
can someone give me the most basic example of a FilePicker in flet
The one in docs isn't?
i dont really know how to get the path
A control that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support and upload.
FilePickerResultEvent contains a path attribute, so its just e.path in your callback
i see, like in the example there was only e.name, so i didnt realise, thanks
Hi there,
I am converting a simple Tic Tac Toe program that works in the terminal, to a popup GUI window.
However I am struggling with "print" commands.
I want to print the gameboard on a Popup GUI window (NOT the simple debug window that GUI provides)
This is my code.
for x in range(rows):
print("\n+---+---+---+")
print("|", end= "")
for y in range(collumns):
print("", gameboard[x][y], end= " |")
print("\n+---+---+---+")
sg.theme('DarkTeal9')
layout =[
[sg.Text("Please fill")],
[sg.Text(printGameBoard(), size=(15,11))],
[sg.Submit(), sg.Exit()]
]
window = sg.Window("Tic Tac Toe", layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == "Exit":
break
if event == "Submit":
break
window.close()```
The gameboard prints like this..
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 7 | 8 | 9 |
+---+---+---+
*btw thats just the important bits of code, there is more that i havnt included lol
How do you import your own font to Tkinter (I'm using the sv_ttk theme)?
Is it possible to share open source project here without being banned? Or is it like advertising
Is there some efficient front end framework for python according to you or is always better to use JavaScript for your python front?
how do you define efficient?
I think but I may be wrong that most frontend python frameworks are more for prototyping than for production
PyQt / PySide is solid for production and used by many real world apps
I will have a look at that thanks. Is it generic or for data visualization?
There are tons of very easy to use libs for data visualisation. PyQt is a generic UI framework
i prefer the second, with succinct description for optional like optional: bool or something
there cant be no optional bool
it can only use types from the click module
Looks cool 😎
Struggling to see the difference between 1. and 2. though
the difference is in the bottom bar
did u notice it?
Still can’t see it, and watched both videos 5x
what?
u didnt see the text like bool-type-arg flashing at the last line of the terminal?
are data tables in flet not scrollable
if not how can i make them so
i have tried wrapping it in a column but no luck
@somber hemlock , I'm following up on some of your advice recently on this channel about Qt. What are the advantages and disadvantages to developing with Qt versus BeeWare? The Qt GUI components are available via LGPL3. This means I could release a commercial mobile app using PySide without purchasing a Qt commercial license, correct?
how do you overlay foreground and background images in tkinter again?
Hello everyone. Please tell me how to make it so that if I open the file for the second time, the system gives an error that the window is already open or the first window closes when the second one is opened?
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.geometry("300x300")
root.mainloop()
Idk
pyqt or kivy
Ok. Thanks @rigid light@somber hemlock & @tribal bone
Hello folks, I have been learning tkinter for GUI. I am a super beginner, as such I'm trying to make sure I don't invest a bunch of time learning a GUI that is going away in the next few years. I thought I had read that tkinter was being discontinued but now im not finding that.
is there a better GUI to be learning not just for this script but for long term support as I continue to learn?
pyqt/pyside would be the better alternative if you want something more professional and powerful
Thanks, I'll give that a look. This is tangential to my regular work but I want the foundation to be solid moving forward. Learning something that will be around still is important
This is the first I've heard that tkinter support is going away, but even still, it's a fairly simple UI and really shouldn't be used for anything that needs more complexity
To be clear - I had read that somewhere a while back and can't find it again. I had already spent some time learning the GUI elements but didn't want to commit to something that might be going away. No idea if it's actually going away or not.
Would someone be willing to program a better and nicer user-interface for my discord bot for free? I will DM you more information, please contact me if you are interested.
noob question, but what methods/modules can I use to get user input in a clickable text box?
I'm trying to make a simple real-time editable graph GUI w/ matplotlib, rendering via pygame
thats cooool
Anuone know why i close my modal for 2 time, my screen stay grey?
for some reason the labels won't show the entire thing.
the code for it is split between two files but here is the drawing code.
from settings import *
window.setFixedSize(width, height)
print(width, height)
def show_UI():
margin = 50 # Adjust the margin as needed
y_pos = 0 # Vertical position
monthlyd.move(0, y_pos)
x_pos = monthlyd.width() + margin
annuallyd.move(x_pos, y_pos)
x_pos += annuallyd.width() + margin
savingd.move(x_pos, y_pos)
x_pos += savingd.width() + margin
billsd.move(x_pos, y_pos)
x_pos += billsd.width() + margin
transportd.move(x_pos, y_pos)
x_pos += transportd.width() + margin
foodd.move(x_pos, y_pos)
x_pos += foodd.width() + margin
rentd.move(x_pos, y_pos)
x_pos += rentd.width() + margin
account_info.move(x_pos, y_pos)
show_UI()
window.show()
app.exec_()
here is what it shows
!code
what is the best way to learn kivy?
kivy-material provides a much more better tutorial and visually pleasing docs than the kivy ones imo
Hello!
I am building Menu for my Draught in Python, pygame.
I've built class 'OptionsScreen', which stores all the TextBox, Buttons etc. and draws them.
When it comes to give some functionalities to Buttons, what is the best practice:
- Button have an attribute (of type function), where I can store the function I want to process after clicking on the button. Something like this:
button_do_smth.function_to_process = self.do_smth
button_clicked = button_do_smth
button_clicked.process()
- Class managing the screen and all the elements (i.e. 'OptionsScreen' in my case) should process all events in a way like this:
if button_clicked == button_do_smth:
self.do_smth()
why is flet squeezing up my memory- it is taking 2.2 gigs ffs
Looks awesome!!!
Send code
Small snippet if possible
Or whatever you suspect causes it
Hi, I am writing code in Eel to avoid possible complications of Electron. Maybe is Eel too simple? As I see on Github comments, you can’t communicate between python and jinja (and probably with any other template)
i think this part is the problem
def render_shop(page):
shop = flet.GridView(runs_count=4, expand=True)
products = requests.get(url + "/get-names").json() # returns a 20 element long list of strings
for name in products:
PopulateShopGrid(shop, name)
page.add(shop)
class PopulateShopGrid:
def __init__(self, grid, name):
self.name = name
img_link = (requests.get(url + f"\get-url?query={self.name}").json().values())[0]
price = (requests.get(url + f"\get-price?query={self.name}").json().values())[0]
item = flet.Column(
[
flet.Image(
src=img_link,
width=200,
height=200,
),
flet.Row(
[
flet.Text(name.capitalize(), size=20),
flet.Column(
[
flet.Text("price"),
flet.Text(str(price)),
]
),
],
alignment="CENTER",
),
flet.TextButton("View", on_click=lambda e: self.scrape()),
],
horizontal_alignment="CENTER",
)
grid.controls.append(flet.Card(content= item))
what is self.scrape?
Btw you don't need a class at all here
def scrape(self):
scrape(self.name)
where scrape just clears up the screen and adds the name and an image to an screen, however scrape is likely not the issue, since once i press the button calling scrape, the memory usage decreases back to normal.
ah i do, cuz there is no way to make the button call pass dynamic arguements to another function otherwise
have you looked into nested functions? also what is "dynamic arguments"?
what are these widgets/objects called that allow you to decrease/increase value?
Html ?
If yes, then it's an input with type="number"
ah it's called spin box, someone in #python-discussion told me
i know it's a number input lol, the up and down arrow part is the big deal for me
it's alright
also spin box is garbage name since we don't see the numbers roll up or down lel
could've used an updated name tbh
i dont have any nested functions, cuz i just followed an oop based approach
and by dynamic arguements i mean, that they are different for each one, and keep changing
does anyone know how can i overlay an image over a tkinter progressbar?
I've managed to workaround all the quirks that tkinter has besides this one
Im using pyside6 and im trying to have an image maintain its aspect ratio when the window is resized but the image gets distorted whenever i resize my window. I have tried with smooth transformation and all kinds of sizepolicy stuff and no solution has worked for me. ```python
class ScaledLabel(QLabel):
def init(self):
super().init()
#self.setScaledContents(True)
def resizeEvent(self, event):
pixmap = self.pixmap().scaled(event.size(), Qt.AspectRatioMode.KeepAspectRatio)
self.setPixmap(pixmap)
class MainWindow(QMainWindow):
def init(self):
super().init()
label = ScaledLabel()
label.setPixmap(QPixmap("qtforpython.png"))
self.setCentralWidget(label)
this is what it looks like distorted (the img is the python for qt wiki logo)
Im not entirely sure if this is the right spot for this, but I had a passion project moment and built a Terminal UI library that im pretty proud of.
It supports buttons, clicks, hover effects, textboxes, and more (all in a modern terminal) and is very customizable to the developers liking. It is in no way a replacement for tkinter or pyautogui but I'm sure someone will think it is as cool as I think it is.
Github: https://github.com/iiVeil/TermUI
Get it here: https://test.pypi.org/project/TermUI/1.2.0/
Documentation: https://pytermui.readthedocs.io/en/latest/
Library Reference: https://github.com/iiVeil/D-Word-Password-Manager
Im really looking for feedback, feature suggestions, and bugs if you guys end up trying it out!
Hi guys.
I'm trying to run a ui file through a python file, but it doesn't work (the ui file doesn't launch from this py file)
from PyQt5 import QtCore, QtGui, QtWidgets, uic
class Application(object):
def __init__(self,app):
self.app = app
self.ui = uic.loadUi('untitled.ui')
self.ui.show()
self.run()
def run(self):
self.app.exec_()
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)```
the ui file is in the same folder as the py file btw
I believe you need to inherit from QMainWindow for your class
ah how do i do that?
can you shw example
class Application(QtWidgets.QMainWindow)
Hello! I have created this form inside a GridLayout. I added spacers to center the contents in the window. How can I center the submit button inside the cell in which the submit button is contained in?
i did that but still didn't work
You're not creating an instance
You can set a columnspan when adding a widget to a grid. What layout does the form use?
why do you need to subclass QApplication for just that much?
also top level imports please
ah actually i figured out how to do it by now
I do have another problem atm though
I'm trying to interact with my ui file's widgets via the python file, but it only seems to work for the first time the function "chucked" is called
class UI(QMainWindow):
def __init__(self):
super(UI, self).__init__()
uic.loadUi("untitled.ui", self)
self.coordYb = self.findChild(QSpinBox, 'Ybig')
self.customize = self.findChild(QCheckBox, 'customize')
self.customize.clicked.connect(self.chucked)
self.show()
def chucked(self):
if self.customize.isEnabled() == True:
self.coordYb.setEnabled(True)
elif self.customize.isEnabled() == False:
self.coordYb.setEnabled(False)```
when i click the self.customize checkbox, the spin box, becomes enabled, but then when i click the checkbox again, to uncheck, the spin box doesn't become disabled
nvm, i was supposed to write self.customize.isChecked()
not isenabled
now it works
does anyone know an alternative to "clicked" for qcombobox?
map is a combo box widget and i tried this self.map.clicked.connect(self.mapInfo) and got this
fixed it
Does anyone know why window.move in Qt doesn't work? I'm using PySide2 5.15.8 and I'm on Ubuntu Wayland. Is this a known bug in Qt?
Does anyone know a C or Python library that allows you to move the window based on its handle or PID?
i have a problem donwloading tdesigner does anyone know how i can fix this
pygetwindow seems to have that feature: https://pygetwindow.readthedocs.io/en/latest/
Whether it is really possible highly depends on your window manager. Wayland doesn't support moving of window programmatically. DWM (Binbows) supports this.
how do i remove those line aroud the button
hello, maybe someone knows Flet?
yes
i have couple questions:
- how can i delete check box
- how can i make newer text going up, and older going down, like:
98
99
100
@warped shuttle what module are you using
I used to use regular tkinter, but then I decided to try custom tkinter, but there was no list box, so I downloaded the CTkListBox library, and now the code doesn't work because I don't know how it works
pls help me
You can set it to the application's styleSheet
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtCore import Qt
class Window(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.main_widget = QtWidgets.QWidget()
self.main_layout = QtWidgets.QVBoxLayout()
self.main_widget.setLayout(self.main_layout)
self.setCentralWidget(self.main_widget)
self.main_layout.addWidget(QtWidgets.QLabel("Hello World"))
self.main_layout.addWidget(QtWidgets.QPushButton("A button"))
list_wdg = QtWidgets.QListWidget()
list_wdg.addItems(['apples', 'oranges', 'bananas'])
self.main_layout.addWidget(list_wdg)
app = QtWidgets.QApplication([])
with open('style.txt') as f:
app.setStyleSheet(f.read())
win = Window()
win.show()
app.exec()
save that stylesheet to a textfile and read it in. Then you can use setStyleSheet to set the style to the app
anybody know how to center a tkinter window
here's my code:
def newWind(bPressed):
newApp = tk.Tk()
newApp.title(bPressed)
newApp.geometry('1920x1080')
newWindLab = tk.Label(newApp, text=(bPressed), font=('Times', 50)
newWindLab.pack()
newWind('Placeholder 1')
when I run it, the window created is about ten pixels offset on the x-axis
guys can help me, I get an error when I want to display the table. Here is the error: Process finished with exit code -1073740791 (0xC0000409)
https://paste.pythondiscord.com/6GFA
my friend tried to help in some way, but he didn't succeed
I have created a custom widget in my kv file as follows:
<UsernameTextField>:
size_hint_y: None
height: text_field.height
MDTextField:
id: text_field
hint_text: root.hint_text
text: root.text
icon_left: "account"
Afterwards I am accessing this custom made widget in my code as follows:
UsernameTextField:
id: username_create_account
size_hint_x: 0.899
pos_hint: {'center_x': 0.5,'center_y': 0.66}
pos: 100, 100
hint_text: "Enter New Username"
However I am getting this error:
BuilderException: Parser: File "\main.kv", line 36:
...
34: MDTextField:
35: id: text_field
>> 36: hint_text: root.hint_text
37: text: root.text
38: icon_left: "account"
...
AttributeError: 'UsernameTextField' object has no attribute 'hint_text'
Why am I getting this error?
This is the complete error, I click on the table and it comes out like this
oh, hm
Need a placeholder in the kv rule, or added to the python defined class
windows as usual being dumb, interprets that as i32 instead of u32 prob
also, 0xC0000409 is literally described as "It is an error"
:incoming_envelope: :ok_hand: applied timeout to @royal saddle until <t:1690776246:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
int representation is useless, hex representation is more useful to indicate HRESULT error codes
HRESULT is a computer programming data type that represents the completion status of a function.
It is used in the source code of applications targeting Microsoft Windows and earlier IBM/Microsoft OS/2 operating systems, but its design does not limit its use to these environments. It could be used in any system supporting 32-bit integers. In oth...
hey guys, Im making a music player using tkinter
but my listbox shows up white, even when I specified the bg and fg to be black
like this, the bottom section is supposed to be black, but it's white
nvm the icons, Ill change it to white
but the bg has to be black
There is currently a black box on the top part of the app
'from tkinter import *
import pygame
import os
root = Tk()
root.title('DMP')
root.geometry("607x357")
pygame.mixer.init()
songList = Listbox(root, bg="black", fg="black", width=100, height=5)
songList.pack()
pause_btn_img = PhotoImage(file='assets/pause.png')
next_btn_img = PhotoImage(file='assets/next.png')
prev_btn_img = PhotoImage(file='assets/prev.png')
#pause_btn_img = PhotoImage(file='assets\pause.png')
controlFrame = Frame(root)
controlFrame.pack()
pause_btn = Button(controlFrame, image=pause_btn_img, borderwidth=0)
next_btn = Button(controlFrame, image=next_btn_img, borderwidth=0)
prev_btn = Button(controlFrame, image=prev_btn_img, borderwidth=0)
#pause_btn = Button(controlFrame, image=pause_btn_img, borderwidth=0)
pause_btn.grid(row=0, column=1, padx=7, pady=10)
next_btn.grid(row=0, column=0, padx=7, pady=10)
prev_btn.grid(row=0, column=3, padx=7, pady=10)
#pause_btn.grid(row=0, column=0, padx=7, pady=10)
root.mainloop()'
`from tkinter import *
import pygame
import os
root = Tk()
root.title('DMP')
root.geometry("607x357")
pygame.mixer.init()
songList = Listbox(root, bg="black", fg="black", width=100, height=5)
songList.pack()
pause_btn_img = PhotoImage(file='assets/pause.png')
next_btn_img = PhotoImage(file='assets/next.png')
prev_btn_img = PhotoImage(file='assets/prev.png')
#pause_btn_img = PhotoImage(file='assets\pause.png')
controlFrame = Frame(root)
controlFrame.pack()
pause_btn = Button(controlFrame, image=pause_btn_img, borderwidth=0)
next_btn = Button(controlFrame, image=next_btn_img, borderwidth=0)
prev_btn = Button(controlFrame, image=prev_btn_img, borderwidth=0)
#pause_btn = Button(controlFrame, image=pause_btn_img, borderwidth=0)
pause_btn.grid(row=0, column=1, padx=7, pady=10)
next_btn.grid(row=0, column=0, padx=7, pady=10)
prev_btn.grid(row=0, column=3, padx=7, pady=10)
#pause_btn.grid(row=0, column=0, padx=7, pady=10)
root.mainloop()`
but, I want the whole app to be black
including the bottom section, where the icons are present
Add gui.configure(bg='black') after gui.geometry
To change the background color of a ListBox, use songList.configure(background='black', foreground='white')
wait, isnt it fg and bg?
It's background and foreground (That works on my environment)
oh, that didnt change it man
It's still like this
Is the songList listbox element empty?
Try adding some content in it so we can see it's width and height
nope, I this is the songlist songList = Listbox(root, background='black', foreground='white', width=100, height=15)
Try adding songList.insert(1, "Test Value") after that line (songList = Listbox(...))
wait a min, when I gave the height as 15,
That top black box was the listbox, then.
bro
yeah
Wait, are the button images transparent? Do they have white backgrounds?
Your listbox is empty, that's why you aren't seeing anything
Yeah, there is actually a next icon too, but that one is white so you cant see it on the white part
but can I actually bring the listbox down?
Im actually using transparent icons too
Oh, alright
To place the listbox below the buttons, you could declare it (using the ListBox class) after them.
@narrow hedge It seems you are AFK, let me know when you're back!
The order you pack things is the order they show up
That is correct
It's not the order you instantiate the class as you mentioned above
hey, man. @proud dune Sorry for going AFK on you...(I was busy helping mom, XD)
Alr, so I gotta change the order
yeah?
oh yeah, that actually worked
but, what actually want is to make the bg of the controlframe part to be black
and bring all the icons inside that
well you didn't set the bg colour of that frame
controlFrame = Frame(root)
controlFrame = Frame(root, bg='black')
oh yeah, mate, silly me
thanks, that actually did it
I dunno why, but I actually forgot that for a moment
Hey everyone
Just a quick on for you.
I get this error when trying to import my menu_bar.py file:
I have an image below displaying the code I have but If I change the import statement to either of the following it works:
# Relative Import
from . import menu_bar
# Alternate Import
from GUI import menu_bar
when executing main_window.py directly, import menu_bar will work since the module is adjacent to the main file.
tho not sure which module you're running as the main script
Hi there,
I have a main.py sitting at the src level
Well then you can't import menu_bar directly as it isn't visible from main
manu_bar is inside the GUI package
so you must use from GUI import main_bar, when main.py is the main script
Yea this is what I had but Pycharm complains 🙄 Just wanted to make sure I was not miss understanding something 🤔
Thank you for your Assistance 🙂
Hello i have question, How to get value of checkbox from FLET module?
maybe it has issues with namespace packages?
I've never used pycharm, so can't tell.
namespace packages are folders with py files and no __init__.py
Yea My thought exactly.
Even if I add an __init__.py it still gives me an issue 🤣 But it runs... so I will just press on 😁
Anyone a pro in Plotly Dash?
I wanted to know:
1 - is it true that all callbacks get called automatically at the start, when the app is booted? If so, then in what order? Can that be checked/changed somehow?
2 - does that mean that there's no point in setting the value of a parameter/property inside the layout definition, if that parameter/property is the output of a callback, because it'll immediately be replaced by the output of the first automatic callback call?
hey guys, IM back again
guys, for this progressbar, do I have to use any other library?
to make this exact progressbar
and also to achieve that font
This is just a figma ui that I made, Im trying to make an app in python
also Is this achievable? In python?
Yes you could do this in python. You'd likely need to make your own custom widget for it though
oh
Arent there any pre made widgets for this?
Or like any way to use a stylizing language, like css
Yes, but nothing that looks exactly like this. A slider would be your closest option
ah, yes a slider
So, Ill have to program it, prolly
most things require programming, yes
Guess Ill have to figure that out now, `
Here's an example with pyqt
from PyQt5 import QtWidgets, QtCore
slider_style = """
QSlider::groove:horizontal {
background-color: black;
border: 0px solid #424242;
height: 10px;
border-radius: 4px;
}
QSlider::handle:horizontal {
background-color: red;
border: 2px solid red;
width: 16px;
height: 20px;
line-height: 20px;
margin-top: -5px;
margin-bottom: -5px;
border-radius: 10px;
}
"""
app = QtWidgets.QApplication([])
win = QtWidgets.QDialog()
layout = QtWidgets.QHBoxLayout(win)
slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
slider.setStyleSheet(slider_style)
layout.addWidget(slider)
win.show()
app.exec()
Any library where you can draw straight on the canvas would let you imitate that, sliders and progress bars would be the more simpler widgets to write custom instructions for
Hello, I'm using PySimpleGUI to create a simple program to display some datas about a game from a JSON.
In that JSON, I receive multiple filepath to images. I would like to display these images as a gallery (or a table), how to do so ?
Is there any better ide which doesn't take lot of space and can be run smoothly on a laptop..I mean pycharm lags so much in my laptop..any ideas how to code effectively on command prompt
..or anything ide related
This channel is for GUI library discussion. You can ask about IDE in #editors-ides
is the "only" difference between PyQt and PySide the licensing part?
Im a beginner and cant decide which one I wanna use 😄
There's other minor differences in the library, but for 99% of it, they're the same
PySide exposes a (optional) more Pythonic API. Its just lower_case names and properties instead of getter setters atm.
What would be easier for a beginner?
And can I use Qt Designer / Creator for both?
Both are the same. PySide code can be made to look slightly more Pythonic is all. You can use Qt Creator or designer for both
in the end they're both wrapping Qt as closely as possible, though getting support / stuff fixed for pyside seems easier as last time I looked I could only find mailing lists for pyqt
Would this be the right channel to ask for help with a cli tool?
having a head scratcher of a Qt Widget sizing question, I have a tree view, but annoyingly it shows up w/ a horizontal scroll bar, is there a way I can have the width of the widget fit all the contents?
Screenshot:
some things I'm calling...
trreeView.header().setSectionResizeModel(QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
treeView.header().setCascadingSectionResizes(True)
horizontalSizePolicy = QtWidgets.QSizePolicy()
horizontalSizePolicy.setHorizontalPolicy(QtWidgets.QSizePolicy.Policy.Expanding)
treeView.setSizePolicy(horizontalSizePolicy)
treeView.setHeaderHidden(False) # yet I cannot see the header still, what gives?
treeView.setModel(myModel)
treeView.header().setStretchLastSection(False)
treeView.setItemDelegateForColumn(0, MyCustomDelegate())
treeView.expandAll()
treeView.updateGeometries()
for column in range(2):
treeView.resizeColumnToContents(column)
treeView.setAlternatingRowColors(True)
treeView.show()
I think that should be everything relevant...
well, this is embarassing, i commented out a ton of that stuff, and it looks ok now?
could it also be having horizontalsidepolicy.sethorizontalpolicy(etc) vs horizontalsizepolicy?
oh whoops, that's a typo on my end when migrating my code to discord here, my mistake 🙏
no worries! im pretty new to everything but thought it could be that haha
haha pycharm would yell at a lot and my code would blow up when I ran it if that was actually the case
ok found a post from 10 years ago detailing what I would have to do to get the bahvior I want as described here: https://www.qtcentre.org/threads/53948-resize-to-content-of-a-QTreeWidget
If you really want to resize tree view based on its content then you will need to code to calculate the "correct" size and force it. Set all the sections to QHeaderView::ResizeToContents and query them for their size after every data update to get a reasonable starting point. No matter how much sense it makes you eventually hit the point where the content is too wide for the screen and you are back to where you started.
so, after reading that, yeah, I probably don't want to do that, and instead should just disable word wrap and truncate the text...
I have a widget with a QLineEdit and a QTreeWidget in a QVBoxLayout. I would like to size MyWidget to adjust to the longest string in the treeWidget.
Do I need to override sizeHint() or can qt do it somehow? When I type in the QLineEdit, it automatically adjusts the items in QTreeWidget.
MyWidget::MyWidget(QWidget *parent) : QWidget(parent...
what's the problem with scrollbars? they are inevitable
you can make them appear only when content overflows (default behaviour probably)
issue is that I have my tree-view populated before calling .show(), so was hoping to have the initial display of the TreeView conform to size such that no scroll bars would be necessary, but after reading that comment, I think that's just a losing game, best to implement single line/no text wrap with elided text
in my case i'm using a QStyleItemDelegate (not too experienced with those!) so I have some extensive control over the content being displayed in each cell...
now, I need to try and think of a cleaner way to update the cells via dataChanged.emit(QModelIndex, QModelIndex) ...the cells have Progress Bar's embedded, and figuring out how to notify the cell view to update because the progress bar has updated is remarkably not trivial (right now if any progress changes, I update the entire tree view which for my size works fine)
Everything centred around Qt's QAbstractItemModel is a PITA to work with. I realised that its just better to not use a tree if you can (and instead use a grid layout?) However that too is inefficient for a large number of rows
Gtk4 has a much much better designed API to create and populate list / column / tree views.
I think you should be able to handle this with QStyledItemDelegate signal/slots
I’m already using the QStyledItemDelegate, definitely need to use signals/slots, would likely need to make sure that the connection is a unique connection but I know how to do that…
zsh: segmentation fault (core dumped) qtcreator
It was working fine a few days ago, any idea?
Qt Creator 11.0.1 based on Qt 6.5.2
This happens when modifying any widget in the design page
Hmm ok, so this seems to happen only in wayland and not xwayland
Oh if running wayland, you may need to set some environment variable; I’ve had not great luck with wayland when working with PyQtGraph
You could make a custom signal and pass in an object ref through it
File a bug report on the Qt issue tracker
It started crashing only after some system update
not sure if qt creator was updated too, I didn't pay attention
heh unix ppl problems
more like qt's problem
yup
wayland is still somewhat of an experimental WM itself
it doesn't allow window positioning
An overview of the Wayland protocol and how it fits into Qt.
try running QtCreator with -platform wayland ?
Idk, I only get issues with qt on wayland
gtk has been perfectly fine
even dialogs are opened centered
crashes just like before, that's probably the default option on wayland system
Gtk4 underwent a lot of rewrite and change to support Wayland. Now it doesn't support X
Gtk3 idk, won't be so good on Wayland
@blazing pine for now, I'll just run it with QT_QPA_PLATFORM="xcb"
Will make a report tomorrow
This is case sensitive for me
QFileDialog.getOpenFileName(self, filter="JPEG (*.jpeg)")
How can I make it not so?
You mean you want .JPEG also?
ye, windows treat file association by extension insensitively
that's why i want similar behavior
You can use this filter
"JPEG (*.jpeg, *.JPEG, *.jpg, *.JPG)"
will it work for *.JpEg?
No
Even the Windows OS API (which is what Qt uses internally) doesn't allow for case insensitive filters
If you got files named like that, there's high chance somebody is trying to mess with you
Crash your application when you detect such file names 
Don't even bother calling some nice clean exit function like sys.exit. just do os.abort or something
is there an easy way to implement a QFileDialog into PySide6? I cant find anything in Qt Creator
Looks like the docs has you covered.
fileName, selectedFilter = QtWidgets.QFileDialog.getOpenFileName(self,
"Open Image", filter="Image Files (*.png *.jpg *.bmp)")
(excerpt from the docs; modified for clarity)
It's the sort of stuff you have to do in code though.
hmm okay, was hoping there is an way easier way 😄
Yeah, the way it's usually done with Qt Creator/Designer is that you make the UI, export it as a .ui file, then run pyuic on it and import the generated Python code into your app (you could also use PySide6.uic to import the .ui file directly). That way, you can add handlers for the widgets or additional code as needed.
I'd recommend you get comfortable with at least the basics of the code. Qt can be complicated but it's probably the most powerful GUI for Python out there.
Yea I think I’m gonna skip the QFileDialog for now and get my app running, after that I can still change some things
can someone recommend me some easy and scalable modules to make user-interfaces?
like able to use dbs and stuff with it
commonly used ones are PyQt5, Tkinter (if you use this one, also learn customtkinter and/or ttk), and PySimpleGUI. i would recommend using customtkinter for a modern style, but choose what works best for you
hey, im trying to make a tkinter window close itself after it completes its purpose but unfortunately everywhere i put the .destroy function the window doesnt close. anyone willing to review my code and help me a bit?
Feel free to open a help thread for this and share the code there
i am trying to make the small tkinter window in option 4 to automatically close itself after i submit a text file so it will loop back to the menu loop. unfortunately, wherever i put window4.destroy it wont work.
You can do this with QML
Declare the FileDialog in your qml and use it there itself
Your main Tk instance shoud always be global. Otherwise you're just creating multiple instances of your tkinter application and the windows can't talk to each other
someone tell me what app this youtuber is using for python? i am trying to an IDE that is very userfriendly
unlike this
but which is better? i really need help
This looks like sublime
It's impossible to say just from this screenshot, but that's the default colour scheme for sublime
vsc has this as default
oh
hi i need some help
for some reason on tk they don't show rounded edges on my gui whereas it does on figma (im creating a gui)
object has no attribute
rounded main window corners or widget corners?
Having read the sticky, I am still unsure what framework to use. I want to write a relatively simple GUI:
- macOS is the only platform I care about
- I want native widgets
- I want to display a PDF in a widget, everything else is probably boring standard components.
Toga looks promising, but a bit unfinished.. I'm not sure how I would display a PDF there. With what framework would I have the least amount of pain?
pywebview to render the pdf in an OS supplied webview runtime
If you need additional widgets you can wrap the webview in a tkinter window
What do you mean by native widgets? There's QPdfView in pyqt6
QPdfView doesn't use any native components and has a huge dependency and is an entire impl by itself
Cocoa widgets, not something rendered by some framework. It should look and feel like any other native app.
Pywebview uses cocoa on macos
Yeah, as long as I only use that for the PDF viewing part..
As a window renderer
is cocoa the current macos? I know very little about mac, haha
I don't think cocoa can render pdfs (is one hell of a job to be pulled of by a gui lib)
But every os has a webview runtime now (mostly preinstalled, you should check)
And the webview can definitely render pdfs
Yes, it's the successor to Carbon, IIRC. But I also don't know a lot about Mac internals.
youre saying i should create just one window? not window1 and window4?
Tk() is more than just a window. It's the application instance. If you want more than one window, any additional windows have to be a Toplevel()
multiwindow is just an outdated concept tbh
How so?
you don't find it in newer apps, especially electron ones
I think it entirely depends on what you're building
most VFX software thrive on multi window
and newer ui libs generally implement navigation with pages and routers
maybe because they have a lot of old code / use traditional ui libs?
partially yes, but also because it can be important to see a lot of information at any given time
Floating windows with multiple monitors offers a ton of flexibility
If the windows are dockable as well as floating then all well but if they are just floating it looks super crappy imo
yeah they're all dockable too. You can configure and save any layout, or tear off windows and place them wherever you want
naijce
it seems that modern ui libs aren't matured enough to create complicated UIs yet
like you can't even implement a lazy listview in JS in a half decent manner
Its that bad
Result you end up with pagination
Hey, I developed a web interface using Django for an RFID based attendance system using some microcontroller(ESP8266).
I wanted to check if the http GET request is returning the correct response. Is there a way to find this without actually integrating it in the microcontroller.
In short is there a way of checking the response of HTTP GET requests ?
Tried using Toga now, but it is still very limited, and not very configurable (e.g.: the DetailedList has mandatory Delete and Refresh buttons). Now fighting with wxPython 🤮
can someone tell me its giving me an error if i add the selected line?
can someone help me?
Im getting this error:
Traceback (most recent call last): File "c:\Users\Sirius\Desktop\Tmp Audio Player.py", line 53, in <module> my_meter = ttk.Meter(master=window2) File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 718, in __init__ self._setup_widget() File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 758, in _setup_widget self._draw_base_image() File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 862, in _draw_base_image self._set_widget_colors() File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 773, in _set_widget_colors self._meterbackground = Colors.update_hsv(background, vd=-0.1) File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 367, in update_hsv r, g, b = Colors.hex_to_rgb(color) File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 315, in hex_to_rgb r, g, b = colorutils.color_to_rgb(color) TypeError: cannot unpack non-iterable NoneType object
Didn't I tell you to try pywebview 
You mean Tkinter? My local Python doesn't have Tkinter support, and the experiment I tried on my other machine with it was.. ugly, at least the divider wasn't native.
@dire barn why no Qt ?
I thought Qt drew its own widgets?
See above:
I want native widgets
When not using native widgets, it doesn't feel right, the controls never behave completely correctly.
ok
Currently using TK as a UI and wanting to switch to PyQT. Are there other UI designers similar to QT designer out there that are perhaps better tools?
Can I introduce css into tk to spice it up?
For reference my tk is written directly into a gui module by going qt I'd like to introduce UI files and keep my gui module just for initialization and functionality.
qt creator
although I prefer qt designer and a model view structure, the ui file is seperate and generated by qt designer
for what it is worth, it might be usefull to look into QtQuick (qml) right away. As far as I can tell, less and less companies are using QtWidgets.
do we have to write qml by hand?
Got it working
there's a designer, like QtWidgets afaik
tbh I prefer not using designers and write everything myself so I don't know much about that
i was coding a gui using tkinter for my project and when i run the code and give something in the entry fields and click enter it is not going to the next line can someone help me
here is the code
Is Entry in tkinter a multiline text widget?
no
well then there you go, problem solved
use Text if you want multiline
Or multiple entries. Depends really on your goal
do you want it so if you press enter in the username entry it moves to the password entry?
ah u just want to switch focus
had to focus next
Writing QML by hand is better than using the Qt Widgets designer.
You can use Qt Design Studio as a Qt Designer replacement for QML, although you still will have to manually write some QML yourself
btw, can I add custom widgets written in python to at creator's designer?
Yes
ye i looked at qml, much better than XML garbage
That is entirely possible
nice, i was starting to feel qt creator is too limiting
its focus is on readability
and its super easy to create bindings
Not so easy in Qt Widgets
I already did my app using .ui forms
I'll use qml if I do some other project in qt
Qt Widgets really exposes only like half of the XML capability of UI files
You can use QML and Qt Widgets both in a single app
By using QQuickWidget for QMl stuff in your widgets application
Ok
How does it look so far?
The help message needs worked on, but im just getting things like auto-complete working
or suggestions
1 sec. Ill show the full program
Hey guys, I was wondering if anyone could check out my Git Hub and maybe star a repository that I have I am trying to get it to around 20 stars, Thank you if you do that: https://github.com/ViridianTelamon/Spearmint.
only if if you star mine 
damn lol
This took months?
Pretty nice, maybe you could make the width of the PIN textbox and increase the height of it?
@digital rose what module are you using
could somone help me with a problem i have with tkinter and ttkbootstrap dm me pls
has anyone here used kivy to develop and deploy mobile apps?
How to add context menu to a QTableView to copy a field value from selected rows? I got selectionBehavior set to SelectRows so can't select individual cells to copy
Should I assign a new function to contextMenuEvent method with QMenu stuff?
Could you send the link to the file containing this auto completer?
I'm building a tkinter app. My main window has multiple frames attached to the first grid row, which I switch between using tkraise()
However I am not able to get the elements inside frames to center.
I have tried row and column configure but to no avail
The code in question: https://github.com/DeathVenom54/voting-ip-project/blob/cd412d86e1a6773fa65c8474f4073342f8cdbbb7/frontend/App.py#L19C8-L19C8
https://github.com/DeathVenom54/voting-ip-project/blob/pyqt/frontend/opening_page.py
frontend/App.py line 19
# instantiate all frames```
@quasi oxide the grid parameter reads 0,0 as top left, try different values for the argument or use .place with different param values. For example: ```py
label = tk.Label(frame, text='POLL PILOT')
label.place(relx=0.5, rely=0.5, anchor=CENTER)
Doing column=1 on one element does put it on the right but if I set column=1 for all, they're still on the left
I'd prefer using grid as you can make layouts quite easily with padding as well
Place needs x and y positions
What are you trying to center? Everything in the middle of the window?
I'll send it to you later
yes
I chenged bg color and found that the frame is in fact not occupying all space in window
# instantiate all frames
for (name, frame) in App.frames_data.items():
self.loaded_frames[name] = frame['frame'](self)
self.loaded_frames[name].grid(row=0, column=0, sticky='news')```
So the sticky='news' isn't working?
Got it to work! I just had to use rowconfigure and columnconfigure for the App (main Tk window)
@quasi oxide you could do something like this ```py
self.loaded_frames[name] = tk.Label(frame, text='POLL PILOT')
self.loaded_frames[name].place(relx=0.5, rely=0.5, anchor=CENTER)
Thanks, I got it working with grid though
ok cool
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
Added these 2 lines to root tk.Tk
yeah that works too
use the clicked connection
or itemChanged
I dont think ot has a clicked connection
What is the best TUI framework / library in python atm?
https://github.com/rivo/tview i am looking for something like this, syntax is so nice
!pypi textual
https://github.com/caner-cetin/flamethrower/blob/main/src/views/class_detail_view.go example of what i mean by good syntsx
let me check thanks
wait textual actually comes with shit ton of widgets
still cannot catch the spirit of what i want
lmao
def tracks_list_contextMenuEvent(self, event) -> None:
self.menu = QtWidgets.QMenu(self)
copy_menu = self.menu.addMenu("&Copy")
album_copy = QtGui.QAction("Album", self)
copy_menu.addAction(album_copy)
title_copy = QtGui.QAction("Title", self)
copy_menu.addAction(title_copy)
...
self.menu.exec()
self.tableView_tracks_list.contextMenuEvent = (
tracks_list_contextMenuEvent.__get__(self.tableView_tracks_list)
)
How am I supposed to spawn a menu properly?
It always spawns at the top left corner (even outside the app)
import Qcursor from QtGui
then use the Qcursor.pos()
I just had this issue like 5 mins ago lol
self.menu.exec(QtGui.QCursor.pos())
it worked, thanks
thanks, tried qt for the first time
did you use the designer?
ye
yeah same
I got my gui made, I just have to fix the full screen and stretching now
which is gonna suck
I got issues with centering stuff too, I just use spacers and set max width for widgets as a workaround for now
ye here, maybe you shouldn't spawn different windows
just use stacked widgets for different pages
That chat app ui is fine as a sepearate window tho
in my program code I spawn all my windows once, the. I just show them
much easier to code and setup
and it allows me to have a separate file for each page
the main reason I did this is because I couldn't find out how to resize different pages
Pages in stacked widgets have their own layout
but it's being a mess for me too, settings alignment for one page, sets for all of them, Idk why
yeah im not sure, I tried resizing one page and it would just change the others
yup
thats why I switched
You may use this for screencast https://github.com/ShareX/ShareX instead of bandicam lol
yeah I use OBS now, it's just a pain to setup. Bandicam takes like 5 seconds to fit thr screensize I need
tho...How do I use some state outside this method?
The text I'll be copying to clipboard is not part of self
can't modify the method params either
just make a self.text statement
umm, the text is already there but not part of self
how would I bind it to self if I can't even access it?
wait what line
In TableView
def setModel(self, model: PySide6.QtCore.QAbstractItemModel) -> None: ...
what does this method do?
because the text I want to copy is inside the model
check the methods with dir
oh wait
are you trying to get the text of the table?
like the selected row?
ye
ah 1 moment, let me go through my code
# Setup tracks list model
self.tracks_model = TracksModel()
self.tableView_tracks_list.setModel(self.tracks_model)
def tracks_list_contextMenuEvent(self, event) -> None:
self.menu = QtWidgets.QMenu(self)
copy_menu = self.menu.addMenu("&Copy")
copy_album = QtGui.QAction("&Album", self)
copy_menu.addAction(copy_album)
copy_title = QtGui.QAction("&Title", self)
copy_menu.addAction(copy_title)
copy_artists = QtGui.QAction("A&rtists", self)
copy_menu.addAction(copy_artists)
copy_link = QtGui.QAction("&Link", self)
copy_menu.addAction(copy_link)
# This contains the text
# [
# self.tracks_model.tracks[row.row()]
# for row in self.tableView_tracks_list.selectionModel().selectedRows()
# ]
self.menu.exec(QtGui.QCursor.pos())
can't access the model from TableView object
So I did a connection
self.connect_window.ui.ServerTable.cellClicked.connect(self.cell_clicked)
Then I did this in the cell_clicked
def cell_clicked(self, row, column):
self.selected_row = row
``` then when I call some other method like load etc. I check and see what the current self.selected_row is
or do you mean you right click on a cell , then the menu shows up
like copy etc
I can get the rows using
print(self.selectionModel().selectedRows())
that's not the problem
the problem is that I need to access the model data
Ah then I have no idea. I've never used a model
why do you need a model in the first place?
All my code info is shared through a class
i found model in dir(self)
maybe i can access model through that
oh ye, it worked
thankfully
...
def get_selected_tracks():
return (
self.model().tracks[row.row()]
for row in self.selectionModel().selectedRows()
)
def copy_fields(fields: Iterable[str]) -> None:
QtWidgets.QApplication.clipboard().setText("\n".join(fields))
copy_album.triggered.connect(
lambda: copy_fields(
(track.album_name for track in get_selected_tracks())
)
)
...
Ah nice!
I like this a lot
ShareX
welp, time to remake this with a layout
how do i check which button was clicked for QMessageBox.question ?
self.sender()
def show_list_context(self, point):
list_widget = self.sender()
item = list_widget.itemAt(point)
menu = QMenu(self)
``` thats what I did for this
then I just check and see, and show which menu depending on it etc
Found it
if ret == QMessageBox.StandardButton.Yes:
...
else:
...
my lsp stops working every now and then, making it hard to explore the qt api
Also, my horiz stretch does nothing
ah dang
that sucks
Ye I'm not good with layouting
Yeah I mean look at this lol
ah
lol I didn't even see that u were inside the designer
thought this was inside the app
nope. You can move them around tho
is this form layout?
its grid. And a mix
i see
love qt6 on wayland
it's sort of a display manager in linux
it's default 
qt doesn't support wayland all that well rn
Okay
final UI I think. Might add some icons etc but this is gonna be the main look
interesting
any suggestions?
does anyone know if i can create a button that only pops up when a if statement is passed in tkinter? and if u have can u show me an exanple?
how to use QMessageBox with no parent?
ah None worked
I hope this wouldn't have unexpected consequences
try:
window = MainWindow()
window.show()
except Exception as e:
import traceback
detailed_dialog(
None,
"Failed to launch main window",
repr(e),
icon=QMessageBox.Icon.Critical,
detailed_text=traceback.format_exc(),
).exec()
sys.exit(1)
The only consequence I've noticed is that it pops up in the center of your screen, as opposed to in the center of your parent.
I'm guessing resizing and location issues also
guys I can't install tkinter by pip
yep you can't
Got backgrounds to work
...there is no parent 
nice, but hard to see some light green text due to contrast
Am I creating a menu here repeatedly?
I want to create an interface overlay over a windows application. My app should stick to that window even when I move it around
Can I use tkinter for this?
and pyautiogui to select the windows e.g
yep
You can create frameless windows with tkinter
That should come in handy then
Thx
The overlay part tho
Some software don't like it
So they can do stuff like killing your process or hiding the gui themselves
I tried to understand tkinter grid function better by making this example.
import tkinter as tk
from tkinter import ttk
# Open root window
root = tk.Tk()
root.geometry("800x400")
root.title('test')
# configure the grid
for cel in range(8):
root.columnconfigure(cel)
root.rowconfigure(cel)
for column in range(8):
for row in range(8):
login_button = ttk.Button(root, text=(str(column), str(row)))
login_button.grid(column=column, row=row, sticky='nesw')
root.mainloop()
What I expected to happen here is 1 button in each grid stretched out, but the result is as follows:
Already fixed it had to add weight = 1 when configuring the row and columns
I have this now, is there a way to make the buttons touch? Like there is no gap in between
Anyone know a solution to this witchcraft?
Tried uninstalling pyside and install (venv) it again but it doesn't help.
PySide6 6.5.2
PySide6-Addons 6.5.2
PySide6-Essentials 6.5.2
the problem disappeared when I disable Pylint
yeah true
how does it look so far though? Any suggestions
that's some high quality linter right there
damnit i hate ci cd bs
Mildly frustrating. especially when the code otherwise works.
it fails at the last step
i use ruff, it works fine
except for some visual bugs in jupyter notebook
ok it worked, it was permissions all along
i figured it out thanks to the very very obvious error message
Your code?
if you use pack/grid, set padx and pady to 0 (or remove them)
I am self taut and did not find much good on place. Can you tell me the main differance between place and pack and place and grid
place should be avoided 99.9% of the time, it's pretty much useless
absolute positioning is a nightmare if you need to make any adjustments. pack and grid manage the widgets so they're aware of what's around them and will adjust position accordingly
Guys are any of u familiar with the python flet framework/library
i have seeend videos about it and honestly its better than tkinter pyside6 and PyQT5
although i have only worked with Tkinter ,PyQT and customtkinter
I developing with it now and tbh its better than all the python UI frameworks ever existed
it's two times larger than Tkinter
but they say its still devlopment
it has the multiplatfrom concept
you guys should try it too
I'm currently learning it
here is the documentation
flet.dev
Build internal web apps quickly in the language you already know.
it has the flutter concept to develop apps
but in pythons which im so thankfull for
Tkinter is shit
after i tried this
what don't you like about pyqt?
iam just saying that flet is better than them in options you get
it has multiplatfrom support too
def home_page():
home_frame = tk.Frame(main_frame)
home_log = scrolledtext.ScrolledText(home_frame, font = {"Times New Roman", 15})
home_log.pack(fill='both', side='bottom', expand=False)
home_frame.pack(pady=20, padx=20)
Why is my scrolledtext widget filling the entire frame? And not attached to the bottem like I assigned it to.
Anyone know any good videos on how to learn to use tkinter
@placid steeple just use documentation/online tutorials, it's much more convenient and efficient
what would be a good way to ensure only a single instance of your qt app runs at a time? lock files?
I found this tendo.singleton floating around, should I use it?
or use QLockFile?
I am very annoyed that the discord bot destroyed my entire message which I didn't save. Ugg. I guess I have to rewrite it...
Anyways, any nerds want to help me with some curses? I'm making a rogue-like thing in which the world you explore is very large, way larger than you can fit in a curses Pad. I want to make it so that the player is in the middle of the screen and the "camera" follows the player as they go. I want it to be completely continuous in experience.
I wrote up a plan about how I think this may work, which this discord is making me put into a pastebin:
https://paste.pythondiscord.com/NKEQ
Can I have any advice if this is the correct way of going about this? Is there a better method I can use?
I'm going to bed. IF anyone has any comments please @ me or private message me, thank you
I tried to use QLockFile, but it's not working
lockfile = QtCore.QLockFile(f"{__package__}.lock")
if lockfile.tryLock(100):
print(f"{lockfile.fileName(), lockfile.isLocked()=}")
print("app running")
time.sleep(60)
...
else:
print("app already running")
...
I can still run multiple instances of the app
Can i somehow integrate command prompt window in PyQt5 / Qt designer?
All I want is to show output of a .bat file using command prompt that is simulated in my Qt window
@median junco what ide/engine are you using
Use a global mutex
Must be something in threading
how? and why isn't lockfile working?
How? Let me lookup
Lockfile? Idk
onlien tutorials?
Do you have any ones you can reccomend to me
alr
@placid steeple tutorialpoint and geeksforgeeks both have some nice articles you can follow

seems like c++ qt has a QtSingleApplication which has no such thing in pyside or pyqt
yeh I saw that online, couldn't find it in python lib
I will look into both of them thank you (my project is due in 3 weeks lol)
there's this too tendo.singleton.SingleInstance, uses lockfile i think
it works but idk if I should use it
tkinter is really easy to learn so you should be good ;)
and if you do learn tkinter you should aslo probably know customtkinter, since it looks way nicer and more modern
@next ridge you can use this class as is https://stackoverflow.com/a/12712362/5541355 it involves creating / searching if a local port is open
which would be faster? lockfile or this port method?
Can't say for sure
But both are equally fast on modern systems
If you wanted a Windows only solution its as simple as creating a named mutex via a simple OS API call
yeah thats what the goal is
im learning tkinter to learn how to use customtkinter
I've been using this as a basis for learning it
real python is great
but this specific one has been explaining it as if writing it directly to console
while I prefer to make a demo file which I can look back at when coding
if you have specific problems, tutorialspoint is helpful for that
its more kind of like
ive been writing it like this
but I cannot update the text boxes in real life to actually demonstrate these functions
because they happen automatically as the program is run
is there a way for me to sort of run these at my choice of time while the program is running without writing all my code to the console?
Im using pycharm
I tried it in the output but it doesn't really work like that
all 3 u sent me are open rn
can you paste your code
sure
import tkinter as tk # This imports the tkinter file
window = tk.Tk() # This creates a window for tkinter
def task_1(window):
greeting = tk.Label(text="Hello, Tkinter") # Creates some Text (A label) to the window
frame = tk.Frame()
greeting.pack() # This adds the label to the window!
# Reminder!!!
# When you pack a widget into a window, Tkinter sizes the window as small as it can be while still fully encompassing the widget.
#Label widgets are used to display text or images.
label2 = tk.Label(
text="Hello, Tkinter",
foreground="white", # Set the text color to white
background="black", # Set the background color to black
width=10, # Sets the width of the label
height=10 # Sets the height of the label
)
# You can also use HexaDecimal Values for colours
label2.pack() # Adds the label to the window
# Next we will look into buttons, Buttons are just like Labels but you can click them!
button = tk.Button(
text="Click me!", # Defines the text for the button
width=25,
height=5,
bg="blue",
fg="yellow",
)
button.pack()
# Next is Entrys which are text boxes which users can input text into!
entry = tk.Entry(fg="yellow",
bg="blue",
width=50 # This will be the width of how many text units can be entered
)
entry.pack()
# Now we are going to get create a text box which has functions
def entry_box(window):
label = tk.Label(text="Name") # Creates a text box in which the person cannot edit
entry = tk.Entry() # Creates a text bot which the user can edit
label.pack()
entry.pack()
#Tkinter automatically centers the label above the entry, this is a feature of .pack()
name = entry.get() # This gets the contents of the entry text box!
print(name)
entry.delete(0) # This deletes a character from the entry text box! In this example it is the first character.
entry.delete(0, 4) #This deletes all the characters between the 0 and 4th character and is inclusive.
entry.delete(0, tk.END) # This deletes the all the characters because of the special constant tk.END
# If the user were to enter "Real Python"
entry.delete(0, "Python") # This would delete everything up to Python making the text box just "Python"
# Next is inserting text
entry.insert(0, "Real") # This would insert real at the start of the text making it "Real Python" once again
#If the text box is empty it doesn't matter what number you put, it will always place it at the start
def text_box(window):
text_box = tk.Text()
text_box.pack()
# You could run text_box.get(), however it would return an excpetion.
#If text box contained "Hello World" on a different line for each word
text_box.get("1.0") # This would return just "H"
# The index must contain the line and the position of the character on that line when using get for text boxes
text_box.get("1.0", "1.5") # This would return "Hello", 1 represents the line, and after the "." represents the position of the character
text_box.get("2.0", "2.5") # This would return "World"
text_box.get("1.0", tk.END) # This would return "Hello\nWorld\n", "\n" represents a new line.
# text_box.delete() is used similarly to entry boxes delete
text_box.delete("1.0") # This would delete the first lines first character making it "ello"
text_box.delete("1.0", "1.4")
# When deleting with text boxes you pass two indices to delete a range of characters starting at the first index and up to, but not including, the second index.
# Even after deleting this you will still
text_box(window)
window.mainloop() # This tells Python to run the Tkinter event loop. It is basically a start command, like bot.run()
It is a lot lol
I like having like a code bank of examples in which I can reference while coding
hmm
make a button
button = tk.Button(window, text='text box', command = lambda:text_box(window)
button.pack()
when the button gets pressed the command should execute
why can't i assign a font to a variable with tkinter?
the docs tell me i can use tk.font but vscode is telling me tkinter has no such module
(i renamed it to tk when i imported it)
ok that problem is fixed, but im running into errors with changing the size of the font
i thought i could do MyFont.size(14) to modify the size attribute but apparently not
cause i wanna assign the font family to a variable so that i can change it as I like without having to go through every line to change it
but some text is bigger than other text, and I cant figure out how to make my text size change while keeping the same family
i see that you can call the size by just putting the number in without writing size= , meaning you can write it as tkinter.font.Font("Arial", 20), but then I dont know how i would call that attribute to change it
its even more confusing when i see there is a size attribute RIGHT THERE
MyFont = TkFont.Font(font="Arial", size=14)
text_result = tk.Text(root, height=2, width=16,
font=MyFont.config(size=24))
text_result.grid(columnspan=5)```
basically this is how i wanna use it
is this the correct way?
(the things in there like root which arent defined arent the problem, i just didnt want to copy all my code)
oh your right
thank you
you can either use myFont.configure(size=20) or just redefine the variable: ```py
#reference the variable
myFont = tkinter.font.Font("Arial", 10)
#new value
myFont = tkinter.font.Font("Arial", 20)
the site said it was config bruh wtf 💀
config and configure are essentially synonymous
first = int(input('enter number: '))
operation = input("enter operation: ")
second = int(input('enter number: '))
if operation:
input("*")
print(first * second)
elif
it says there is a problem with elif
it didnt work
the size isnt changing
heres more of my code for reference
root = tk.Tk()
root.geometry("300x275")
MyFont = TkFont.Font(family="Arial", size=14)
text_result = tk.Text(root, height=2, width=16,
font=MyFont.configure(size=24))
text_result.grid(columnspan=5)
btn_1 = tk.Button(root, text="1",
command=lambda: add_to_calculation(1),
width=5, font=MyFont.configure(size=14))
btn_1.grid(row=2, column=1)
btn_2 = tk.Button(root, text="2",
command=lambda: add_to_calculation(2),
width=5, font=MyFont.configure(size=14))
btn_2.grid(row=2, column=2)
btn_3 = tk.Button(root, text="3",
command=lambda: add_to_calculation(3),
width=5, font=MyFont.configure(size=14))
btn_3.grid(row=2, column=3)
btn_4 = tk.Button(root, text="4",
command=lambda: add_to_calculation(4),
width=5, font=MyFont.configure(size=14))
btn_4.grid(row=3, column=1)
btn_5 = tk.Button(root, text="5",
command=lambda: add_to_calculation(5),
width=5, font=MyFont.configure(size=14))
btn_5.grid(row=3, column=2)
btn_6 = tk.Button(root, text="6",
command=lambda: add_to_calculation(6),
width=5, font=MyFont.configure(size=14))
btn_6.grid(row=3, column=3)
btn_7 = tk.Button(root, text="7",
command=lambda: add_to_calculation(7),
width=5, font=MyFont.configure(size=14))
btn_7.grid(row=4, column=1)
btn_8 = tk.Button(root, text="8",
command=lambda: add_to_calculation(8),
width=5, font=MyFont.configure(size=14))
btn_8.grid(row=4, column=2)
btn_9 = tk.Button(root, text="9",
command=lambda: add_to_calculation(9),
width=5, font=MyFont.configure(size=14))
btn_9.grid(row=4, column=3)```
Guys I got a noob question
How do I reach the Frame of class Home from class Menu. Obviously its an object, how do I reach the frame itself?
I want to change a frame on button click like this
command = lambda :app.Show_frame(Home.Frame))
But Home.Frame doesn't work
def Show_frame(frame):
frame.tkraise()
class Menu(tk.Frame):
def __init__(self, parent):
super().__init__(parent)
ButtonOne = tk.Button(self text="Home", command = lambda :app.Show_frame())
ButtonOne.pack(expand = True, fill = 'both', side='top')
class Home(tk.Frame):
def __init__(self, parent):
super().__init__(parent)
Like why can't I just say Home.Frame when I'm in the Menu class
I don't know what "engine" means. I don't use an IDE. I code in vim.
no one?
You need to hold a reference to Home somehow when you're inside the Menu class or vice versa. For instance, I might approach it like:
class Menu(tk.Frame):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
ButtonOne = tk.Button(self text="Home", command = lambda :app.Show_frame())
ButtonOne.pack(expand = True, fill = 'both', side='top')
class Home(tk.Frame):
def __init__(self, parent):
super().__init__(parent)
self.menu = Menu(self)
so with something like this, if you want to access Home.Frame from menu, it would be: self.parent.Frame
Does that make sense?
That won't work because MyFont.configure(...) doesn't return anything. You're essentially doing
font=None.
I would recommend just creating a new font variable at the size you want and using that.
does pyglet accept otf files and not just ttf files? there is a font that i want to add but im having trouble with importing it (its an otf file)
i wanna know if that is the problem or if its something else
ive tried putting it in the same directory as the .py file and adding the whole directory with the add_directory() command, and so far nothing has worked
i cant find anything online telling me if pyglet accepts or doesnt accept otf files
ok even ttf doesnt work
what am i doing wrong
import pyglet
pyglet.font.add_file('lmroman10-regular.ttf')```
these are the only two lines concerned
the name is the exact file name, and the file is placed in the same directory as the .py file
Hello, anyone ever encountered this sort of problem in PySide6 before? using QScrollAreas...
myFont.configure() should be its own line of code, not a parameter
@bronze iron What do you think about the UI for this IRC chat?
be honest. I need improvements
someone said it was too bland . Not really sure what needs work tho. It does have a lot of empty space tho
... Why are you asking me about UIs? I hate UIs, I love apis.
This just looks like most IRC UIs. IRC is basic, IRC UI is basic 🤷
Hello
Hello, I’m facing problem when running any Python code that contains tkinter because it shows black screen only I use mac
Anyone suggests a solution?
can you post a picture
Hi, I'm new here, just wanted to show you guys a program I made using PyQt5 for a download manager that can download multiple files simultaneously. In order for me to show you what I did, you need to download it. It's just a zip file made from the auto-py-to-exe library to convert my py file to an exe file and zip up the folder containing the program's code. It's not a virus I swear, because every time I post something about a link to download something, people always say it contains a virus. Oh my god, I swear it does not contain a virus, because I just converted the py file to an exe file. So, if you want to check it out, you can. If not, then it's ok too.
This is the link:
https://drive.google.com/file/d/1iPNs1-4QpTbQAA05TgPgSDTGPpV5zuzO/view?usp=sharing
We don't really allow unapproved advertising here, especially to run an unknown exe. If you'd like to share your project's code for something like a code review, it should be a paste link or a github page
I want to write the code of this kind of design, but I think it is very detailed I can not do it how can I do it or does anyone have interface code in a style similar to this
This could be done using pyqt
Hi, sorry for the late response.
I usually get something like this
image source is from google
@fringe sorrel have you tried changing the color of your label/window?
yeah
even tried to close dark mode
nothing worked
Looking at the source code, the font support is platform-specific. For example, on Linux it looks like it would use FreeType, which does support OpenType fonts.
https://github.com/pyglet/pyglet/blob/master/pyglet/font/__init__.py
https://github.com/pyglet/pyglet/blob/master/pyglet/font/freetype.py
pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications. - pyglet/pyglet
even after converting the font file to ttf (like all the examples online show) it still didnt work
I need help making a UI compatible with asyncio.
@fringe sorrel i use windows so i'm a little confused but is that the command window or the root window?
root window
Can I see your backend I'm tryna make a irc chat
what tkinter version are you using
can you screenshare in a vc just so i can get an idea of what's going on
Thx
If something doesnt work let me know. I've been having weird issues when pushing to git
K
:incoming_envelope: :ok_hand: applied timeout to @rotund lodge until <t:1692638241:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
:incoming_envelope: :ok_hand: applied timeout to @rotund lodge until <t:1692639355:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
[PyQt] Is there an easy way to auto-expand an QLineEdit based on its contents (expand if it doesn't fit)? I'm thinking the only way would be to figure out the contents' width with QPainter.fontMetrics().horizontalAdvance() if that's even possible, but maybe there is an easier way?
And with QGridLayout, it is not possible to auto-determine how much width is available, and wrap rows according to how many columns fit? Or vice versa, wrap columns based on how many rows fit. I suppose it would be possible "manually" if I really need it, but I am not supposed to do that, right?
I've been using this "flow layout" class to handle that
Oh, cool, thank you!
If you haven't already fixed your problem, this might be useful
https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QGraphicsEffect.html
This is pretty neat!
The color scheme reminds me of AS400 I used to use when I worked sales before committing to the life of a programmer.
hey guys i need some help
what app is this youtuber is using? i find it very clean
please ping if you know, thanks!
looks like Sublime Text
you think?
but it looks very similiar to VS Code tho
idk i'm quite a beginner on python so i like to explore editors
nah, that's definitely not VSC
I use Sublime Text, this is 100% what it is
I don't use that colour scheme though
ahhh really?
so i'm using the IDLE
I use this colour scheme
well the font looks weird
in idle?
small thing i'm working on
sometimes it's annoying when you can't edit something at the same time if you want
yes, it's definitely sublime
there's a free version
it has most features, and it bugs you to pay every once in awhile
Just be warned that it doesn't support input()
but that's fine since you can run your code from cmd
well that's bad
for my lil project i'm gonna need that a lot
but thank you so much man
:)
you don't really need input() if you're using GUI
hm
but i thought if you are going to put in some numbers to convert
in that case i'm sorry like i said, i'm total noob like level 5 experience with python
How does QtQuick compare to QtWidgets? Is it more "troublesome" or less? Do you have to use QML, or can you still do stuff procedurally?
this is amazing! thank you! is there a way to do this in QML though?
have you heard of the lord and saviour gtk4
[PyQt] A QScrollArea allows itself to be squished by QSplitter to the same (tiny) size, regardless of its actual widget size - because "well, you can always scroll it". Is it possible to disallow squishing it in one direction below its child widget size? I.e. I only want to scroll it vertically; but horizontally, it must never be below its widget width and force me to scroll! (Disabling horizontal scroll bar does not help - it simply does not show the bar.)
I'm so dumb. Why does this always happen immediately after I post the question, and not during the hours before that? I was setting the sizePolicy of the widget inside the ScrollArea, and wondering why does that not affect the ScrollArea itself.
rubber duck debugging so common there's a term for it
:incoming_envelope: :ok_hand: applied timeout to @fresh prism until <t:1692968565:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
how can i apply rounded corners in a Image in gtk-3?
there are lots of good libraries, like Tkinter/extensions, PyQT, PySimpleGUI, etc. if you do happen to choose tkinter, along the way learn customtkinter and/or ttk because tkinter looks like garbage
Thanks
can someone help on these i have been trying to but it not working i have install dorker compose
the stdlib includes tkinter https://docs.python.org/3/library/tkinter.html .
some people like Qt, some people like GTK windowing toolkits.
i think the standard reply is tkinter. however, the question could be clarified. UI in the web browser could be accomplished in a variety of ways, for instance. in my understanding, this chan is a/b desktop UI, but then again i haven't checked the scrollback.
any qtile fans out there?
do people use pyinstaller with pyqt or something else to deploy to .exe (and other os)
like, can you deploy a pyqt app to android, what would you use then?
also, bit of a tangential question but, I've finished a couple of tutorials on PyQtWidgets (and ModelView stuff). but then I discovered QtQuick and it feels confusing:
(1) it seems that everyone is moving away from QtWidgets and applying QtQuick + QML?
(2) not exactly sure how much of PyQt can be actually used with QtQuick
(3) it seems nice for developing mobile apps (but what if I don't want to bother with that?)
(4) looks very similar to kivy, I tried kivy but completlly failed at deploying a "Hello world" as an .apk (tried 3 days at it), why would you use this over kivy
I cannot run mamba after installing it. Can anyone help?
(base) notooth@localhost:~$ conda install mamba
(base) notooth@localhost:~$ mamba
bash: mamba: command not found...```
in gtk4 you use the border-radius css property
in gtk3 i believe i saw someone using cairo to do this:
- Here is someone explaining this: https://stackoverflow.com/questions/35480832/create-a-rounded-image-in-gtk
- The gnome music project does this for album cover-s, an example gtk3 release was 3.38
The cairo approach requires creating a widget subclass, implementing the draw function and then creating a cairo surface with your image in, then using cairo function-s to clip the surface.
It is easier in gtk4 where you can add a css class to your image and then in the style.css file you can round all widget-s with that css class.
Perhaps a selector of image.myClass
I need help, Im building a Flask web application with an HTML form that I want to submit. But im encountering a BuildError when Flask tries to generate a URL for an endpoint named 'upload' in my form's action attribute. However, I didn't define the 'upload' endpoint in my Flask application, and im unsure how to handle this situation.
ehh, tkinter can be a hassle to learn, especially when people tell you to switch to customtkinter or ttk in the middle of learning it. and it definitely has its limitations, so some people decide to use an easier, better-looking alternative like Qt
use QML or Qt Widgets. You can create UI using drag and drop (or you could write it in either QML or XML(for Widgets) if you wanna do that)
someone knows if tk supports draggables?
like qt support on discord is dead and i think tk have right now more support :/
there is the qt server..
i dont use tk but ill try to see if there is documentation for this
i could throw you something similar in qt cause i have designer app but tk is more supported as its builtin
are you using qml or qt widgits
i want to use tk
oh ok
like i'd like sort of that (sorry for language, i meant only to have a window with 2 or 3 panels where are items being able to be dragged between these panels):
and i'd like something like that in tkinter
sort of a todo list app with two views where i can drag tasks between lists on one window
↑↑↑
well it seems like you are trying to make drag and drop widgits
yep
i would recommend QT for this(its literally made for this), but I believe this post has you covered: https://stackoverflow.com/questions/37280004/tkinter-how-to-drag-and-drop-widgets
I am trying to make a Python program in which you can move around widgets.
This is my code:
import tkinter as tk
main = tk.Tk()
notesFrame = tk.Frame(main, bd = 4, bg = "a6a6a6")
notesFr...
will see cause im too dumb for qt designer and in tk i already made apps…
qt is easy
and ui looks better
tk looks ugly like you need to put insane amount of effort to make it look good or import a 3rd party theme
like theme i dont care but even qt designer is hard af for me (and where coding all that…)
Hello everyone, I'm learning python, which IDE would you recommend to a backend dev in training?
i prefer writing the ui using code, bc then i can implement dynamic behaviour with ease
any with a { tree-sitter+ lsp+ dap} backend. Have you used a modal editor before like vim?
Hey, thanks for your swift response, I haven't used anything before I'm in a career change phase.
I'll look for what you recommend.
there are many capable modal editors like neovim which can use modern features however these require time to learn the keybindings
there is good reason to learn an editor with in depth keybinding systems as they are very fast once you learn them but there is that learning curve.
Out of these, i would recommend helix or neovim ( i have heard that emacs is good), they both come with support for pretty much any language
vscode is the only ide i know of with modern features without requiring one to learn many keybinds
i am hesitant to recommend vscode due to microsoft~s monopoly on many industries, i do not want to contribute,
There are probably other easy to pick up editors but vscode is the only one i have used
Ide-s used to be more clunky than they are today, they used to build in support for each language within themselves but nowerdays ,many editors support generic interfaces to different languages so that things such as ( code completion, highlighting, "go to definition") are handled by external software
that software is:
- tree-sitter: provides a quick representation of your code, the editors use this for colouring code and jumping around the document
- lsp ( language server protocol): provides more in depth features such as code completion, the ability to jump around references to a symbol, the ability to rename a symbol and have that rename propagate through the code, ...
examples are: pylsp ( python), clangd ( cpp, c), marksman ( markdown) - dap ( debug adapter protocol): provides a generic manner of debugging code, allows one to execute their code and view the program state in order to locate issues with the code
so in short, the modern code editors i can recommend are:
keybind heavy ( fast):
- helix
- neovim
- ( possibly emacs)
easy to pick up and use, usually graphical: - vscode ( with microsoft caveat ( vscodium is vscode but compiled without ms telemetery and such))
oh i used pycharm for a lil bit but again it is propriatary, they do have a community edition but it~s main function is to funnel people into the payed edition
Hi, I'm working with Tkinter to make a GUI with a scrollable Text widget, and everything to do with showing things in the widget works, but the Scrollbar seems to keep repeatedly snapping back to the top of the Text widget as soon as it gets pulled down. Any idea what could be causing this?
text = tk.Text(frame, wrap='word', width=40, height=10, font=('Arial', 10))
text.grid(row=0, column=0, padx=20, pady=20, sticky='ew')
scrollbar = tk.Scrollbar(frame, command=data_show.yview)
scrollbar.grid(row=0, column=1, sticky='ns', padx=(0, 10), pady=10)
text['yscrollcommand'] = scrollbar.set
another thing - someone know how to generate list of buttons in tk basing of text file with new lines as button labels?
like i can't generate dynamic variables
and i want sort of :
f = open("file.txt", "r")
num = 0
for line in f:
$num+button(app, text=line).pack
num++
while also being able to track such buttons so i can for example do later a condition to check text parameter contents (even if duplicate)
and also being able to count how much buttons are generated?
Is kivy still pretty much the go to for mobile development without html/css/js?
still no answer…
store the buttons in a list or dict as you create them
but how to pack them and display?
f = open("file.txt", "r")
num = 0
num2=0
for line in f:
$num+button(app, text=line).pack
num++
for button in buttons:
if button[text] == *[@,#,$]*:
$num2+button(frame,text=button[text]).pack
num2++
like that
import tkinter as tk
button_names = ['foo', 'bar', 'baz']
buttons = []
root = tk.Tk()
for btn in button_names:
new_btn = tk.Button(text=btn)
new_btn.pack()
buttons.append(new_btn)
root.mainloop()
try running this
k, will see
ugh…
C:\home\hacknorris\Muzyka\game> ./main.py
Traceback (most recent call last):
File "./main.py", line 60, in <module>
myapp = App(root)
File "./main.py", line 44, in __init__
additem = tkinter.Button(left,text=inititems[item]).pack(side=LEFT)
TypeError: list indices must be integers or slices, not st
code:
import tkinter
from tkinter import *
from tkinter.ttk import *
import os
import configparser
config_file = "settings.conf"
config = configparser.ConfigParser()
config.read(config_file)
items = []
items2 = []
inititems = []
for line in config.get('default','init_items'):
inititems.append(line)
for item in inititems:
additem = tkinter.Button(left,text=inititems[item]).pack(side=LEFT)
additem2 = tkinter.Button(right,text=inititems[item]).pack(side=LEFT)
items.append(additem)
items2.append(additem2)
it's telling you what the issue is
you likely don't want text=inititems[item]
you just want text=item
also absolutely do not pack and assign in the same line
additem = tkinter.Button(left,text=inititems[item]).pack(side=LEFT)
additem = tkinter.Button(left,text=inititems[item])
additem.pack(side=LEFT)
what is inititems? Your loop doesn't quite make sense here either
anyway - now works, used enumerate
now other problem - i'd like a container to wrap content if bigger than current window size
(config access will fix later)
auto wrapping widgets is actually quite a complex problem to solve. I recommend just using some sort of scrolling widget or fixed grid