#user-interfaces

1 messages · Page 73 of 1

sharp stone
#

I tried but there is many attributes in real and I need to handle that automatically

unique forge
tribal path
#
class Design(App):
    def __init__(self, **kwargs):
        super(Design, self).__init__(**kwargs)
        self.main_hero = MainHero() # Tried main_hero = MainHero() too
        self.val = StringProperty(self.main_hero.nick)
``` isn't how you use props
```py
class Design(App):
    val = StringProperty()
    def __init__(self, **kwargs):
        super(Design, self).__init__(**kwargs)
        self.main_hero = MainHero() # Tried main_hero = MainHero() too
        self.val = self.main_hero.nick
unique forge
#

if you want to

#

use electron.js with html and css

#

or you can use html, css, and python eel

#

or you can use Qt, Kivy, and other frameworks

spark prism
#

ok

tawdry mulch
sharp stone
tribal path
#
    def rename(self):
        # self.app.main_hero.nick = "Renamed"
        self.app.val = "Renamed"

Or move the Prop

worthy ridge
#

@coarse mirage use a style sheet

#

@coarse mirage ```
/* LBT_PSB_groupsearch */

    QPushButton#LBT_PSB_groupsearch{
        background-color: $ui-01;
        color: $link-01;
        border: 1px solid Transparent;
        
        border-radius: 2px;
        background-image: url(':/icon_pack/png/16/search_icon-02.png');
        background-position: center;
        background-repeat: no-repeat;
    }

    QPushButton:disabled#LBT_PSB_groupsearch{
        background-color: $disabled-02;
        color: $disabled-03;
        border: 1px solid Transparent;

        border-radius: 2px;
        background-image: url(':/icon_pack/png/16/search_disabled-02.png');
        background-position: center;
        background-repeat: no-repeat;
    }

    QPushButton:hover#LBT_PSB_groupsearch{
        background-color: $active-ui;
        color: $hover-primary-text;
        border: 1px solid Transparent;
        
        border-radius: 2px;
        background-image: url(':/icon_pack/png/16/search_icon-01.png');
        background-position: center;
        background-repeat: no-repeat;
    }

    QPushButton:checked#LBT_PSB_groupsearch,
    QPushButton:pressed#LBT_PSB_groupsearch {
        background-color: $active-ui;
        color: $hover-primary-text;
        border: 1px solid $ui-01;
        
        border-radius: 2px;
        background-image: url(':/icon_pack/png/16/search_icon-01.png');
        background-position: center;
        background-repeat: no-repeat;
    }
spark prism
#

ok

ivory ember
#

How does one apply a QLinearGradient to a QTabWidget tab. I tried ```py
self.main_background_gradient = qtg.QLinearGradient(0, 0, self.width(), self.height())
self.main_background_gradient.setColorAt(0, qtg.QColor("#30cfd0"))
self.main_background_gradient.setColorAt(1, qtg.QColor("#330867"))
self.main_background_gradient_brush = qtg.QBrush(self.main_background_gradient)
self.main_background_palette = qtw.QApplication.instance().palette()
self.main_background_palette.setBrush(qtg.QPalette.Base, self.main_background_gradient_brush)
self.notebooks_tab.setPalette(self.main_background_palette)

#

the self.notebooks_tab is the widget assigned to one of the tabs on the main QTabWidget

zenith epoch
#

anyone who is familiar with qt designer can help me? i want to change the colour of main window but not the tool bar

queen mist
#

Hi

#

im currently working on a TKinter maze game

#

im trying to get my restart button to work

#

but it doesn't want to

#

anyidea how i can do this?

#

i need it to destory the canvas than

#

start the program from the beggining

#

rn it destorys canavs

#

idk how to make it start the whole code again

#

i can't have it in a whole new function i think im not sure

queen mist
brittle bolt
#

that way someone has an idea of what your doing

proven basinBOT
#

Hey @queen mist!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

queen mist
#

¬code-blocks

tawdry mulch
zenith epoch
queen mist
#

restart button

#

code above ^

jagged frigate
#

is curses in python system independent?

open lintel
#

is this correct?

proven basinBOT
#

Hey @open lintel! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

hushed night
#

UI's are kinda sus

#

lol

tawdry mulch
#

@hushed night Why so :0

hushed night
tawdry mulch
#

Cool thought 😄 @hushed night

hushed night
#

😂

hybrid spindle
#

Anyone know how to identify what subplot you are accessing during event handling in matplotlib/pyqt?

So if you have a click event and a 6x2 subplot figure. How could one determine which subplot is being clicked on?

tawdry mulch
hybrid spindle
#

Thought that was kinda odd.

#

Im just working with the standard pyplots though

digital rose
#

whyyy

#

Yo how do I change the dimensions of my treeview

eager beacon
#

Do you want the entire treeview's size to change or the items within?

digital rose
#

Nope I actually fixed it :)

eager beacon
#

ah good

digital rose
#

I just transformed it at its ".pack" and ".place"

#

statements thing

eager beacon
#

yep, it sounds like that would do the trick

digital rose
# queen mist can anyone help with this?

@queen mist how do you want to restart the app? If you just want to remove everything you can use .destroy() on the canvas and then re draw the canvas with the same arguments you passed in the first time.

#

This is where classes come in handy for me, i just delete the current instance of the class and create a new one, that acts like a restart function.

tawdry mulch
digital rose
#
database.tag_configure("light", background = "white")
database.tag_configure("dark", background = "light blue")

Noloops = 0
for content in Column_Labels:
    if Noloops%2 == 1:
        database.insert(parent='', index = 'end', iid = Noloops, text = "", values = ("lol", "2", "xd"), tags = ("light",)) 
    if Noloops%2 == 0:
        database.insert(parent='', index = 'end', iid = Noloops, text = "", values = ("lol", "2", "xd"),  tags = ("dark",)) 
    Noloops += 1
```yo why does this function not work anymore?
tame breach
#

Sorry DaRoque, I'm a tk newb and can't help you. I'm guessing you trying to alternate the highlighting of columns. At the very least it looks like your loop is set up correctly, so beyond that IDK.

#

Proving my noobishness, my question is, with the following code:

text.tag_add("start", "1.8", "1.13")
text.tag_config("start", background="black", foreground="green")

is text.tag_add making "start" a variable that is holding the location of 1.8/1.13? and in the next line, is config using that range to apply the formatting? I assume that is happening but the documentation is kinda vague so I wanted to be sure. Thanks.

queen mist
digital rose
#

look at this example, to demonstrate how i like to use classes, it even works for the restart thing you want:

from tkinter import *
from time import sleep

class Window(Tk):
    def __init__(self):
        Tk.__init__(self)
        self.draw_widgets()

    def draw_widgets(self):
        self.restart_but = Button(self, text = 'restart', command=self.restart_app)
        self.restart_but.pack(side='top')

    def restart_app(self):
        self.destroy() # destroys the main window.
        sleep(1)
        new = Window() ; new.mainloop()

if __name__ == '__main__':
    root = Window() ; root.mainloop()
#

it restarts the window after a time delay of 1 second. @queen mist

#

classes are the best, majorly because they are properly structured, and it's the best practice to use classes.

queen mist
#

ima start using them, they look neat ^

jagged frigate
#

is curses in python system independent?

digital rose
# tawdry mulch What is wrong

Well there is an existing function that makes a treeview have striped details so that it would be much easier to read at, but that function does not work anymore for some reason ;-;

#

Are there any other working functions that does the same thing that works?

digital rose
tawdry mulch
#

Obviously there is no thing default. I don't see what is wrong. What is wrong, does it not show? Does it give an error? Does it freeze? @digital rose

tawdry mulch
hybrid spindle
#
class TopLevelWindow(QtWidgets.QMainWindow):
    def __init__(self,Abs):
        super().__init__()
        self.canvas = MplWidget(Abs)
        self.setCentralWidget(self.canvas)

class MplWidget(FigureCanvasQTAgg):
    def __init__(self,Abs, parent=None):
        f = Figure()
        super(MplWidget, self).__init__(f)
        self.setParent(parent)
        
        #plot stuff here

        def onclick(self,event):
          if event.button == 1:
            #update plot with stuff        

So this is the base of my code. Curious how I would automatically update the figure once conditions are met. Currently itll only update if I move the window around

digital rose
#

this is what i get with

def cmd():
    os.system('cmd.exe')
cmd_button = Button(homee, text="💻CMD", font=("impact", 20), bg="gray33", borderwidth=1, fg="orange", command=cmd)
cmd_button.place(x=350, y=150)
#

pls ping me

digital rose
#

The proggram is crashing anf the cmd is not opening

tawdry mulch
#

Hmmmm my assumption is it takes some time to execute that command and hence the freeze.

#

I also think, you are looking for os.system('start cmd.exe') @digital rose

tawdry mulch
lucid halo
#

Can we merge electronjs with python or are there any other thing like that in python

unique forge
#

Python EEL combines HTML, CSS and Python

tribal path
#

!pypi eel

proven basinBOT
#

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

lucid halo
#

oh coool thx

tame breach
#

@tawdry mulch Sorry for the late reply, but thank you for your help. Trying to wrap my brain around tk with some tutorials.

versed vessel
#
generate_new = tk.Button(root, text = 'Generate new bits', command =gen_bits_function)

def sort_bits(bits_sort):
    bits_sorted = bits.sorter(bits_sort)
    sorted_bits = tk.Label(root, text = str(bits_sorted)).pack()

def gen_bits_function():
    global gen_bits
    gen_bits = bits.generate()
    generated_bits.forget
    generated_bits = tk.Label(root, text = 'Generated bits: ' + str(gen_bits)).pack()

Why does it says that my function does not exist?

#
File "C:\Users\A\Desktop\list\main.py", line 17, in <module>
    generate_new = tk.Button(root, text = 'Generate new bits', command =gen_bits_function)
NameError: name 'gen_bits_function' is not defined
```
tawdry mulch
tawdry mulch
lofty pond
tawdry mulch
#

Eel is pretty cool, ngl

tame breach
tawdry mulch
tame breach
#

lol, my bad. My questions about

text.tag_add("start", "1.8", "1.13")```
and if start was a variable or not.  I guess I could have said pseudo-variable for TK use.
tawdry mulch
versed vessel
tawdry mulch
versed vessel
#

I tried it and it worked lol

#

thanks

tawdry mulch
#

What is the best widget for showing items fetched from a database (like a table) with qt quick? Any idea?

eager beacon
#

Most apps that display tables from a database use a tableview

hybrid spindle
#

anyone have any thoughts on why the button_press_event handling will connect/work but my key_press_event wont register?
Took out all the functionality, but onclick is definitely connected and working in the actual code

class MplWidget(FigureCanvasQTAgg):
    def __init__(self,Abs, parent=None):
        f = Figure()
        self.fig = f
        self.wc = None #initialize overall parameter
        super(MplWidget, self).__init__(f)

        self.setParent(parent)

        #do some plot stuff

        # Set up connectivity
        self.cid1 = self.mpl_connect("button_press_event", self.onclick)
        self.cid2 = self.mpl_connect("key_press_event", self.onpress)
    def onpress(self,event):
        #do keyboard pressy stuff
    def onclick(self, event):
        #do clicky stuff



class TopLevelWindow(QtWidgets.QMainWindow):
    def __init__(self,Abs):
        super().__init__()
        self.canvas = MplWidget(Abs)
        self.setCentralWidget(self.canvas)

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    w = TopLevelWindow(Abs)
    w.resize(1300,850)
    w.show()
    sys.exit(app.exec_())

hybrid spindle
coarse mirage
#

I'm working in PyQt5 and trying to have it so that when a button is click the animation playing on the label is changed. However, it doesn't work:

        Main_Window.screen.sprite = Animations.confident
        print ("Hello.")
        
    def screen(self):
        sprite = Animations.normal
        gif_background = QLabel(self)    
        gif_background.setGeometry(40, 60, 107, 100)
        gif_background.setStyleSheet("background-image : url(C:/Users/nomar/Dropbox/Blueprints/Background.jpg);")
        gif_background.movie = QMovie(sprite)
        gif_background.setMovie(gif_background.movie)
        gif_background.movie.start()
    
        
    def textbox(self):
        text = QLabel ("Welcome to the Dice Game!", self)
        text.setGeometry(165, 30, 300, 100)
        text.setStyleSheet("color: white")
        text.setFont(QFont('Advanced Pixel-7', 16))
        
class Animations:
    normal = "C:/Users/nomar/Dropbox/Blueprints/Trucy_Normal1.gif"
    confident = "C:/Users/nomar/Dropbox/Blueprints/Trucy_Confident_Speak1.gif"```
worthy ridge
#

@coarse mirage use stylesheets property selector

#

And u need to declare the image in the resource pack of the app

coarse mirage
eager beacon
coarse mirage
eager beacon
#

are you trying to toggle the image every time the button is pushed?

coarse mirage
eager beacon
coarse mirage
#

Basically I'm going to be making a dice game and depending if the user wins or lose that will change how the sprite reacts.

#

Assigning it via button press is more of a "test"

coarse mirage
eager beacon
#

@worthy ridge already gave you the good advice on how to handle it, I think you should take their advice.

eager beacon
#

if won:
sprite = 'gif1'
else:
sprite = 'gif2'
movie = QMovie(sprite)

#

....

#

I still think you should use the properties that were suggested earlier, or QStateMachine

coarse mirage
#

I'll look into thanks.

left thistle
#
# Since there are 12 months in a year, these are the final days for each month in order
days = (31, 28, 31, 30, 31, 31, 30, 31, 30, 31, 30, 31)

def main(): 
    __name__
    menu()
    stepTracker()

def menu():
    print('Here is your workout information for the year: ')
    
def stepTracker():
    stepCounter = open('steps.txt', 'r')
    monthCount = 0
    for num in range(0, 12):
        totalSteps = 0
        count = 0
        average = 0
        for count in range(0, days[monthCount]):
            steps = int(stepCounter.readline())
            totalSteps = totalSteps + steps
            average = totalSteps / days[monthCount]
        print('The average steps taken for the month of ' +  month[monthCount] + ' is:' + format(average, ',.1f') + 'steps.')
        monthCount = monthCount + 1

main()```
#

how do I implement a GUI in my code?

tawdry mulch
left thistle
#

yeah ive used tkinter, am kind of unfamiliar with it

tawdry mulch
tawdry mulch
worthy ridge
#

@coarse mirage set lable properts in pythons and the use that property to change the css

civic lava
#

hi how do i open a image and open it in a canvas using tkinter

#

hi how do i open a image and open it in a canvas using tkinter

ivory ember
digital rose
# civic lava hi how do i open a image and open it in a canvas using tkinter

@civic lava i would suggest using PhotoImage() to open image files.

from tkinter import *

root = Tk()
image=PhotoImage(file='/path/to/image.png')
c = Canvas(root) ; c.pack(side='top', expand=True, fill='both')
c.create_image(100, 100, image=image)
root.mainloop()

just replace /path/to/image.png with the actual path of the image.

tawdry mulch
#

Keep in mind though, tk.PhotoImage can not open 'jpg' images @civic lava

thorny crescent
#

If someone created a python & Electron app then would the final version of the app need to have python integrated in it?

eager beacon
#

I don't see why you would need to include python. Assuming you're using python for something like a backend server with cherry py or flask.

#

though since electron makes it easy to bundle cross-platform apps I don't see a reason not to include python

prime patio
hybrid spindle
#
class mainWindow(QtWidgets.QTabWidget):
    def __init__(self,Abs, parent=None):
        self.Abs = Abs
        super(mainWindow,self).__init__(parent)
        
        self.tab1 = QtWidgets.QWidget()
        self.addTab(self.tab1,'First Ions')
        self.fig = Figure()
        self.canvas = FigureCanvasQTAgg(self.fig)
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.canvas)
        self.tab1.setLayout(layout)
        
        if len(self.Abs.ions) > 6:
            self.fig2 = Figure()
            self.tab2 = QtWidgets.QWidget()
            self.addTab(self.tab2,'Additional Ions')
            self.canvas2 = FigureCanvasQTAgg(self.fig2)
            layout2 = QtWidgets.QVBoxLayout()
            layout2.addWidget(self.canvas2)
            self.tab2.setLayout(layout2)

  #do app stuff

if __name__ == "__main__":
    import sys


    app = QtWidgets.QApplication(sys.argv)
    main = mainWindow(Abs)
    main.resize(1300,850)
    main.show()
    sys.exit(app.exec_())

So I was trying to change the style of my lil app. And noticed changing the style did absolutely nothing. Is this due to not putting anything in a frame, so its essentially just opening up tabbed pyplot windows and theres no Qt frame for me to edit the style?

  1. putting this in a frame, will it change any of the functionality from the event handling with mpl?
  2. without putting it in any container, do I have any sort of options to change the window style or add a save button or anything else?
#

looking a bit boring currently

#

Also is there a way to change the tab's appearance? Couldn't find any documentation or questions related to modifying that

worthy ridge
#

@hybrid spindle dm me i have a style sheet

fair vine
#

hey all, i'm trying to make my first GUI using Tkinter for my todo list

#

is anyone here an expert and able to provide me with some help?

#

this stressing me out lol

digital rose
fair vine
#

i'm trying to make my todo list into a GUI

#

with a text entry where the user can input their to-do items and an 'add item' button that puts the text entry onto the item list

digital rose
fair vine
#

im trying to make a listbox now

#

wait what have i missed, not defined tkinter

#

but normally this works

#
import tkinter as tk

win = tk.Tk()


listbox_tasks = tkinter.Listbox(win, height=3, width=50)
listbox_tasks.pack()


win.mainloop()
digital rose
#

It should be tk.Listbox

#

Since you've imported tkinter as tk.

#

@fair vine

fair vine
#

im dumb

#

thankyou lol

#

thats why u dont copy paste from ur last one

#

lol

digital rose
fair vine
#

dw

#

im trying to make the entry hold on

#

sorry taking me ages lol im bad

digital rose
#

You can post the code here. !paste

#

!paste

proven basinBOT
#

Pasting large amounts of code

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

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

fair vine
#

@digital rose

#
import tkinter as tk

win = tk.Tk()

def add_task():
    task = entry_task.get()
    listbox_tasks.insert(tk.END, task)

listbox_tasks = tk.Listbox(win, height=3, width=50)
listbox_tasks.pack()

entry_task = tk.Entry(win, width=50)
entry_task.pack()

button_add_task = tk.Button(win, text="Add Task", width=48, command=add_task)
button_add_task.pack()

win.mainloop()
#

i have this so far

#

but i'm getting this error - AttributeError: type object 'Listbox' has no attribute 'Entry'

#

nvm fixed it

#

how would i go about making a listbox widget that shows all items in my list?

digital rose
#

You can run a for loop that goes through your list and appends items in the listbox.

tawdry mulch
#
import tkinter as tk

win = tk.Tk()

lst = [1,2,3,4,5]
listbox_tasks = tk.Listbox(win, height=3, width=50)
listbox_tasks.pack()

listbox_tasks.insert('end',*lst)

win.mainloop()
#

Also keep in mind, these height and width are not pixels.

plush stream
#
QPushButton{border-image: url(C:/Users/Kevin/AppData/Roaming/vlc/art/artistalbum/James Arthur & Anne-Marie/The Greatest Showman_ Reimagined/art.jpg); background-color: transparent;}

somehow this gave me an error

#

Could not parse stylesheet of object QPushButton(0x28893a31500)

#

but i couldn't see anything wrong with the qss script

eager beacon
#

its because of the &

plush stream
#

ah, hold on.

#

you need to pass the path like a string in python using the double quote

#

now it works

#

i just get used to pass in the path without the double quote which usually works

eager beacon
#

Yeah there are some characters that require it. I'm not sure if you could use some sort of html escape without the quotes but its probably just easier to make sure there are quotes when you have something other than underscores/hyphens and slashes

plush stream
#

yeah makes sense

eager beacon
#

Apparently all you need is a backslash before if you're doing it without quotes. \&

plush stream
#

I'm still going to use the double quote because i want to pass a variable to the url();, not a constant

eager beacon
#

Are you changing the entire stylesheet of the button or something?

plush stream
#

yes

#

I'm using the button to display track album art

eager beacon
#

Oh, gotcah.. I just thought I somehow overlooked a way to use variables within a stylesheet.

plush stream
#

haha no

#

and another cool thing i did is change the dropshadow color according to the album art

eager beacon
#

Is that with the qgaphics effect applied to the button?

plush stream
#

yes

eager beacon
#

if you decide to add other graphics effects you should keep an eye on your CPU usage. I think there is some sort of bug in Qt that causes them not to be discarded properly or something. I had an app that I used a couple of them in and after having it open for awhile the python process would slowly creep up to 100%

#

it stopped when I removed the effects

#

but I do like how the effect matches the art

plush stream
#

huh, interesting. though fortunately i hadn't encountered that problem

#

the cpu usage is averaging on 2 - 4% usually and 32% max

#

it only jumps up when resizing

eager beacon
#

thats actually pretty good. Is that when playing a track?

plush stream
#

yes!

eager beacon
#

nice

tawdry mulch
#

I think instead of using QML and linking with python it is rather more easier to use PyQt right. Python as a backend for QML seems just time consuming idea.

modern marsh
#

yes

#

but StyleSheets have a problem

#

they can't be changed easily during runtime

tawdry mulch
#

Hmmmm, I see

worthy ridge
#

@plush streamu need to compile it into a resource back to use images in stylesheet and the path is not CSS compatible no spaces

polar wave
#

tkinter: hi! what event triggers when the cursor position changes in a textbox?

modern marsh
#

wait so, QSS is basically CSS?

digital rose
# polar wave `tkinter`: hi! what event triggers when the cursor position changes in a textbox...

cursor position changes, either when you insert a character in the text box, or you navigate through the text with the arrow keys. take a look at this example, which makes use of the "<KeyRelease>" event to check for cursor position whenever you let go of any key on the keyboard.

from tkinter import *

def check_cursor(event):
    cursor_pos = event.widget.index('insert') # returns position of the cursor in this format: 'line.column'
    print(cursor_pos)

root=Tk()

t=Text(root, font=('DejaVu Sans Mono', 15, 'normal'))
t.pack(side='top', fill='both', expand=True)
t.bind('<KeyRelease>', check_cursor)

t.focus_set() # adds focus to the text widget.

root.mainloop()
digital rose
#

a really decent hack would be to use the built - in event '<<CursorChange>>' to check for any cursor position changes, as well, you might call that a lazy solution.

stoic jackal
#

is there anyway to make a radio button deselectable in tkinter?

digital rose
chrome sail
#

I need some help with tkinter

#

Please?

#

Help

#

I just need the piece of code that allows you to save and load Image files

tawdry mulch
#

Use filedialog to load

chrome sail
#

Hwo do i specify the filetype

#

The thing is, i know how to add a save button, and save a file, but i don't know how to load, or specify the file type...

tawdry mulch
#

Use the filetype option

#

filedialog.askopenfilename(filetype=[('jpeg','*.jpeg')])

#

What?

chrome sail
#

TY alot!!!

tawdry mulch
#

Hmmhmm xd

tawdry mulch
chrome sail
#

TY ALOT

plush stream
modern marsh
#

Ah I see

chrome sail
#

How do we define the IMage file type?

tawdry mulch
#

What is IMage

tawdry mulch
arctic frigate
#

hi so i have this line
self.button0 = Button()

#

but some reason when i later print self.button0, its a NoneType

tawdry mulch
#

Because your code is like self.button0 = Button().pack(). @arctic frigate

arctic frigate
#

i have self.button0.grid() on the next line

#

i dont use pack

tawdry mulch
#

Can you show some more code? @arctic frigate

#

!code

proven basinBOT
#

Here's how to format Python code on Discord:

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

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

arctic frigate
#

yeah one sec

worthy ridge
#

U can get most of the widgets covered

#

I use resources pack and the theme is like generated using a pallete so the sheets have placeholders

plush stream
#

Thanks!

proven basinBOT
#

Hey @arctic frigate!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

arctic frigate
#

heres the code

#

if anyone else could help, that would be great

lime monolith
arctic frigate
#

its called in the constructor

lime monolith
arctic frigate
#

oh i see that now

stoic jackal
#

how do i disable an entry i ntkinter? rn im doing ```py
month_entry = Entry(top).grid(row = 4, column = 2)

if before_or_since.get() == 3:
month_entry.config(state = 'disabled')

else:
month_entry.config(state = 'normal')

#

i get the error ```py
month_entry.config(state = NORMAL)
AttributeError: 'NoneType' object has no attribute 'config'

#

i tried doing month_entry.config(state = 'DISABLED') and month_entry.config(state = DISABLED)

#

i also tried month_entry.configure(state = 'disabled')

lime monolith
stoic jackal
#

basicly im trying to make it so when a radio button is selected the entry becomes disabled

#
from tkinter import *


top = Tk()

day = StringVar()
month = StringVar()
year = StringVar()
before_or_since = IntVar()

top.geometry('600x600')

title = Label(top, text = 'Email Sorter', font = ("Arial", 20, "bold"), relief = 'solid', padx = 10, pady = 5)

label2 = Label(top, text = 'Select Options', font = ("Arial", 16, "bold"))

before_label = Label(top, text = 'Select Either Before or Since', font = ("Arial", 12), justify = 'center', pady=30).grid(row=3, column=1)

before_rb = Radiobutton(top, text='Before', value = 1, variable = before_or_since).grid(row=3,column=2)

since_rb = Radiobutton(top, text='Since', value = 2, variable = before_or_since, justify = 'left').grid(row=3,column=3)

none_rb = Radiobutton(top, text='None', value = 3, variable = before_or_since, padx = 60).grid(row=3,column=4)


since_label = Label(top, text = 'Enter a Date', font = ("Arial", 12), justify = 'center').grid(row=4, column=1)

month_entry = Entry(top)
month_entry.grid(row = 4, column = 2)

quit_button = Button(top, text = "QUIT", font = ("Arial", 12, "bold"), fg = "black", relief = "groove", command = exit)


title.grid(row = 1, column = 2, pady = 20)

label2.grid(row = 2, column = 2, pady = 20)

if before_or_since.get() == 3:
    month_entry.config(state = 'disabled')

else:
    month_entry.config(state = 'normal')

top.mainloop()
tawdry mulch
stoic jackal
digital rose
#

helo can anyone pls help me with cx_freeze and pyqt5

tawdry mulch
tawdry mulch
#

and call the function after u hv typed something inside the entry

#

or whatever

stoic jackal
#

tysm

lime monolith
# stoic jackal whats that?

You have called the disable code before the gui event loop is running, you need to react to events in the GUI like the radio button click happening and then update the GUI in the event handler.

stoic jackal
digital rose
# digital rose helo can anyone pls help me with cx_freeze and pyqt5

i am trying to convert my qt5 project to exe using cx_freeze but its converts successfully and even runs it but i duno why whenever i click on any widget it crashes, now i noticed it doesn;t happen when i remove the base from the cx_freeze setup file```python
target=Executable(
script="main.pyw",
base="Win32GUI",
icon="icon.ico"
)

lime monolith
stoic jackal
#

before right?

digital rose
stoic jackal
digital rose
#

ah ok ty

lime monolith
# stoic jackal before right?
from tkinter import *


top = Tk()

day = StringVar()
month = StringVar()
year = StringVar()
before_or_since = IntVar()

def an_event_handler():
    if before_or_since.get() == 3:
        month_entry.config(state = 'disabled')

    else:
        month_entry.config(state = 'normal')

top.geometry('600x600')

title = Label(top, text = 'Email Sorter', font = ("Arial", 20, "bold"), relief = 'solid', padx = 10, pady = 5)

label2 = Label(top, text = 'Select Options', font = ("Arial", 16, "bold"))

before_label = Label(top, text = 'Select Either Before or Since', font = ("Arial", 12), justify = 'center', pady=30).grid(row=3, column=1)

before_rb = Radiobutton(top, text='Before', value = 1, variable = before_or_since, command=an_event_handler)
before_rb.grid(row=3,column=2)

since_rb = Radiobutton(top, text='Since', value = 2, variable = before_or_since, justify = 'left', command=an_event_handler)
since_rb.grid(row=3,column=3)

none_rb = Radiobutton(top, text='None', value = 3, variable = before_or_since, padx = 60, command=an_event_handler)
none_rb.grid(row=3,column=4)


since_label = Label(top, text = 'Enter a Date', font = ("Arial", 12), justify = 'center').grid(row=4, column=1)

month_entry = Entry(top)
month_entry.grid(row = 4, column = 2)

quit_button = Button(top, text = "QUIT", font = ("Arial", 12, "bold"), fg = "black", relief = "groove", command = exit)


title.grid(row = 1, column = 2, pady = 20)

label2.grid(row = 2, column = 2, pady = 20)


top.mainloop()
worthy ridge
#

@digital rose try logging the app

digital rose
worthy ridge
#

Because sometimes qt supresses errors

digital rose
#

oh alright ima use the logging module then and reconvert to exe

worthy ridge
#

Yeah and log to a file

#

I use nautika for this purposes

digital rose
#

nautika?

#

its a module

worthy ridge
#

Nope like it is used to make exes and freeze

digital rose
#

ah aight

digital rose
worthy ridge
#

I dk much about cx

digital rose
#

aoh, so should i use nautika to convert to exe?

#

is it gud

#

@worthy ridge i logged the app behavior and it output an error, but duno wut this means cuz i didn;t get this whne running the py file

worthy ridge
#

I nwex code

digital rose
#

when i run the .py file it works fine

digital rose
worthy ridge
#

Need

digital rose
#

ah ok

#

the function that output the error

worthy ridge
#

Ur missing an encoding attr

#

Btw u should subcalass the uo code

digital rose
#

i wrote an api to download animes and implemented into the gui, the self.api is the api

digital rose
#

mmmmmm @worthy ridge r there any other packages to convert py to exe

#

no pyinstaller

#

:-:

worthy ridge
#

Nuitka

digital rose
#

aoh aight ima gib it a try

digital rose
#

pip install Nuitka?

#

ok it works

#

umm ok install done how do i use it

#

@worthy ridge can u tell me pls how do i use nuitka?

#

i'm getting this error

#

ima search on yt

#

but ty for the help

unique forge
#

.topic

buoyant cometBOT
#
**What's the most impressive Desktop Application you've made with Python so far?**

Suggest more topics here!

unique forge
#

.topic

buoyant cometBOT
#
**Do you perfer Command Line Interfaces (CLI) or Graphic User Interfaces (GUI)?**

Suggest more topics here!

tawdry mulch
tawdry mulch
unique forge
hybrid mantle
tawdry mulch
hybrid mantle
#

But CLI it not bad

tawdry mulch
hybrid mantle
hybrid mantle
tawdry mulch
hybrid mantle
#

Thks

#

The project is: the user install a script in his computer, in a GUI he enter his informations (nbre of prossesors, nbre of hearts, nbre of RAM,ect)

#

After that, we test his bandwidth et we deduct a price from its configuration

#

After, we will have to be able to make the computers talk to each other without going through a server

#

Sometimes our brain ignites

#

.topic

buoyant cometBOT
#
**What's your favorite CLI (Command Line Interface) or TUI (Terminal Line Interface)?**

Suggest more topics here!

tawdry mulch
tawdry mulch
polar wave
tawdry mulch
#

Hmmmm I could not get it too @polar wave

digital rose
polar wave
digital rose
polar wave
#

yea... that was a problem for me... but using <KeyRelease> and <KeyPress> worked and i didn't get any issues.

digital rose
#

When using Key

polar wave
#

yea...

digital rose
polar wave
#

oh ok.

#

i have another question though.

#

How do I make the textbox fill all the unused space? i'm using the grid system btw

digital rose
polar wave
#

like it filling the whole column and stretching to the end of the window.... but configuring the columns and rows doesnt seem to work

digital rose
polar wave
#

can i use pack with grid though?

digital rose
#

Im pretty sure tkinter would throw a TclError saying that you cannot use pack when widgets are rendered using grid.

polar wave
#

it still doesn't stretch....

polar wave
#

sorry, just found the problem....

digital rose
#

so it could be better to use both of them throughout the app.

amber roost
#

I never found much of a reason to use place and tbh pack feels quite uncontrollable to me.
Makin cells resize with grid is possible, although more annoying than with place. All cells start out with a default row/column weight of 0, which means they will grow as large as their contained widgets demand and no more. You need to set the weight to something larger than 0 by calling w.grid_columnconfigure(0, weight=1) and w.grid_rowconfigure(0, weight=1), which will cause widget w's grid column 0 and row 0 to expand whenever w should resize; so to apply that to the textbox, call these methods of the text's parent widget and target the row/col that contains the text widget. You'll need to grid the text with sticky="nsew" as well to make it stick to the edges of its container cell and grow with it. [ @polar wave ]

plush stream
#

anyone have any idea how to style the QTableWidget/QTableView in qss? couldn't find any details from the doc on how to do it.

eager beacon
#

What do you want to do?

plush stream
#

edit the headers

eager beacon
#

This is from one of my old projects maybe it will help

QHeaderView {
    font-family: "Open Sans Light";
    font-size: 14px;

}

QHeaderView::section {
    height:39px;
    font-size: 14px;
    padding-left: 5px;
    padding-bottom: 0;
    padding-top: 0;
    border: 1px none #ccc;
    border-bottom: 1px solid rgb(40,43,45);
    border-left: 1px solid rgb(53, 57, 59);
    background:rgb(84,89,99);
    color:#fff;
}

QHeaderView::section:first:horizontal {
    border-left: none;
    border-right: none;
}

QHeaderView::section:last:horizontal {
    border-right: none;
}

QHeaderView::section:first:horizontal {
    border-left: none;
    border-right: none;

}
plush stream
#

just trying to match the style

eager beacon
#

ah yeah I think you should be able to get that changed.

#

let me know if you find out a way to set/resize the width of the columns when the window resizes in an intelligent way. I gave up on it and just used stretch on the last column

plush stream
#

oh i have a crude (but working flawlessly) solution for that

#

hold on

eager beacon
#

oh?

#

alright

plush stream
eager beacon
#

Yeah I think thats pretty much it

plush stream
#
    def resizeEvent(self, event):
        self.playtable.setColumnWidth(0, int(self.playtable.width() / 4))
        self.playtable.setColumnWidth(1, int(self.playtable.width() / 4))
        self.playtable.setColumnWidth(2, int(self.playtable.width() / 4))
        self.playtable.setColumnWidth(3, int(self.playtable.width() / 4))
#

so it's taking the QTableWidget's width and then divide it with the number of column you have

eager beacon
#

Yeah I think I tried something like that, my problem was if I changed the width on one of the cols manually It was hard to get that one to stay the sameish percentage without a bunch conditionals and making the resize kind of laggy/jumpy when I changed the size of the window after

#

and without those conditionals it was infuriating when I resized

plush stream
#

I've tried many different way to do it but none of them works/broken. this is the closest i can get to what i want

eager beacon
#

Yeah I think I tried a couple of different things but it was never quite right

#

I need to sit down one day when and figure it out... I bet if i read the docs more closely it would be easy to figure out

plush stream
#

we all know reading the docs is boring 🙂

#

but sometimes it saves you a hell lot of time

eager beacon
#

It would save so much more time if PySide/PyQt generated doc strings

polar wave
#

Tkinter: How do you make the window like what you get when you have the tear-off set as True in a window? I'm talking about this but I don't know what it's called.

plush stream
#

tear off menu? iirc

polar wave
#

yes, but it's a window that you can customise.

digital rose
#

helo can anyone help me with nuitka, how can i include my modules to the package

#

during conversion

digital rose
#

sed

digital rose
#

This attribute only works on Windows.

polar wave
#

oh, thanks! im going to try it later. does it work on TopLevel too?

digital rose
#

Yes.

polar wave
#

nice!

wise epoch
#

How can I keep pyqt5 window on top even if I focus to another window

eager beacon
#

set a window flag with Qt.WindowStaysOnTopHint

lean oak
#

Hello

#

Anyone help me in python Tkinter, I am a newbie, 🙏🙏

digital rose
lean oak
#

from tkinter import *
root = Tk()
root.geometry("500x220+500+200")
root.title("Reverse number Game")
root.configure(background='light green')

heading = Label(root, text="Welcome to mind Game ", fg='black', font='arial 15 bold').grid(row=0, column=3)

def secondPanel():

FirstMove = Label(root, text="First Move", font='arial 10 italic').grid(row=1, column=2)

Player1 = Label(root, text="Player 1 :", fg='black', bg='red').grid(row=1, column=2, pady=20, padx=5)
Player2 = Label(root, text="Player 2 :", fg='black', bg='red').grid(row=2, column=2, pady=10, padx=5)

Player1Name = StringVar
Player2Name = StringVar

p1Entry = Entry(root, textvariable=Player1Name).grid(row=1, column=3, padx=50)
p2Entry = Entry(root, textvariable=Player2Name).grid(row=2, column=3, padx=50)

submit = Button(root, text="Start",command=secondPanel).grid(row=4, column=3)

root.mainloop()

#

As soon as click on btn, player2 label and p2entry should disapper

#

How can I do it

digital rose
#

!code

proven basinBOT
#

Here's how to format Python code on Discord:

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

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

lean oak
#

What happed? I don't understand

digital rose
#

use backticks to show code (`)

#

that makes it a bit more readable.

lean oak
#

How can I do it?

#

Off it, focus on code

digital rose
#

ok, anyways, to make a widget invisible you can say:

Player2.pack_forget()
# and
p2Entry.pack_forget()

but your widget handling is quite poor, once you create the widget and use .grid() in the same line, the widget becomes a NoneType object, so put the grid in a separate line.

wise epoch
digital rose
#

further more, you can bind that to a button, you can use it as a command, and associate the command to the button:

def make_invis():
    Player2.pack_forget()
    p2Entry.pack_forget()

submit = Button( .. .. ., command= make_invis)
. .. .. . 
do not change the rest of the code
#

@lean oak

lean oak
#

Yees

#

Wait let me check

plush stream
#

ayo check this out, i found a qss editor that apply your stylesheet in realtime. it even has autocomplete suggestions. might be handy

#

oh and it allows you to use variables within qss

lean oak
digital rose
eager beacon
#

or at least it wasn't about a year ago

plush stream
#

ooops

#

hopefully it has improved

tawdry mulch
#

It should be Player1Name = StringVar() and so on...

digital rose
tawdry mulch
plush stream
digital rose
tawdry mulch
#

I did not say to use StringVar(), if your using it, use it properly atleast

#

At any point use set() or get(). Its pointless, it will give error

digital rose
#

i do know he hasnt said StringVar(), and instead has said StringVar.

#

its from a general perspective.

tawdry mulch
#

I never use StringVar()

#

unless I want to use trace().

#

Or when using a grouped widget

eager beacon
tawdry mulch
digital rose
lean oak
#

Thats ok

digital rose
#

or else the class wont be instantiated.

lean oak
#

I want help, plz viseur I have already placed grid in new line, but same error

digital rose
tawdry mulch
#

Why are you using a StringVar(), to get the values right, just try Player1Name.get()

lean oak
#

If you have some time

#

Can I call u

#

It would be more easy to describe my issue

digital rose
plush stream
eager beacon
plush stream
#

maybe

#

i didn't check the exact path

digital rose
#

a general question, how is syntax highlighting handled in real time in IDEs? because seemingly highlighting text on key presses makes it a bit slower.

#

at least in python.

eager beacon
plush stream
#

oh

#

it could be also that because i think it crashed when i typed using rgba

eager beacon
#

Yeah, I cant remember every crash but I do remember thinking it would be pretty cool if it wasn't so unstable.

plush stream
#

there is however a more stable alternative that i found

eager beacon
#

and dont even think about using a palette color as a variable!

plush stream
#

what do you mean?

tawdry mulch
digital rose
tawdry mulch
#

IDLE is made in tkinter, AFAIK

digital rose
tawdry mulch
#

You mentioned IDE, not IDLE

eager beacon
plush stream
#

oh

digital rose
plush stream
#

i like idle for quick script

digital rose
#

and when i say IDE it can be any, out of the ones created in the world.

tawdry mulch
#

The IDE I use is VS Code maybe you should search out what all IDE exists out there

digital rose
tawdry mulch
#

IDLE is one of the many, not the only one. Pretty sure VS Code is not done in Python

digital rose
#

my question was about "handling syntax highlighting in real time" not - "tell me about IDEs" @tawdry mulch .

eager beacon
#

There are several IDEs that are made with Python

tawdry mulch
digital rose
tawdry mulch
#

Kinda reminds me, there is an library for syntax highlighting with python

eager beacon
#

QScintilla

plush stream
#

has anyone tried pyside6 yet

eager beacon
#

yes, missing a lot of basic stuff

tawdry mulch
#

Has a version for python? @eager beacon

eager beacon
#

like QImage formats

plush stream
#

im looking for QtWinExtras but i hadn't find it

tawdry mulch
eager beacon
#

yeah, 6.2 is the goal for most of the missing stuff I think

#

there is a blog post somewhere that has a roadmap

plush stream
#

oh okay

#

i thought the classes were relocated or something

tawdry mulch
#

Shouldnt they have done it together at first version itself? @eager beacon _

chrome sail
tawdry mulch
#

Well he meant, that Menu() has a tearoff=True option, to replicate that effect on a window @chrome sail

#

Well depends

tawdry mulch
#

Usually *.jpg and *.png does it

chrome sail
#

Upper or Lower-case?

tawdry mulch
#

Well, try both :p

tawdry mulch
chrome sail
#

It still won't ope

#

Any files

tawdry mulch
#

share that line of code @chrome sail

chrome sail
#
def saveFile():
    ProPixelSave = filedialog.asksaveasfile(filetype=[('jpg','*.jpg')])

tawdry mulch
#

Tis wud open all jpg files

tawdry mulch
chrome sail
#
def openFile():
    ProPixelOpen = filedialog.askopenfilename(filetype=[('jpg','*.jpg')])

#

Thnx imma try!

tawdry mulch
#

The first part of the tuple is what you see down there, the second part of the the tuple is the file extension to choose from

tawdry mulch
plush stream
#

what are you guys tryna do

tawdry mulch
#

Who!! @plush stream

digital rose
stoic jackal
#

How do I reduce the amount of space between each column in tkinter? I have to fit 7 widgets in one row

#

I tried using sticky and padx

tawdry mulch
#

Can u show us an example @stoic jackal

#

columnspan seems like the obvious guess

stoic jackal
#
month_entry = Entry(top, width = 2)
month_entry.grid(row = 4, column = 3)
month_label = Label(top, text = 'Month', font = ("Arial", 10)).grid(row=4, column=2)

day_entry = Entry(top, width = 2)
day_entry.grid(row = 4, column = 5)
day_label = Label(top, text = 'Day', font = ("Arial", 10)).grid(row=4, column=4)


year_entry = Entry(top, width = 4)
year_entry.grid(row = 4, column = 7)
year_label = Label(top, text = 'Day', font = ("Arial", 10)).grid(row=4, column=6)
#

it runs off the screen

stoic jackal
tawdry mulch
stoic jackal
#

okay

stoic jackal
#

i want them to be next to each other

#

and the year part runs off the screen

#

also columnspan did not work

tawdry mulch
#

there is so much empty space

#

can you post full code

#

!paste

proven basinBOT
#

Pasting large amounts of code

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

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

tawdry mulch
#

I think some widget above is using all those extra space @stoic jackal

stoic jackal
#

okay

#

I cant past full code tho

#

ill use the paste thing

tawdry mulch
#

Kay

stoic jackal
tawdry mulch
#

Try

#
title.grid(row = 1, column = 2, pady = 20, columnspan=6)
 
label2.grid(row = 2, column = 2, pady = 20, columnspan=6)

@stoic jackal

#

The rest of space is due to padx.

stoic jackal
#

so the title and label2 were taking up space?

tawdry mulch
#

well the column number depends on how many columns you want to include within it

stoic jackal
tawdry mulch
#

Though I would follow PEP8, while writing code

#

it keeps your code neat

stoic jackal
#

oh so the column was being "stretched'

tawdry mulch
stoic jackal
#

PEP8? Interesting ill check it out

stoic jackal
eager beacon
versed vessel
#

Can i use any font that its installed in my PC with tkinter?

eager beacon
versed vessel
#

Ok ok

tawdry mulch
#

But while sending it to someone else, there will be issue.

proven basinBOT
#

lstbox.py line 10

pyglet.font.add_file('fonts/coolvetica compressed rg.ttf') # Add the task font```
versed vessel
#

Pyglet is a library i need to import?

tawdry mulch
#

You need to install it first @versed vessel

tawdry mulch
#

Issue means, the font wont load and default font will be used. If you check that repo, you can see how I used custom fonts

#

you can even download the app and try it and see the fonts work

versed vessel
#

Ok ok

#

I'll try it

proven basinBOT
#

lstbox.py line 37

font=('coolvetica compressed rg',30), tag='text') #250,25```
tawdry mulch
#

Yea exactly, but make sure the name of the font is the NAME of the font

#

not the name of the font file

#

See the Font Name is Roboto

#

That is what you have to use

versed vessel
#

Its is working! Thanks a lot!

tawdry mulch
versed vessel
#

Hmm, i can commit it to github and you can try it if you want

tawdry mulch
versed vessel
tawdry mulch
#

Yea, all cool

versed vessel
#

Nice!

#

The widgets are in different order because i did some things with the grid before commiting but the font works, thanks a lot!

hybrid spindle
#

So I have the following within my main app:

        def saving(self):
            print('clicked')
            pdb.set_trace()

        button = QPushButton("SAVE",self)
        button.setGeometry(550,30,200,30)
        #pdb.set_trace()
        button.clicked.connect(saving(self))

Unfortunately immediately upon running the program, it prints 'clicked' and calls the debugger. Why doesnt it wait for me to actually click the button to execute the 'saving' function?

tawdry mulch
#

Wait, what. How can you pass in self, it is not a method

#

Do you really need to pass self to saving?

hybrid spindle
#

I did want to access components saved in self.

tawdry mulch
#

Then make it a method

#

keep it in same indentation level as __init__

#

Then button.clicked.connect(self.saving)

#

But before all this, do give button.clicked.connect(lambda: saving(self)) a try

tawdry mulch
# hybrid spindle that did it!

Though, try accessing some elements with self and see if it works. It just seems like a very weird way. Rather creating a method seems more conventional (?)

modern marsh
#

wdym by creating a method

tawdry mulch
#
class Foo:
  def __init__(self):
    pass
  def this_is_a_method(self):
    pass
hybrid spindle
tawdry mulch
modern marsh
tawdry mulch
#

The methods?

modern marsh
#

@hybrid spindle what class have you inherited

modern marsh
tawdry mulch
#

Because you can call the methods from anywhere inside and outside the class

modern marsh
#

eh outside not so easily unless its static

tawdry mulch
#

After initialization of the object?

#

Like

modern marsh
#

Yeah

tawdry mulch
#
app = Foo()
app.this_is_a_method()
modern marsh
#

Yes

tawdry mulch
#

Like that it is usefull 😄

modern marsh
#

A lambda ensures that this does not happen

modern marsh
tawdry mulch
#

Hah!

#

So to conclude @hybrid spindle, When calling or assigning functions, dont use (), that will call the function directly. If the function has no parameters, then just type the func name, else use lambda or partial.

modern marsh
#

You can pass self in a function depending on what self is

#

Thats why I asked what class you inherited

tawdry mulch
#

Hmmmm, not sure

spring ibex
#

In tkinter I'm trying to allow users to select serial ports to use and open

#

I've managed to locate and add all the code to find and add the serial ports into a combobox

#

but I'm wondering how can I use the user selection in opening the serial port

tawdry mulch
#

How do you open a seriel port? @spring ibex

#

serial.Serial() something I guess?

spring ibex
tawdry mulch
#

Yea

#

but what is the code used to open? So i can give an example

spring ibex
tawdry mulch
#

What is wrong there

spring ibex
#

I don't know how to open the serial port with the selected com port

tawdry mulch
spring ibex
#

It's a combobox and I'm wondering how do I use the selection from the combobox to open a serial port

tawdry mulch
#

You get the selection with get(). That is implemented correctly. Opening a port is not tkinter, so...

#

Google it? @spring ibex

tribal coral
#

What's a good way to keep code organized when working with GUIs? Using PyQT and my code is an absolute mess. I'm trying to refactor it and put it into a class of some sort, but just not sure how everything would work at that point.

tawdry mulch
#

@spring ibex

spring ibex
#

Thanks

lime monolith
tribal coral
#

you want me to send the file, or something like pastebin?

lime monolith
tribal coral
#

like 100 lines, but probably over discord limit of 2k characters

#

first time messing with GUIs, so some imports might be useless and code might be a mess

#

but here

lime monolith
tribal coral
#

Alright

#

I'll be looking around to hopefully get an idea

proven basinBOT
#

Pasting large amounts of code

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

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

lime monolith
tribal coral
#

what are *args and **kwargs

#

and the -> None

#

never seen any of those

lime monolith
# tribal coral never seen any of those

-> None is a type hint my IDE added it, its not necessary you can remove it.
*args and **kwargs allows you to pass multiple arguments and keywords, rather than stating the specific required ones.

tribal coral
#

whats the point of unspecified arguments?

lime monolith
tribal coral
#

i see

#

didnt know that was a thing

lime monolith
tawdry mulch
#

I installed PySide6, not bad move right

remote grail
#

Hey guys i have a question. How do you install .Git files on Debian after cloning them

sudden coral
#

What are .git files? Git repositories aren't "installed". Also, you're in the wrong channel. If you have a question about git, please ask in #tools-and-devops

arctic frigate
#

hi, so i have a while loop at the end of my tkinter file with the update_idletasks() and update() methods in them

#

i also have so input conditionials from keypresses and it seems that the input is kind of delayed or sometimes does not get registered when pressed

#

any way to resolve this?

tawdry mulch
#

root.mainloop() is an alternative of update() and update_idletasks() used together inside a infinite loop.

arctic frigate
#

well i needed stuff inside the main loop so i used a while loop with those 2 commands

#

one sec

#
while True:
    if a1.play == False:
        if GPIO.input(switches[0]):
            if a1.button == 0:
                a1.button = 3
            else:
                a1.button -= 1
        if GPIO.input(switches[3]):
            print('f')
            if a1.button == 3:
                a1.button = 0
            else:
                a1.button += 1
        if a1.button == 0:
            a1.button0['bg'] = 'red2'
            sleep(.1)
        else:
            a1.button0.config(bg='white')
            sleep(.1)
        if a1.button == 1:
            a1.button1.config(bg='red2')
            sleep(.1)
        else:
            a1.button1.config(bg='white')
            sleep(.1)
        if a1.button == 2:
            a1.button2.config(bg='red2')
            sleep(.1)
        else:
            a1.button2.config(bg='white')
            sleep(.1)
        if a1.button == 3:
            a1.button3.config(bg='red2')
            sleep(.1)
        else:
            a1.button3.config(bg='white')
            sleep(.1)
        if GPIO.input(switches[4]):
            a1.commands[a1.button]()
        
    a1.update_idletasks()
    a1.update()
#

it works, but i either have to hold the button down or i press it and there's a delay

#

i know its meh coding design but its for my final project and i kinda through it together bc it's due tomorrow

#

@tawdry mulch

#

i also have a portion of the code in pygame and the buttons do not have a delay in the pygame loops

modern marsh
#

Pyside6 is currently on Qt 6.1 ig

polar wave
#

tkinter: hi! how do i prevent insert() adding a new line when triggered?

polar wave
#

yes

digital rose
polar wave
#

wait for a sec

digital rose
# polar wave wait for a sec

In any case, by default the text widget is configured to add a newline at the end, so right after you use insert, you can say this:

text.insert(..)
text.delete('end-1c', 'end')
polar wave
#

ty! im going to try it.

digital rose
#

end-1c means: 1 character before the end of the text widget. So when the text widget inserts a new line, it uses the escape code \n, which is one char.

polar wave
#

ok, that's handy. thanks!

digital rose
# polar wave ok, that's handy. thanks!

No problem. Another thing, when using indices like insert or end, you can use +n chars or -n chars for any positive integer n, to access some number of characters before or after that index.

polar wave
#

nice! ty!

digital rose
#

hi

modern marsh
#

Hello

jovial lava
#

iihiii

tawdry mulch
tawdry mulch
polar wave
#

someone just pinged me....

tawdry mulch
polar wave
#

oh, it's fine. thanks tho 🙂

zenith epoch
#

any idea how i can i make a fixed, frameless window draggable, dont want to resize

#

in pyqt5

tawdry mulch
#

In QML, I had to set some flag and set the min and max height and width to the same dimension. @zenith epoch

#

It would be same with PyQt5 also, maybe?

plush stream
#

you can use the setFixedWidth and setFixedHeight function in pyqt/pyside to set a fixed width to your window

tawdry mulch
plush stream
#

and use Qt.WA_FramelessWindowHint for frameless window

zenith epoch
#

mouse area?

#

i made the window frameless and fixed

#

just need to make it draggable

plush stream
tawdry mulch
zenith epoch
plush stream
#

oh also talks about qt

#

i've been facing this issue recently

#

where i tried to change the color of the QScrollBar

#

but it's displaying these weird pattern

#

it's sort of invisible when the color white is applied because it blends

#

but when it's set to darker color, it became visible

#

any idea why?

#
QScrollBar:vertical {
    background: rgb(57, 63, 82);
    border: 0px solid #666666;
    width: 15px;
    margin: 0px;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: -2px;
    padding-right: -2px;
}
modern marsh
zenith epoch
modern marsh
#

np

ivory ember
#

does anyone know what the supported video formats are available for QVideoWidget

#

i have searched the docs in QMediaContent, QMediaPlayer, and of course, QVideoWidget and could not find anything

#

any ideas, maybe I missed something?

tawdry mulch
#

Windows: DirectShow
Linux: gstreamer

MAC/iOS: AV Foundation (IIRC all that also QuickTime can play)

NO GUARANTEE FOR CORRECTNESS:

supported video file formats: QuickTime Movie (.mov), MPEG-4 (.mp4, .m4v), MPEG-2, MPEG-1, 3GPP, 3GPP2, AVCHD, AVI, DV;

supported video codecs: MPEG-2, MPEG-4, H.264, H.263 H.261, Apple ProRes, Apple Pixlet, Animation, Cinepak, Component Video, DV, DVC Pro 50, Graphics, Motion JPEG, Photo JPEG, Sorenson Video 2, Sorenson Video 3, H.263, H.261, Apple ProRes, Apple Pixlet, Animation, Cinepak, Component Video, DV, DVC Pro 50, Graphics, Motion JPEG, Photo JPEG, Sorenson Video 2, Sorenson Video 3

supported audio file formats: M4A, m4b, .m4p, MP3, Core Audio (.caf), AIFF, AU, SD2, WAV, SND, AMR

supported audio codecs: AAC, HE-AAC, Apple Lossless,MP3, AMR Narrowband, MS ADPCM, QDesign Music 2, Qualcomm PureVoice (QCELP), IMA 4:1, ALaw 2:1, ULaw 2:1, Integer (24-bit, 32-bit), Floating Point (32-Bit,64-Bit)

@ivory ember

ivory ember
#

?

#

source

tawdry mulch
ivory ember
#

thanks amigo

tawdry mulch
ivory ember
#

ig i gotta implement checking the supported codecs 😁

tawdry mulch
ivory ember
#

yessir

shell sleet
#

Hello!

#

I need some help in Tkinter

#

Anyone ready to help?

digital rose
autumn badge
#

anyone here play with remi? i am trying to run a few of the example apps and i keep getting an error on any app with a button. anything with a onclick.do throws the error Method 'onclick' has no 'do' member

#

shit. apparently it works in IDLE but not VSC

tawdry mulch
#

What is the code

tawdry mulch
autumn badge
#

as much as i like VSC, it is becoming a PITA

tawdry mulch
#

Why would VSC throw an error that doesnt exist

#

I recommend to show the code, let some1 take a look @autumn badge

autumn badge
#
class MyApp(App):
    def __init__(self, *args):
        super(MyApp, self).__init__(*args)

    def main(self):
        container = gui.VBox(width=120, height=100)
        self.lbl = gui.Label('Hello world!')
        self.bt = gui.Button('Hello name!')
        self.bt2 = gui.Button('Hello name surname!')

        # setting the listener for the onclick event of the buttons
        self.bt.onclick.do(self.on_button_pressed, "Name")
        self.bt2.onclick.do(self.on_button_pressed, "Name", "Surname")

        # appending a widget to another
        container.append(self.lbl)
        container.append(self.bt)
        container.append(self.bt2)

        # returning the root widget
        return container

    # listener function
    def on_button_pressed(self, widget, name='', surname=''):
        self.lbl.set_text('Button pressed!')
        widget.set_text('Hello ' + name + ' ' + surname)

# starts the web server
start(MyApp)```
#

the self.bt.onclick.do(self.on_button_pressed, "Name") throws the error in VSC

autumn badge
worthy ridge
#

@plush stream change add page and sub page sub control

hoary venture
#

I want to make a simple tax calculator app can someone help me?

shell sleet
#

Hello, i have a gui with few widgets which are inside a function ,I want to remove(forget)all the widgets when a function is called

orchid saffron
#

don't know if this is the right place to ask but does anyone know if it is possible to interact with closed captions on a google meet(google classroom application)? for example, could you look for a word in the CC and when it pops up, say it's "apple" the code would output something?

autumn badge
#

possible if Google has an API for it

orchid saffron
#

is there a source where I could check if they do? If not, do you think something could be adapted, maybe a screen recording that could be scanned perhaps?

autumn badge
#

i dunno. maybe goolge it? #irony

#

i think google has a site where they list all of the APIs they have

orchid saffron
#

oh alright, I will try that. what do you think about the feasability of the second option? maybe use something similar to the CC tech to look for specific words?

autumn badge
#

what is your end goal for it? light a light if "apple" is said?

orchid saffron
#

anything really, I would like to make an simple program that can recognize the words in the closed captioning and if a certain words is there, give an output

#

a primitive version might just to add the word to a list and count how many times it it said

#

but you could easily expand this

autumn badge
#

some light reading

orchid saffron
tawdry mulch
tawdry mulch
hoary venture
tawdry mulch
hoary venture
#

looks like this

shell sleet
hoary venture
tawdry mulch
tawdry mulch
hoary venture
#

Total amount*Tax Percentage

autumn badge
#

so if you have a 10% tax you will want to set the total to
total = amount + (amount*tax)

plush stream
tawdry mulch
worthy ridge
tawdry mulch
worthy ridge
#

Look up my style

hoary venture
tawdry mulch
#

!code

proven basinBOT
#

Here's how to format Python code on Discord:

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

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

hoary venture
#

ok

autumn badge
tawdry mulch
#

@autumn badge Out of curiousity, why are you not importing the library

hoary venture
#
expr=""
def calculate_due():
    intxt = float(Amount_Entry.get())  
    txt=float(Tax_Entry.get())
    if intxt !="":
        Totaldue= intxt*txt
       
        Due_Entry = Label(window, fg = "white", bg = "black", font = "Aleo")
        Due_Entry.place(x=150, y=120)

        
    else:
         messagebox.showwarning(window,text=" Stop!""Please enter a value")
   
    
window=Tk()

window.title("Windows TaxApp")
window.configure(bg="black")
window.geometry("300x200")
Total=StringVar()
Percent=StringVar()


lbl1=Label(window,text="TAX CALCULATOR",fg="white",bg="black",font="bold")
lbl1.place(x=80,y=5)

lbl2= Label(window, text="Total Amount:       $",fg="white",bg="black",font="Calibri")
lbl2.place(x=25,y=40)

Amount_Entry= Entry(window,textvariable=Total)
Amount_Entry.place(x=160,y=40,width=50)

lbl3= Label(window,text="Tax Percentage: ",fg="white",bg="black",font="Calibri")
lbl3.place(x=25,y=80)

Tax_Entry= Entry(window,textvariable="Percent")
Tax_Entry.place(x=150,y=80,width=50)

lbl4= Label(window,text="Total Due: ",fg="white",bg="black",font="Calibri")
lbl4.place(x=25,y=120)

# Due_Entry= Label (window)
# Due_Entry.place(x=150,y=120,width=70)

btn1= Button(window,text="COMPUTE",bg="white",fg="black",command= calculate_due)
btn1.place(x=100,y=160)

window.mainloop()
tawdry mulch
#

Try this @autumn badge

#
import remi.gui as gui
from remi import start, App

class MyApp(App):
    def __init__(self, *args):
        super(MyApp, self).__init__(*args)

    def main(self):
        container = gui.VBox(width=120, height=100)
        self.lbl = gui.Label('Hello world!')
        self.bt = gui.Button('Hello name!')
        self.bt2 = gui.Button('Hello name surname!')

        # setting the listener for the onclick event of the buttons
        self.bt.onclick.do(self.on_button_pressed, "Name")
        self.bt2.onclick.do(self.on_button_pressed, "Name", "Surname")

        # appending a widget to another
        container.append(self.lbl)
        container.append(self.bt)
        container.append(self.bt2)

        # returning the root widget
        return container

    # listener function
    def on_button_pressed(self, widget, name='', surname=''):
        self.lbl.set_text('Button pressed!')
        widget.set_text('Hello ' + name + ' ' + surname)

# starts the web server
start(MyApp)
autumn badge
#

think i might have found the source of the problem

tawdry mulch
#

Tadaa

#

Open the json and give the path of your python interpretter

tawdry mulch
#

Do you realize that you have not set the text for the label?

hoary venture
tawdry mulch
#
Due_Entry = Label(window, text=Totaldue, fg = "white", bg = "black", font = "Aleo")
hoary venture
#

ok

autumn badge
hoary venture
#

OMG THANKYOU SO MUCH GUYS

autumn badge
#

it worked though

#

weird

hoary venture
#

YOU GUYS ARE REALLY HELPFUL

tawdry mulch
autumn badge
#

oh......im pretty sure i have

tawdry mulch
#

Ok then send the ENTIRE code

tawdry mulch
autumn badge
#

wait, what di dyou add?

tawdry mulch
#
import remi.gui as gui
from remi import start, App
autumn badge
#

oh shit. i see now. for some reason it didnt grab the entire thing, my bad

tawdry mulch
#

So did you have it in your code?

autumn badge
#

yea, i did

#

there is the code with the errors

tawdry mulch
#

have you tried running the app?

#

the error is pylint one, more like a warning

autumn badge
#

yea, it runs but has those errors

#

normally warnings are yellow

#

like that

tawdry mulch
autumn badge
#

im sure it is man.

tawdry mulch
#

Just a min

autumn badge
#

actually, i think python is fine

#

VSC is borked

#

you got a good way to uninstall it completely? so i can reload it and start over?

#

i get no errors when trying it with IDLE

tawdry mulch
#

Hmmm Control Panel uninstall

#

and reinstall

autumn badge
#

settings still stay

#

need to find a way to purge

tawdry mulch
#

Anyway your not alone

#

At the end they solved it though @autumn badge

autumn badge
#

so basically, that will always show but it will still run?

tawdry mulch
#

Well it should. Don't you have a some sort of terminal?

autumn badge
#

yea. and i can certainly run it that way.

tawdry mulch
#

Press Ctrl + Shift + ` and then try typing 'python filename.py'

worthy ridge
worthy ridge
#

What

tawdry mulch
#

@worthy ridge

worthy ridge
#

3 languages and many frameworks

tawdry mulch
#

Great!

tawdry mulch
worthy ridge
#

Yes

#

But i use blender as in 3d art more

tawdry mulch
#

Yea, I did try it before. Without python

#

It is free, is one of the best part

worthy ridge
#

Its great lol

tawdry mulch
#

Brilliant, I was too dumb to understand it back then. Mayb 6 years before?

autumn badge
worthy ridge
#

Nope 2 yrs @tawdry mulch

tawdry mulch
worthy ridge
#

Ohh

tawdry mulch
#

remi? Never heard of it

worthy ridge
#

U can look up

autumn badge
#

just one i wanted to try

worthy ridge
#

UGLYclown999 on artstation to see my art@tawdry mulch

tawdry mulch
#

looks noice @worthy ridge

worthy ridge
#

Thats my first post

tawdry mulch
#

What is the use of python though? In blender

worthy ridge
#

For plugins

tawdry mulch
autumn badge
tawdry mulch
autumn badge
#

just wanted to play with it for a moment

#

what do you use?

tawdry mulch
#

These are the two best out there, IMO

#

I mean you could use Eel and so on...

autumn badge
#

im trying to stay away from QT modules. I dont like their screwy licensing

tawdry mulch
autumn badge
#

i understand that

#

i mainly write for internal use at work, but i would like the option to be able to sell

tawdry mulch
#

Once I get into this compleletely I would use Electron or something, rather than desktop apps

autumn badge
#

but i knwo my selling volume will nto be $500/month

#

lol

tawdry mulch
#

There is also WxPython

autumn badge
#

there are many and i have tried many

tawdry mulch
#

Yep, but I feel tkinter is best out there

autumn badge
#

been writing with appJar lately

tawdry mulch
#

hah noice

#

Kivy seems worth a try too

autumn badge
#

aka - modified tkinter

tawdry mulch
#

Well, it is better IG

#

tkinter gives you the simplicity of using JUST PYTHON.

#

kivy uses kv files or somethting right? I havn't used it before

autumn badge
#

oh, i meant appJar. it is basically a skin over tkinter to make it "simpler"
that also means i have hit the limitations on my second app

Kivy looks cool, but yea, i would prefer a pure python interface. and something pissed me off about kivy.....i forget what.

#

pyforms would have been cool if it were more developed and supported

tawdry mulch
autumn badge
#

i went on a framework bender for about a year

#

like some, hate others, couldnt understand the rest

#

pyqt is pretty solid.

tawdry mulch
tawdry mulch
autumn badge
#

gave up on pyside2 because any time i would install it, something would go wrong

tawdry mulch
#

now isnt a good time to try it then, more issues in pyside 6

autumn badge
#

that is what drew me to appjar

#

it was a very simplified code version of tkinter. so i could pump out apps quick

tawdry mulch
#

I don't know about efficiency. But tkinter has every tool you would need to make a gui.

autumn badge
#

pysimplegui works well but it takes a hot minute to get used to

tawdry mulch
autumn badge
#

by "efficiency" i dont mean the running of the code but more the writing of it

#

for me at least

tawdry mulch
#

right

autumn badge
#

everyone is different

#

some people love JS

#

i run as fast as i can as soon as i see it

tawdry mulch
#

:p

autumn badge
#

somethign about me and JS that just dont get along

tawdry mulch
#

I see

autumn badge
#

i should give tkinter and pyqt a try again.............at some point

tawdry mulch
#

Probably yea

autumn badge
#

too many things to do and know.........

tawdry mulch
#

Life..

digital rose
#

Mouse pointer theme rather.

autumn badge
# tawdry mulch Life..

too many languages/scripts to know right now

Python, excel VBA, AutoLisp, Json, sql, etc

tawdry mulch
#

Its just an animated cursor off the internet. TBH that is my system cursor and not the tkinter cursor. But I have used the same with tkinter windows and it works. Had to abandon it cuz unfortunately Menu does not take in cursors @digital rose

tawdry mulch
digital rose
autumn badge
#

havent seen it on the paycheck yet though LOL

digital rose
#

Ah, i see, thanks.

tawdry mulch
#

Just to mimic razer :p

tawdry mulch
autumn badge
tawdry mulch
#

First Pycharm, then VSC. Casually IDLE to test some scripts

autumn badge
#

i kinda like it

#

kinda like pycharm without all the bloat

tawdry mulch
tawdry mulch
autumn badge
tawdry mulch
#

Well atleast my VSC looks nice (for my eyes) :0

autumn badge
#

im gonna try out PyScripter for a while. I dont like how VSC keeps fucking up on me

digital rose
tawdry mulch
digital rose
#

Rarely, either IDLE or Sublime Text 3.

#

When i feel bored

autumn badge
#

not beginner friends but very very functional (vim)