#user-interfaces

1 messages · Page 10 of 1

indigo crane
#

yeah forgot to pack

sleek hollow
#

misread it

indigo crane
#

was making a minimal example to reproduce :P

indigo crane
sleek hollow
#

I get 95.92433628318584 from running it

indigo crane
#

thank youuuuu!

#

🤍

native ledge
#

is there anyone online right now that has lots of knoledge of pyqt6?

somber hemlock
native ledge
#

???

somber hemlock
swift vault
#

One step closer 🥳

elfin stirrup
clear pond
#

need help, can someone help me center

swift vault
# elfin stirrup How does this work exactly?

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')")```
elfin stirrup
swift vault
#

Its a framework that allows to print left, center and right oriented text using a theme for different presentation

elfin stirrup
#

interesting

#

I'm sorry for the stupid question, but why?

#

(feel free not to answer)

swift vault
#

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" 😅

elfin stirrup
#

oh, this is interesting.

#

well, thank you! good luck!

swift vault
#

goal is to simplify console output,and make it more... appealing.. to endusers, while keeping it simple to use for coders

elfin stirrup
#

yeah, that's cool

swift vault
swift vault
# clear pond need help, can someone help me center

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```
misty canopy
#

// 2 * 2 / 2 looks slightly weird to me anyway, since it's just //2 but as a float

lucid cedar
#
        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?
somber hemlock
lucid cedar
# somber hemlock (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

somber hemlock
#

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))
lucid cedar
somber hemlock
#

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

lucid cedar
somber hemlock
#

Instead of

ft.Column(ft.Row(ft.Button(...)))

use

col = ft.Column(...)
row = ft.Row(...)
btn = ft.Button(...)
row.append(btn)
col.apppend(row)
lucid cedar
somber hemlock
#

only whenever required

somber hemlock
lucid cedar
somber hemlock
#

Yes but such code looks trashy

lucid cedar
somber hemlock
#

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

lucid cedar
somber hemlock
#

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

somber hemlock
lucid cedar
somber hemlock
lucid cedar
lucid cedar
#

guess i will have to switch back to something else cuz it aint colouring the module name and class name and stuff

somber hemlock
lucid cedar
somber hemlock
#

yea use pylance preview if vscode

#

Preview version > stable

lucid cedar
somber hemlock
#

yea use preview

#

should fix that

#

And make sure it isn't accidentally scanning your entire venv by any chance

lucid cedar
somber hemlock
#

btw have you enabled any of the linters from python extension?

somber hemlock
#

Like flake8 or mypy?

#

pycodestyle, pydocstyle and the worst registered offender pylint?

#

Check if you have, disable those, they slow everything down

lucid cedar
somber hemlock
#

These stuffs are enabled from inside the python extension

lucid cedar
digital rose
#

i've accidentally created a shield.

floral marsh
#

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?

floral marsh
#

(Or, is there a tool you suggest for cross platform gui?)

humble tundra
#

You can easily make desktop apps with it

#

And easily build for win, Mac, linux

humble tundra
#

Electron is well a mem hog and takes a lot of mem so I will suggest Tauri it uses wayy less mem than Electron

lucid cedar
#

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

digital rose
#

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()
elfin stirrup
#

@digital rose you don't seem to have made your button use the style you created

digital rose
elfin stirrup
#

@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

digital rose
#

😕 Eh. Thank you

turbid ravine
#

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

  1. 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

  2. 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)

lucid cedar
#

can someone give me the most basic example of a FilePicker in flet

somber hemlock
lucid cedar
somber hemlock
#

FilePickerResultEvent contains a path attribute, so its just e.path in your callback

lucid cedar
undone mica
#

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

last saddle
#

How do you import your own font to Tkinter (I'm using the sv_ttk theme)?

fair locust
#

Is it possible to share open source project here without being banned? Or is it like advertising

fair locust
#

Is there some efficient front end framework for python according to you or is always better to use JavaScript for your python front?

somber hemlock
fair locust
somber hemlock
fair locust
somber hemlock
drifting spire
turbid ravine
exotic socket
turbid ravine
#

did u notice it?

exotic socket
#

Still can’t see it, and watched both videos 5x

turbid ravine
#

what?

#

u didnt see the text like bool-type-arg flashing at the last line of the terminal?

lucid cedar
#

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

tame perch
#

@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?

golden breach
#

how do you overlay foreground and background images in tkinter again?

digital rose
#

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()
tribal bone
#

pyqt or kivy

tame perch
#

Ok. Thanks @rigid light@somber hemlock & @tribal bone

solid wedge
#

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?

sleek hollow
solid wedge
sleek hollow
#

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

solid wedge
digital rose
#

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.

faint warren
#

noob question, but what methods/modules can I use to get user input in a clickable text box?

faint warren
stray jackal
#

thats cooool

vale wadi
#

Anuone know why i close my modal for 2 time, my screen stay grey?

hot scaffold
#

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

spare hedge
#

!code

proven basinBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

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

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

For long code samples, you can use our pastebin.

amber sage
#

what is the best way to learn kivy?

somber hemlock
brazen nacelle
#

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:

  1. 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()
  1. 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()
lucid cedar
#

why is flet squeezing up my memory- it is taking 2.2 gigs ffs

full cosmos
#

Looks awesome!!!

somber hemlock
#

Small snippet if possible

#

Or whatever you suspect causes it

floral marsh
#

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)

lucid cedar
# somber hemlock Small snippet if possible

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))
somber hemlock
#

Btw you don't need a class at all here

lucid cedar
# somber hemlock what is self.scrape?
    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.

lucid cedar
somber hemlock
digital rose
#

what are these widgets/objects called that allow you to decrease/increase value?

timber yacht
#

If yes, then it's an input with type="number"

digital rose
digital rose
timber yacht
#

Oh you want the exact name

#

Nvm

digital rose
#

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

floral marsh
lucid cedar
#

and by dynamic arguements i mean, that they are different for each one, and keep changing

elder hinge
#

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

magic ether
#

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)

solid jackal
#

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!

digital rose
#

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
sleek hollow
digital rose
#

can you shw example

sleek hollow
jagged hill
#

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?

digital rose
sleek hollow
#

You're not creating an instance

sleek hollow
somber hemlock
#

also top level imports please

digital rose
#

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

digital rose
#

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

digital rose
#

fixed it

grand zenith
#

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?

wet vapor
#

i have a problem donwloading tdesigner does anyone know how i can fix this

somber hemlock
warped shuttle
#

how do i remove those line aroud the button

digital rose
#

Is there a way to select all widgets that are in a tab widget at same time?

#

nvm

winged mesa
#

hello, maybe someone knows Flet?

somber hemlock
winged mesa
#

i have couple questions:

  1. how can i delete check box
  2. how can i make newer text going up, and older going down, like:
    98
    99
    100
hexed horizon
#

@warped shuttle what module are you using

clever trout
#

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

sleek hollow
#

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

hexed horizon
#

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

plucky torrent
#

guys

#

i need help on github interface

clever trout
#

my friend tried to help in some way, but he didn't succeed

digital rose
#

How is -1073740791 an exit code 💀

#

Try pasting the full traceback @clever trout

jagged hill
#

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?

clever trout
digital rose
#

oh, hm

tribal path
#

Need a placeholder in the kv rule, or added to the python defined class

simple badger
#

also, 0xC0000409 is literally described as "It is an error"

proven basinBOT
#

: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.

somber hemlock
#

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...

narrow hedge
#

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

proud dune
#

There is currently a black box on the top part of the app

narrow hedge
#

'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()`

narrow hedge
#

including the bottom section, where the icons are present

proud dune
narrow hedge
#

well, that kinda did it, but...

proud dune
#

To change the background color of a ListBox, use songList.configure(background='black', foreground='white')

proud dune
#

It's background and foreground (That works on my environment)

narrow hedge
#

oh, that didnt change it man

narrow hedge
proud dune
#

Is the songList listbox element empty?

#

Try adding some content in it so we can see it's width and height

narrow hedge
#

nope, I this is the songlist songList = Listbox(root, background='black', foreground='white', width=100, height=15)

proud dune
#

Try adding songList.insert(1, "Test Value") after that line (songList = Listbox(...))

narrow hedge
proud dune
#

That top black box was the listbox, then.

narrow hedge
#

bro

narrow hedge
proud dune
#

Wait, are the button images transparent? Do they have white backgrounds?

sleek hollow
#

Your listbox is empty, that's why you aren't seeing anything

narrow hedge
#

but can I actually bring the listbox down?

#

Im actually using transparent icons too

proud dune
#

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!

sleek hollow
#

The order you pack things is the order they show up

proud dune
#

That is correct

sleek hollow
#

It's not the order you instantiate the class as you mentioned above

narrow hedge
#

Alr, so I gotta change the order

#

yeah?

narrow hedge
#

but, what actually want is to make the bg of the controlframe part to be black

#

and bring all the icons inside that

sleek hollow
#

well you didn't set the bg colour of that frame

#
controlFrame = Frame(root)
#
controlFrame = Frame(root, bg='black')
narrow hedge
#

oh yeah, mate, silly me

#

thanks, that actually did it

#

I dunno why, but I actually forgot that for a moment

thick lichen
#

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
next ridge
#

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

thick lichen
next ridge
# thick lichen

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

thick lichen
#

Yea this is what I had but Pycharm complains 🙄 Just wanted to make sure I was not miss understanding something 🤔

thick lichen
winged mesa
#

Hello i have question, How to get value of checkbox from FLET module?

next ridge
thick lichen
coral rover
#

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?

narrow hedge
#

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

narrow hedge
narrow hedge
sleek hollow
narrow hedge
#

Arent there any pre made widgets for this?

#

Or like any way to use a stylizing language, like css

sleek hollow
#

Yes, but nothing that looks exactly like this. A slider would be your closest option

narrow hedge
#

So, Ill have to program it, prolly

sleek hollow
#

most things require programming, yes

narrow hedge
#

Guess Ill have to figure that out now, `pithink

sleek hollow
#

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()
tribal path
#

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

devout badge
#

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 ?

frigid cave
#

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

sleek hollow
waxen halo
#

is the "only" difference between PyQt and PySide the licensing part?
Im a beginner and cant decide which one I wanna use 😄

sleek hollow
somber hemlock
waxen halo
#

What would be easier for a beginner?
And can I use Qt Designer / Creator for both?

somber hemlock
rocky dragon
#

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

royal atlas
#

Would this be the right channel to ask for help with a cli tool?

blazing pine
#

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?

twilit whale
#

could it also be having horizontalsidepolicy.sethorizontalpolicy(etc) vs horizontalsizepolicy?

blazing pine
#

oh whoops, that's a typo on my end when migrating my code to discord here, my mistake 🙏

twilit whale
#

no worries! im pretty new to everything but thought it could be that haha

blazing pine
#

haha pycharm would yell at a lot and my code would blow up when I ran it if that was actually the case

blazing pine
#

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...

somber hemlock
#

you can make them appear only when content overflows (default behaviour probably)

blazing pine
# somber hemlock what's the problem with scrollbars? they are inevitable

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)

somber hemlock
#

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.

somber hemlock
blazing pine
#

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…

next ridge
#
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

next ridge
#

Hmm ok, so this seems to happen only in wayland and not xwayland

blazing pine
#

Oh if running wayland, you may need to set some environment variable; I’ve had not great luck with wayland when working with PyQtGraph

somber hemlock
somber hemlock
next ridge
#

not sure if qt creator was updated too, I didn't pay attention

somber hemlock
#

heh unix ppl problems

next ridge
somber hemlock
#

it doesn't allow window positioning

blazing pine
#

try running QtCreator with -platform wayland ?

next ridge
#

gtk has been perfectly fine

#

even dialogs are opened centered

next ridge
somber hemlock
#

Gtk3 idk, won't be so good on Wayland

next ridge
#

@blazing pine for now, I'll just run it with QT_QPA_PLATFORM="xcb"
Will make a report tomorrow

next ridge
#

This is case sensitive for me

QFileDialog.getOpenFileName(self, filter="JPEG (*.jpeg)")

How can I make it not so?

somber hemlock
next ridge
#

ye, windows treat file association by extension insensitively

#

that's why i want similar behavior

somber hemlock
#

You can use this filter

"JPEG (*.jpeg, *.JPEG, *.jpg, *.JPG)"
next ridge
#

will it work for *.JpEg?

somber hemlock
#

No

somber hemlock
#

Even the Windows OS API (which is what Qt uses internally) doesn't allow for case insensitive filters

somber hemlock
somber hemlock
#

Crash your application when you detect such file names incident_actioned

#

Don't even bother calling some nice clean exit function like sys.exit. just do os.abort or something

waxen halo
#

is there an easy way to implement a QFileDialog into PySide6? I cant find anything in Qt Creator

royal gull
#

It's the sort of stuff you have to do in code though.

waxen halo
#

hmm okay, was hoping there is an way easier way 😄

royal gull
#

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.

waxen halo
#

Yea I think I’m gonna skip the QFileDialog for now and get my app running, after that I can still change some things

graceful gate
#

can someone recommend me some easy and scalable modules to make user-interfaces?

#

like able to use dbs and stuff with it

hexed horizon
swift cove
#

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?

sleek hollow
swift cove
#

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.

somber hemlock
#

Declare the FileDialog in your qml and use it there itself

sleek hollow
digital rose
#

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

digital rose
#

you think

#

i thought it was visual studio code

sleek hollow
#

vsc has this as default

digital rose
#

oh

grim rose
#

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)

serene badge
#

object has no attribute

somber hemlock
dire barn
#

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?

somber hemlock
#

If you need additional widgets you can wrap the webview in a tkinter window

sleek hollow
#

What do you mean by native widgets? There's QPdfView in pyqt6

somber hemlock
dire barn
somber hemlock
#

Pywebview uses cocoa on macos

dire barn
#

Yeah, as long as I only use that for the PDF viewing part..

somber hemlock
#

As a window renderer

sleek hollow
#

is cocoa the current macos? I know very little about mac, haha

somber hemlock
#

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

dire barn
swift cove
sleek hollow
somber hemlock
#

multiwindow is just an outdated concept tbh

sleek hollow
somber hemlock
#

you don't find it in newer apps, especially electron ones

sleek hollow
#

I think it entirely depends on what you're building

#

most VFX software thrive on multi window

somber hemlock
#

and newer ui libs generally implement navigation with pages and routers

somber hemlock
sleek hollow
#

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

somber hemlock
sleek hollow
somber hemlock
#

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

oak jackal
#

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 ?

dire barn
vagrant junco
#

can someone tell me its giving me an error if i add the selected line?

vagrant junco
#

can someone help me?

vagrant junco
#

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

somber hemlock
dire barn
mighty frigate
#

@dire barn why no Qt ?

dire barn
mighty frigate
#

possibly and ?

#

there's a problem with that ?

dire barn
mighty frigate
#

ok

long forum
#

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.

floral igloo
#

although I prefer qt designer and a model view structure, the ui file is seperate and generated by qt designer

mighty frigate
#

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.

queen trout
mighty frigate
#

tbh I prefer not using designers and write everything myself so I don't know much about that

lunar portal
#

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

next ridge
lunar portal
#

no

next ridge
#

well then there you go, problem solved

sleek hollow
#

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?

lunar portal
#

yea like that

#

i figured it out

next ridge
#

ah u just want to switch focus

lunar portal
#

had to focus next

somber hemlock
#

You can use Qt Design Studio as a Qt Designer replacement for QML, although you still will have to manually write some QML yourself

next ridge
#

btw, can I add custom widgets written in python to at creator's designer?

somber hemlock
#

Yes

next ridge
somber hemlock
next ridge
somber hemlock
#

and its super easy to create bindings

#

Not so easy in Qt Widgets

next ridge
#

I'll use qml if I do some other project in qt

somber hemlock
#

Qt Widgets really exposes only like half of the XML capability of UI files

somber hemlock
#

By using QQuickWidget for QMl stuff in your widgets application

next ridge
#

Ok

queen trout
#

The help message needs worked on, but im just getting things like auto-complete working

#

or suggestions

digital rose
#

I like it alot bro

#

I don't know much but I think it's very plainn

queen trout
#

1 sec. Ill show the full program

queen trout
#

It still has some small issues but I can hammer them out pretty easy

quartz dust
queen trout
#

This took months?

civic grove
#

help me guys

#

please

#

i dont know how to create a frame in tkinter

proud dune
#

Pretty nice, maybe you could make the width of the PIN textbox and increase the height of it?

hexed horizon
#

@digital rose what module are you using

quasi oxide
vagrant junco
#

could somone help me with a problem i have with tkinter and ttkbootstrap dm me pls

sharp mantle
#

has anyone here used kivy to develop and deploy mobile apps?

next ridge
#

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?

next ridge
quasi oxide
proven basinBOT
#

frontend/App.py line 19

# instantiate all frames```
quasi oxide
#

(please ping when answering)

hexed horizon
#

@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)

quasi oxide
#

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

sleek hollow
queen trout
quasi oxide
#

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)

hexed horizon
#

@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)

quasi oxide
#

Thanks, I got it working with grid though

hexed horizon
#

ok cool

quasi oxide
#
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)

Added these 2 lines to root tk.Tk

hexed horizon
#

yeah that works too

queen trout
#

or itemChanged

#

I dont think ot has a clicked connection

upper sinew
#

What is the best TUI framework / library in python atm?

dire barn
proven basinBOT
upper sinew
#

let me check thanks

#

wait textual actually comes with shit ton of widgets

#

still cannot catch the spirit of what i want

somber hemlock
next ridge
# queen trout use the clicked connection
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)

queen trout
#

import Qcursor from QtGui

#

then use the Qcursor.pos()

#

I just had this issue like 5 mins ago lol

next ridge
queen trout
#

yup np

#

very cool gui btw

next ridge
#

thanks, tried qt for the first time

queen trout
#

did you use the designer?

next ridge
#

ye

queen trout
#

yeah same

#

I got my gui made, I just have to fix the full screen and stretching now

#

which is gonna suck

next ridge
#

I got issues with centering stuff too, I just use spacers and set max width for widgets as a workaround for now

queen trout
#

I dont even have a layout, everything is static lol

#

so...pain

next ridge
#

just use stacked widgets for different pages

#

That chat app ui is fine as a sepearate window tho

queen trout
#

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

next ridge
#

but it's being a mess for me too, settings alignment for one page, sets for all of them, Idk why

queen trout
#

yeah im not sure, I tried resizing one page and it would just change the others

#

yup

#

thats why I switched

next ridge
queen trout
#

yeah I use OBS now, it's just a pain to setup. Bandicam takes like 5 seconds to fit thr screensize I need

next ridge
#

The text I'll be copying to clipboard is not part of self

#

can't modify the method params either

queen trout
#

just make a self.text statement

next ridge
#

how would I bind it to self if I can't even access it?

queen trout
#

wait what line

next ridge
#

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

queen trout
#

check the methods with dir

#

oh wait

#

are you trying to get the text of the table?

#

like the selected row?

next ridge
#

ye

queen trout
#

ah 1 moment, let me go through my code

next ridge
#
        # 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

queen trout
#

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

next ridge
#

that's not the problem

#

the problem is that I need to access the model data

queen trout
#

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

next ridge
#

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())
    )
)
...
queen trout
#

Ah nice!

queen trout
#

welp, time to remake this with a layout

next ridge
queen trout
#

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

next ridge
#

Found it

if ret == QMessageBox.StandardButton.Yes:
    ...
else:
    ...
#

my lsp stops working every now and then, making it hard to explore the qt api

queen trout
#

Also, my horiz stretch does nothing

next ridge
queen trout
queen trout
#

the spacing

#

it should be autofillings but its broken

next ridge
#

ah

queen trout
#

im just gonna restart I think

#

it just keeps getting worse

next ridge
#

what widget is this?
allowing you to move em

queen trout
#

Qt Designer

#

wait, widget?

#

List

next ridge
#

lol I didn't even see that u were inside the designer

#

thought this was inside the app

queen trout
#

nope. You can move them around tho

next ridge
#

is this form layout?

queen trout
#

its grid. And a mix

next ridge
#

i see

next ridge
#

love qt6 on wayland

queen trout
#

lol

#

whats wayland?

next ridge
queen trout
#

ah.

#

I like that cursor btw

next ridge
next ridge
queen trout
#

finally got the layout

#

almost

queen trout
#

Okay

#

final UI I think. Might add some icons etc but this is gonna be the main look

jolly flower
queen trout
pseudo trout
#

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?

next ridge
#

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)
rigid star
queen trout
#

I'm guessing resizing and location issues also

mighty rover
#

@digital steeple

#

Pls

warm sonnet
#

guys I can't install tkinter by pip

somber hemlock
queen trout
#

Got backgrounds to work

next ridge
next ridge
pastel lotus
#

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

somber hemlock
#

You can create frameless windows with tkinter

pastel lotus
#

Thx

somber hemlock
#

The overlay part tho

#

Some software don't like it

#

So they can do stuff like killing your process or hiding the gui themselves

pastel lotus
#

I'm using it on Bluestacks

#

But I'll see what happens

pastel lotus
#

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

digital rose
#

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

digital rose
somber hemlock
#

ahh.. that shitty linter

#

why the hell do people still use it

queen trout
#

how does it look so far though? Any suggestions

next ridge
#

damnit i hate ci cd bs

digital rose
next ridge
#

it fails at the last step

next ridge
#

except for some visual bugs in jupyter notebook

next ridge
#

i figured it out thanks to the very very obvious error message

jolly verge
#

if you use pack/grid, set padx and pady to 0 (or remove them)

pine glen
#

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

sleek hollow
#

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

mint grove
#

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

#

it has the flutter concept to develop apps

#

but in pythons which im so thankfull for

#

Tkinter is shit

#

after i tried this

sleek hollow
#

what don't you like about pyqt?

mint grove
#

iam just saying that flet is better than them in options you get

#

it has multiplatfrom support too

pastel lotus
#
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.

placid steeple
#

Anyone know any good videos on how to learn to use tkinter

hexed horizon
#

@placid steeple just use documentation/online tutorials, it's much more convenient and efficient

next ridge
#

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?

median junco
#

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?

median junco
#

I'm going to bed. IF anyone has any comments please @ me or private message me, thank you

next ridge
#

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

solar void
#

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

hexed horizon
#

@median junco what ide/engine are you using

somber hemlock
#

Must be something in threading

next ridge
somber hemlock
placid steeple
#

Do you have any ones you can reccomend to me

next ridge
hexed horizon
#

@placid steeple tutorialpoint and geeksforgeeks both have some nice articles you can follow

somber hemlock
#

Or cross platform

next ridge
somber hemlock
#

seems like c++ qt has a QtSingleApplication which has no such thing in pyside or pyqt

next ridge
placid steeple
next ridge
#

it works but idk if I should use it

hexed horizon
#

and if you do learn tkinter you should aslo probably know customtkinter, since it looks way nicer and more modern

somber hemlock
next ridge
somber hemlock
#

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

placid steeple
#

im learning tkinter to learn how to use customtkinter

#

I've been using this as a basis for learning it

hexed horizon
#

real python is great

placid steeple
#

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

hexed horizon
#

if you have specific problems, tutorialspoint is helpful for that

placid steeple
#

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

placid steeple
hexed horizon
#

can you paste your code

placid steeple
#

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

hexed horizon
#

hmm

#

make a button

#
button = tk.Button(window, text='text box', command = lambda:text_box(window)
button.pack()
placid steeple
#

ok

#

i made a button

hexed horizon
#

when the button gets pressed the command should execute

weary vector
#

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

weary vector
#
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)

placid steeple
#

thank you

hexed horizon
weary vector
#

the site said it was config bruh wtf 💀

hexed horizon
#

config and configure are essentially synonymous

pearl meteor
#

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

weary vector
#

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)```
pastel lotus
#

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

median junco
static cove
# pastel lotus Like why can't I just say Home.Frame when I'm in the Menu class

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?

static cove
# weary vector no one?

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.

weary vector
#

alright

#

at least that makes 2 lines to change instead of like 30

weary vector
#

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

cedar turret
hexed horizon
queen trout
#

@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

bronze iron
true vault
#

Hello

fringe sorrel
#

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?

steep ledge
#

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.

sleek hollow
novel shell
#

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

sleek hollow
#

This could be done using pyqt

fringe sorrel
hexed horizon
#

@fringe sorrel have you tried changing the color of your label/window?

fringe sorrel
#

yeah

fringe sorrel
muted hazel
# weary vector does pyglet accept otf files and not just ttf files? there is a font that i want...

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

GitHub

pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications. - pyglet/pyglet

GitHub

pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications. - pyglet/pyglet

weary vector
quaint needle
#

I need help making a UI compatible with asyncio.

hexed horizon
#

@fringe sorrel i use windows so i'm a little confused but is that the command window or the root window?

past jacinth
hexed horizon
hexed horizon
#

can you screenshare in a vc just so i can get an idea of what's going on

queen trout
past jacinth
#

Thx

queen trout
# past jacinth Thx

If something doesnt work let me know. I've been having weird issues when pushing to git

past jacinth
#

K

proven basinBOT
#

: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.

proven basinBOT
#

: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.

ruby cape
#

pov you add 100 lines of codes without testing anything and it works first try

#

😌

rigid star
#

[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?

rigid star
burnt breach
#

how do i add blurs to my qt project?

#

like blur effects

#

glow effects

#

ect?

umbral wigeon
magic dome
digital rose
#

hey guys i need some help

#

what app is this youtuber is using? i find it very clean

#

please ping if you know, thanks!

sleek hollow
digital rose
#

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

sleek hollow
#

nah, that's definitely not VSC

#

I use Sublime Text, this is 100% what it is

#

I don't use that colour scheme though

digital rose
#

ahhh really?

sleek hollow
digital rose
#

so i'm using the IDLE

sleek hollow
#

I use this colour scheme

digital rose
#

well the font looks weird

sleek hollow
#

in idle?

digital rose
#

small thing i'm working on

#

sometimes it's annoying when you can't edit something at the same time if you want

sleek hollow
digital rose
#

so that's i was thinking to change

#

yo

#

it looks the same now damn

sleek hollow
#

yes, it's definitely sublime

digital rose
#

I see

#

so is it free like IDLE?

sleek hollow
#

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

digital rose
#

for my lil project i'm gonna need that a lot

#

but thank you so much man

#

:)

sleek hollow
#

you don't really need input() if you're using GUI

digital rose
#

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

rigid star
#

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?

burnt breach
inland wedge
#

have you heard of the lord and saviour gtk4

rigid star
#

[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.)

rigid star
#

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.

tribal path
#

rubber duck debugging so common there's a term for it

primal tinsel
#

what module should i import to make UI?

#

anyone?

proven basinBOT
#

: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.

long thorn
#

how can i apply rounded corners in a Image in gtk-3?

hexed horizon
turbid quiver
#

can someone help on these i have been trying to but it not working i have install dorker compose

serene furnace
#

any qtile fans out there?

digital rose
#

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?

digital rose
#

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

rocky crescent
#

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...```
inland wedge
#

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

whole spruce
#

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.

hexed horizon
burnt breach
sudden elk
#

someone knows if tk supports draggables?

#

like qt support on discord is dead and i think tk have right now more support :/

sudden elk
#

yeah, asked but no response

#

anyway

#

are draggables in tk?

burnt breach
#

like dragging windows into other windows

#

and grouping windows?

sudden elk
#

like i'd like 2 containers to drag content from 1 to 2 with lists

#

in one window

burnt breach
#

i dont use tk but ill try to see if there is documentation for this

sudden elk
#

i could throw you something similar in qt cause i have designer app but tk is more supported as its builtin

burnt breach
sudden elk
#

i want to use tk

burnt breach
sudden elk
#

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

sudden elk
burnt breach
sudden elk
#

yep

burnt breach
sudden elk
#

will see cause im too dumb for qt designer and in tk i already made apps…

burnt breach
#

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

sudden elk
#

like theme i dont care but even qt designer is hard af for me (and where coding all that…)

woven lava
#

Hello everyone, I'm learning python, which IDE would you recommend to a backend dev in training?

inland wedge
#

i prefer writing the ui using code, bc then i can implement dynamic behaviour with ease

inland wedge
woven lava
inland wedge
# woven lava Hey, thanks for your swift response, I haven't used anything before I'm in a car...

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

sharp adder
#

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
sudden elk
#

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)

sudden elk
#

and also being able to count how much buttons are generated?

cyan quiver
#

Is kivy still pretty much the go to for mobile development without html/css/js?

sudden elk
sleek hollow
sudden elk
#

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

sleek hollow
#
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

sudden elk
#

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)
sleek hollow
#

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

sudden elk
#

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)

sleek hollow
#

auto wrapping widgets is actually quite a complex problem to solve. I recommend just using some sort of scrolling widget or fixed grid