#user-interfaces

1 messages ยท Page 81 of 1

static cove
#

Yeah of course

digital rose
#

Can you give me an example with my upgrade button

#

and then explain it

static cove
#

Uhhh sure, let me get to my computer

digital rose
#

okay

#

brb

#

My code is above if you wanna do it I'll be back gotta do something

#

ok back

static cove
#

Okay, I'll post a shortened snippet, just so it's easier to see what's going on

digital rose
#

ok

#

rn I'm trying to figure out how to make a thing that will show your money

#

the issue is it just doesn't update

#
current_money = Label(
    text = f"You currently have {money}$",
    fg = "green",
    bg = "black"
    )```
static cove
#
from tkinter import *

# Screen
screen = Tk()
screen.title("You have $")
screen.geometry("500x500")

welcome_text = Label(text="Welcome to Money Simulator")

welcome_text.grid(row=0, column=1, columnspan=2, sticky='')

# We're going to weight the unused columns so that things are centered.
# If a column is used, we should weight it.
screen.grid_columnconfigure(0, weight=1)
screen.grid_columnconfigure(3, weight=1)

# Money
click_me = Button(text="Button 1")
click_me.grid(row=10, column=1)

# Upgrades
upgrades = Button(text="Button 2")
upgrades.grid(row=10, column=2)

# We need to weight the rest of the rows
for _ in range(10):
    screen.grid_rowconfigure(_, weight=1)

screen.mainloop()
digital rose
#

thanks

#

I have a question

static cove
#

So the big thing is that I have 4 columns: 0, 1, 2, 3.
For the two buttons, I want space on either side, so I have to have 2 columns on either side. 2 buttons, 2 columns on the ends = 4 total columns.

With 4 columns, I still need to center that top text. To make it simple, I just make it take up two columns: 1 and 2

digital rose
#

Is there a way to make vsc do what idle does

#

because I have to use idle because vsc doesn't open the boxes

static cove
#

hmmm... let me test it in VSC

digital rose
#

ok

static cove
#

What boxes is it supposed to open?

digital rose
#

the tkinter one

#

so you can play

static cove
#

hmmm, it's opening up for me. Let me check something

digital rose
#

ok

static cove
#

Okay weird, it's opening up tkinter for me

#

If you open the terminal in VSC, and type the py yourfile.py or python yourfile.py does it work then?

digital rose
#

I relaunched vsc and it works now

#

thanks

hoary cypress
static cove
digital rose
#

example?

static cove
#

typing up one now~

digital rose
#

okk

static cove
#
from tkinter import *

money = 5
earnings = 1

# Button 1 Earnings
def money_button():
    global money
    global earnings
    money += earnings
    money_display.set(f"You have ${money}")
    print(f"You now have {money}")

def upgrade_button():
    global money
    global earnings
    

# Screen
screen = Tk()
screen.title("You have $")
screen.geometry("500x500")

# We're going to use a StringVar to have a variable we can update
money_display = StringVar()
money_display.set(f"You have ${money}")

welcome_text = Label(text="Welcome to Money Simulator")

welcome_text.grid(row=0, column=1, columnspan=2, sticky='')

# We're going to weight the unused columns so that things are centered.
# If a column is used, we should not weight it.
screen.grid_columnconfigure(0, weight=1)
screen.grid_columnconfigure(3, weight=1)

money_var = StringVar()

# Money
click_me = Button(text="Button 1", textvariable=money_display, command = money_button)
click_me.grid(row=10, column=1)

# Upgrades
upgrades = Button(text="Button 2")
upgrades.grid(row=10, column=2)

# We need to weight the rest of the rows
for _ in range(10):
    screen.grid_rowconfigure(_, weight=1)

screen.mainloop()
#

Take a look at that and let me know if you have questions about how it's put together

#

Normally I'd try to guide you to figure it out on your own, but this is more of lack of knowledge of a library, so I think it's better for me to show you how to do things and what's even available

digital rose
#

okay

#

working on changing some things of it right now

#

thank you

static cove
#

happy to help~ Feel free to ping if you have any questions or hit some blocks

digital rose
#

okay

#

ty

#

Actually

#

I will message you some time about how to publish this on the play store

static cove
#

That is not something I know much about unfortunately

digital rose
#

okay

#

I started back from what I had because It got messy

#

I'm gonna read what you sent and figure it out

#

thanks

#

@static cove py current_money.grid(row=0, column=1, columnspan=2, sticky='') AttributeError: 'StringVar' object has no attribute 'grid'

#

I'm getting this error

static cove
#

So a StringVar is used in a Label, not in the grid itself

digital rose
#
current_money = StringVar()
current_money.set(f"You currently have {money}$")
current_money.grid(row=0, column=1, columnspan=2, sticky='')
``` How do I fix this then
static cove
#

Sooo it would be:

money_var = StringVar()
money_label = Label(textvariable=money_var)
money_label.grid(row=0, column=1, columnspan=2)
digital rose
#

erm

#

can you add it to my code

#

@static cove

tawdry mulch
digital rose
#

coolcloud

tawdry mulch
digital rose
#

can you do it for me

tawdry mulch
digital rose
#
current_money = StringVar()
current_money.set(f"You currently have {money}$")
current_money.grid(row=0, column=1, columnspan=2, sticky='')```
#

Says I can't use grid with stringvar

#

brb

tawdry mulch
digital rose
#

I don't understand where I would put my stuff though

#

could you add the required thing to mine

tawdry mulch
digital rose
#

I sent it

tawdry mulch
digital rose
#
current_money = StringVar()
current_money.set(f"You currently have {money}$")
current_money.grid(row=0, column=1, columnspan=2, sticky='')```
digital rose
#

no

#

That's my code

#

It just doesn't work because StringVar doesn't have grid

tawdry mulch
# digital rose no

StringVar is not a widget so they cannot be grid. They must be associated to a widget.

digital rose
#

okay so what would I do

tawdry mulch
#

You should be asking that to your self, I do not know what you want. Usually people want a label, prolly you too

digital rose
#

what the fuck

tawdry mulch
#

what

digital rose
#

what do I do

#

@jade crane why did you spam ping @languid notch

tawdry mulch
digital rose
#

how though

#

it's gonna change what it is

#

that's what I'm not understanding

#

I know the problem just not what to do

tawdry mulch
digital rose
#
current_money = StringVar()
current_money.set(f"You currently have {money}$")
current_money.grid(row=0, column=1, columnspan=2, sticky='')```
#

This is what I have

tawdry mulch
digital rose
#

Why are you getting so mad because you dmed me a invite to a server

tawdry mulch
digital rose
#

saying fuck

#

is different then dming someone an invite

tawdry mulch
digital rose
#

no

#

because cussing isn't against the rules

#

lmao

tawdry mulch
#

Take all the time you want reading this

digital rose
#

Says nothing about profanity

tawdry mulch
digital rose
#

Also you're getting blocked for an unannounced server invite.

tawdry mulch
#

OK man(or kid), listen. I sent you a server, that is related to your question because people there can really help you out better. You don't want it? Then say you don't. Dont bring up rules onto it.

plush stream
jade crane
#

its literally a meme, you would expect normals to have it

tight ice
#

!ot

proven basinBOT
tight ice
#

why is my PyQt5 window only showing for a second when i do .show()

tawdry mulch
tight ice
#

no error

#

i fixed it

odd iris
#

uh

#

i need help

#

i try to make a number guessing with tkinter

#

but the button is

#

like

#

ugly

#

here is the code, ping me when someone answer it

import os, sys, time, tkinter, random

window = tkinter.Tk()

def main():
    label1 = tkinter.Label(window)
    label1["text"]="Number guessing by Domino"
    label1["background"]= "#32a852"
    label1.grid(row=0, column=0)
    button1 = tkinter.Button(window)
    button1['text']="Start"
    button1.grid(row=1,column=0)
    button2 = tkinter.Button(window)
    button2["text"]="Quit"
    button2.grid(row=1,column=1)
    window.mainloop()

if __name__ == "__main__":
    main()```
plush stream
#

@odd iris use ttk instead of tk

odd iris
plush stream
odd iris
#

zankyu

marble rover
#

Some im using something like this to makethe window open

How do i make words print onto the window?
Becuase using print will only print the words into the terrminal
import turtle as t
import os
import time

win = t.Screen() # creating a window
win.title("Test") # Giving name to the game.
win.bgcolor('black') # providing color to the HomeScreen
win.setup(width=800,height=800) # Size of the game panel
win.tracer(0) # which speed up's the

while True:
win.update()

#

I want to make it so that i can type into the window and get a respnce

coarse mirage
#

What's the best way to put in a real-time line graph into my program? I was thinking of Plotly but it seems to only open up via webpages.

digital rose
#

Tab? you mean the title bar?

#

Can someone tell me how exactly to load PyQt5-based custom widget plugins to Qt Designer? tutorials are trash, I made the plugin but I don't know how to load it.
PLEASE HELP

#

It's better to do it in Qt Designer,
First design your own title bar in Designer (Add a label as an alt to title name and three buttons of your own for "Close" "Maximize" "Minimize") and in Python do as bellow to remove the default title bar:
in imports add:
from PyQt5.QtCore import Qt
then in your window class:
self.setFlag(Qt.FramelessWindowHint)

#

There is a nice guy in YouTube with a lot of modern Ui stuff designed in PySide, Wanderson
I can give you a link for the relative vid:
https://www.youtube.com/watch?v=wQfKamzV1uQ

//// DONATE ////
๐Ÿ”— Donate (Gumroad): https://gum.co/mHsRC

๐Ÿ”— PATREON:
Many people asked me to create a Patreon (thanks to everyone, you are amazing โค)!
If you can help me keep creating new videos about technology and that amount will not be missed for you this will help to share knowledge FOR EVERYONE!
https://www.patreon.com/WandersonIsMyName

...

โ–ถ Play video
mighty rock
tight ice
#

whats the difference between tkinter and tkinter.ttk

tribal path
#

Android ui? Kivymd are kivy widgets styled as per material.io if thats the sort of thing you're after

velvet garden
#

hello there, i have a quick question

The following code outputs an error: AttributeError: 'Window' object has no attribute 'TKNotebook'

import PySimpleGUI as sg




Username_Tab_Layout = [
    [sg.Text('Username Generator')],
    [sg.Button('Quit')]
]


Password_Tab_Layout = [
    [sg.Text('Username Generator')],
    [sg.Button('Quit')]
]


layout = [
    [sg.Text('- .Password and Username Generator. -')],
    [sg.Button('Quit')],
    [sg.Tab('Password', Password_Tab_Layout), sg.Tab('Username', Username_Tab_Layout)]
]






window = sg.Window('Password and Username Generator', layout, finalize=True)



while True:
    event, values = window.read()

    if event is None or event == 'Quit':
        break
window.close()
wind nymph
#

So i am getting the _tkinter.TclError and i don't really understand what is wrong. So could someone please tell me ?

tawdry mulch
proven basinBOT
#

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

wind nymph
#

@tawdry mulch Hey i tried to open the image with other image editing apps and saved it as .png but the result is the same. Thanks anyways, I am going to look into it a bit more.

tawdry mulch
#

Can you send more code

#

or try to plug your image in this code and let me know if it works

#
from tkinter import *

root = Tk()

img = PhotoImage(file='image.png') # Your image
Label(root,image=img).pack()

root.mainloop()
cursive basin
#

is there something like

self.textCursorPostionChanged.connect(self.foo)

in QPlainTextEdit

#

basically i want to call a function when the postion of text cursor is changed

#

or i have to use mousePressEvent()

cursive basin
tight ice
#

self.textCursorPostionChanged.connect(self.foo)

#

looks pretty fine to me

#

do dir(self)

#

to see what exactly it is

cursive basin
#

i am asking if there is something like that

gaunt sapphire
#

guys

#

i need help

#

plz

tight ice
#

?

gaunt sapphire
#

ok

#

wait

#

the imgs are transparent but in the program int's not

#

๐Ÿ˜•

#

plz give me a solution

gaunt sapphire
cursive basin
cursive basin
gaunt sapphire
#
from tkinter import *

def start():
    start_btn.destroy()    

    login_path = PhotoImage(file=".\\Data\\login.png")

    login_lbl = Label(window,
                        image=login_path,
                      font=("",30,"bold"))
    login_lbl.place(x=500,y=100)

window = Tk()
window.geometry("1200x700")
window.title("IDK")

BG_path = PhotoImage(file=".\\Data\\BG.png")

BG = Label(window,
           image=BG_path)
BG.pack()

logo_path = PhotoImage(file=".\\Data\\logo.png")

logo  = Label(window,
              image=logo_path)
logo.place(x=10,y=10)

start_path = PhotoImage(file=".\\Data\\start.png")

start_btn = Button(window,
                   image=start_path,
                   borderwidth=0,
                   command=start)
start_btn.place(x=480,y=300)

window.mainloop()
gaunt sapphire
gaunt sapphire
gaunt sapphire
tawdry mulch
gaunt sapphire
#

what

#

?

gaunt sapphire
tawdry mulch
digital rose
#

Hi guys! Does anyone know how to run an animation before opening the GUI

#

I have an mp4 animation of the logo of my app and I want to present it to the user before opening the app

#

BTW I'm using pyqt5

digital rose
#

PyQt Kivy

urban garden
#

Someone here to help me with PyQt?

#

I have this issue:
I created a GUI with QtDesigner and i added 2 textfields. Now i want to get the Input. As far as i know this is how it works:

self.user_input_field = QtWidgets.QLineEdit()

@pyqtSlot()
def getWrittenInput(self):
  input_textbox = self.user_input_field.text()
  return input_textbox

When i call this function from another file with this command:

print(user_input)```
The window will crash and this is the error:
```Process finished with exit code-1073740791 (0xC0000409)
#

On Stackoverflow a solution is to install PyQt but i already did so idk why this error shows up.

thorny star
#

@static cove Hello! You had asked me to ping you in this channel for more resources regarding gui theory

#

Sorry I took a little too long

digital rose
#

can anybody help me with Qt designer?

#

@urban garden can you help me?

urban garden
#

@digital rose
Maybe.. whats your question?
(I'm new to Qt Designer)

digital rose
#

even if i add frame of widget instead of label those also copies/inherits the image of QmainWindow which doesn't make sense and it should not do that,

urban garden
#

try to add a background color to the stylesheet of the lables/...

urban garden
#

because with no backgroudn color it could be transparent

digital rose
#

let me send you a screenshot

urban garden
#

kk

digital rose
#

do you know anyother method of adding a background image ? maybe i can try that

urban garden
#

ok lemme do some research

digital rose
#

ok

urban garden
#

i tried to recreate your problem but when i try to add a background image it does not even show up. wtf

digital rose
urban garden
#

yes but i my image is a .png and not .qrc and then i cannot add it

digital rose
#

You can add it,

urban garden
#

oh ok. let me try

#

now it works

digital rose
#

Yup, so recreate the problem by adding the background image to QmainWindow or Qcentral widget and then add anything (label frame etc)

#

hey dude, thanks for your time really appreciate people like you who spends their time to help others, I just found the solution by adding a completely transparent image to the background of the label

urban garden
#

@digital rose
yeah i also figuered out that if you add another background image to the label it covers the the "main background-image". But i think this cannot be the best solution (i think the programm could work slower because it has to load all the images but i have no knowledge about such things it just sound logical). It's weird that the background-color of the label isn't "superior" even if you bring it to the front. idk what's the issue there but i'm happy you found a way around.

digital rose
#

yeah, it's not an ideal solution but it works, and yes it will cause the application to load a bit slower but where it's going to be used, those 500ms doesn't matter, so i will go ahead with this, If you found the actual solution anytime, Please message me, i would really appreciate it, Thanks again

echo swan
#

oh wow

#

that GUI looks so fancy

#

It reminds me of skeuomorphic design

urban garden
digital rose
#

(TKinter Related) How do i get the current value of a Combobox?

teal gull
#

Anyone know why my PyQT5 emits are randomly taking 1000x as long? 0.02ms vs 20ms? I can provide details if you need

static cove
teal gull
mystic crescent
#

Hello there,
Is it possible to auto resize Widgets with this kinda layout. I prototyped the application with cordinats for now.
Like having not everything centered.

#

I wasnt able to find a layout that fids these special needs bzw. how i placed them

plush stream
#

@mystic crescent make a hybrid layout by combining more than one layout

mystic crescent
plush stream
#

For the bike logo, username text field, password field, and login button use QVBoxLayout

#

You can get creative with the other widgets

digital rose
#

its the white line

gaunt tinsel
#

Anyone recommend a good GUI library for python that works on linux?

#

I'm running arch linux with I3

lime monolith
digital rose
#

So basically I wanna make a thing where you can enter text into a thing with tkinter
then press a button that will save it to a variable called text
how could I do that?

tawdry mulch
digital rose
#

Is it possible to get transparent blurred background in tkinter just like the new windows 11 ui?

plush stream
digital rose
#

@plush stream and also if there is any thing with the rounded buttons in tkinter

plush stream
#

I don't use tkinter that much so idk sorry

winged fossil
#

While making a wxpythoj windows app..can i include all my functions inside frame class ?
Even those who are not event driven.

mystic crescent
onyx meteor
#

give me some resource to learn ui ux

plush stream
digital rose
#

Is interpolated animation possible in pyqt

dusk marsh
#

does anybody work with kivi?

#

is it possible to make a for loop in the .kv file, would be useful to use that to create n buttons instead of just putting them all in

celest prawn
#

Anyone know why I keep crashing when trying to read QEditLine in QT?

mytext = self.comboBox.toPlainText()``` this is inside a function that is referenced, when a button is clicked ( self.func ) The function works fine however getting the text doesn't
celest prawn
plush stream
sharp plover
#

@marble island You may also like to investigate Kivy if you haven't already.

distant swift
#

How to keep a Kivy window always on top?

proven basinBOT
tawdry mulch
#

@distant swift ^^

green stump
#

Is anyone familiar with XTerm mouse tracking? If so, how do I enable mouse support and where do event notifiers get sent (maybe just the stdin) ?

digital rose
#

i have a quick question related to PYQT5
How can i use the QPushButton as a holding button?
So like i want a function to be only executed while the button is pressed

#

@plush stream can you please help me?

static cove
#

The clicked could start the function and it'll only run while that's true

digital rose
#

Thanks for the reply, i did it like this and it only prints the string "reached"

i connected the QpushButton to this "test_test(self)" method using this line

self.home_ui.key_2.mousePressEvent = self.test_test

#

@static cove

static cove
#

can you print event for me?

digital rose
#
        print("reached")
        print(event)
        state = self.home_ui.key_2.isDown()
        while state:
            print("yesss")
            state = self.home_ui.key_2.isDown()```
static cove
#

key_2 is your QPuishButton?

digital rose
#

yes

static cove
#

Why don't you use the signal pressed instead of mousePressEvent?

digital rose
#

Ok, let me try that

#

here's how to code looks now But it prints out the "yesss" infinitely and make the UI unresponsive

static cove
#

You want other aspects of the UI to update while the button is being pressed down?

digital rose
#

not really, it's ok if they don't update while the button is pressed, but atleast the button should be responsive and should stop when i release the mouse button

#

it amazes me that despite QT being such a big platform lacks these simple functionalities, i've read the whole documentation now and found nothing to accomplish this task

sudden dock
#

you know how there are like drop down lists everywhere and stuff? is there like some sort of plugin to do that with python code? my code has tons of blocks and in one section a gajillion tons of if statements but trying to scroll to find the one im looking for takes ages, if there is some way to like toggle it to hide its block...idk is there a plugin or mod for that

static cove
#

That's just the basics of working with GUIs

digital rose
#

Yes i'm pretty familiar with multithreading and Qthreads But i don't want anything to happen in the Background i just want it to print "yesss" while the button is pressed and stop when the button is released

digital rose
static cove
#

Basic example using QThread:

from Pyside6 import QtCore, QtWidgets
from __feature__ import snake_case, true_property

class Worker(QtCore.QObject):
  def __init__(self):
    super().__init__()
    self.keep_going = True
  
  def test(self):
    self.keep_going = True
    while self.keep_going:
      print("hi?")

class MainWindow(QtWidgets.QWidget):
  def __init__():
    super().__init__()
    self.layout = QtWidgets.QHBoxLayout(self)
    
    self.thread = QtCore.QThread()
    self.worker = Worker()
    self.worker.move_to_thread(self.thread)

    self.btn = QtWidgets.QPushButton("Press Me", pressed=self.worker.test)
    self.btn.released.connect(self.pls_stop)

    self.layout.add_widget(self.btn)
    self.thread.start()

  def pls_stop(self):
    self.worker.keep_going = False
    print("stopped")

# Insert basic app start stuff here
static cove
digital rose
#

does anybody know something better than tkinter cause i want to make a pretty simple UI but cant find what im looking for

clever raptor
#

Hello everyone! I'm still a beginner and I want to develop a desktop application so I don't know which package I should use, any recommendations?

static cove
zealous abyss
#

if anyone is familiar with curses and py2exe, i have a question about it in #help-cake if you'd like to check it out

thorny star
#
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

class MainWindow(QMainWindow):
    
    def __init__(self, *args, **kwargs):
        
        super().__init__(*args,**kwargs)
        self.setWindowTitle('Test')
        
        widget = QPushButton('Test Once Again')
        widget.setCheckable(True)
        self.setCentralWidget(widget)
        self.toggleState = True
        
        
        widget.clicked.connect(self.buttonClicked)
        widget.clicked.connect(self.buttonToggled)
        widget.released.connect(self.buttonRelease)
        widget.setChecked(self.toggleState)
        
        
    def buttonClicked(self):
        print("Pressed")
        
    
    def buttonToggled(self, check):
        print(f'Toggled! Set to {check}! \n\n')
        self.toggleState = check
        print(self.toggleState)
        
    
    def buttonRelease(self):
        
        self.buttonRelease = self.widget.isChecked()
    
    
app = QApplication([])
window = MainWindow()
window.show()


app.exec_()```


Why is it that when I run this , it spits an error stating that widget isnt an attribute of self when buttonRelease() is run?
#

Is it not very clearly defined in widget = QPushButton('Test Once Again')

royal gull
thorny star
thorny star
#

Thank you!

#

sorry to asjk again

#

ive hit another roadblock

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

class MainWindow(QMainWindow):
    
    def __init__(self, *args, **kwargs):
        
        super().__init__(*args,**kwargs)
        self.setWindowTitle('Test')
        self.widget = QPushButton('Test Once Again')
        self.widget.setCheckable(True)
        self.setCentralWidget(self.widget)
        self.toggleState = True
        self.buttonReleased = True
        

        self.widget.clicked.connect(self.buttonToggled)
        
        self.widget.setChecked(self.toggleState)
        
        
    def buttonClicked(self):
        print("Pressed")
        
    
    def buttonToggled(self, check):
        print(f'Toggled! Set to {check}!')
        self.toggleState = check
        self.setWindowTitle('Changed!')
        self.widget.setText('I have been clicked once already now')
        self.widget.setEnabled(False)
        
        self.widget.setText('I am back!')
        self.widget.setEnabled(True)
        self.widget.clicked.connect(self.buttonToggled)
    
app = QApplication([])
window = MainWindow()
window.show()


app.exec_()

If I hit the button once, it gets disabled and subsequently enabled again. Howeber it runs print(f'Toggled! Set to {check}!') more and more times with each click

#

In the first click print(f'Toggled! Set to {check}!') happens once

#

in the 2nd click it happens twice

#

and this number keeps increasing

#

is there a specific reason as to why this happens?

tawdry mulch
#

I think it is called context menu

lime sapphire
#

hey, quick question, is there a way to make a listbox item have a selected background without me clicking it? (lets say with a function on a button click)

#

nevermind figured it out

digital rose
#

I have a question about Tables in Rich. I'm currently adding rows my_table.add_row(last_seen, name) and they appear under the previous line. Is there a way to get all the rows currently in the table to order them differently, aka the equivalent of a table.get_rows() ?

pseudo folio
#

I am trying to draw a line with a text label on it in pyqt. Is there something already in QtWidgets.QGraphicsLineItem() that I can use. If not, can I use an item group?

hasty sable
#

(Kivy)

uhhhh i have this errror where if i right click on my Text iput, a red dot will appear? wat is this ( sorry for the gramar)
i also have a screen record

tribal path
#

Those are emulated presses for multiple fingers, can remove via config

restive mountain
#

how to store text in textboxes in tkinter

neat trout
#

U mean Store text in variables

#

From the textbox

restive mountain
neat trout
#
text = Textbox.get()```
#

Try maybe

restive mountain
#

ok

restive mountain
#

its nowtworking

neat trout
#

Oh sorry its actually Entry and not text before those parentheses

#

My bad

restive mountain
#

?

neat trout
#
text = Textbox.get()```
restive mountain
#

ok

tawdry mulch
restive mountain
#

;

neat trout
#

It is.

restive mountain
#
    newwindow = Tk()
    newwindow.geometry("400x450")
    newwindow.title("register new passcode")
    a = Entry(root, text="name")
    usrnm = a.get()
    b = Entry(root, text="password")
    pwd = b.get()
    c = Entry(root, text="website")
    web = c.get()
    myButton = Button(root, text="save", command=save)```
tawdry mulch
restive mountain
#

is something wrong here

tawdry mulch
#

You are fetching the value as soon as the box is created, hence it is empty

#

Read about event driven programming

restive mountain
#
    newwindow = Tk()
    newwindow.geometry("400x450")
    newwindow.title("register new passcode")
    a = Entry(root, text="name")
    "usrnm" = a.get()
    b = Entry(root, text="password")
    "pwd" = b.get()
    c = Entry(root, text="website")
    "web" = c.get()
    myButton = Button(root, text="save", command=save)```
restive mountain
neat trout
restive mountain
#

Textbox = Entry(root, colum= whatever, row=whatever)?

neat trout
#

Dont mind the whatever part

tawdry mulch
# restive mountain here

What you are doing is wrong, you cannot assign to a string. What I meant was, you are creating an entry widget and soon after that you are storing the value inside usrnm but there is nothing in the entry box, so it is empty. What you need to do is, create a function to store these into variables

tawdry mulch
neat trout
#

Sorry i forgot.

#

Its been long since i used tkinter

tawdry mulch
restive mountain
#

def save():
usrm = a.get()
pwd = b.get()
web = c.get()

#

i claimd chat #help mango

tawdry mulch
restive mountain
#

def save():
usrm = a.get()
pwd = b.get()
web = c.get()

restive mountain
#
import string
import tkinter
from tkinter import *
from tkinter.ttk import *
import os.path
import os

var1 = 2
root = Tk()
if os.path.exists("info.txt"):
    pass
else:
    file = open("info.txt", 'w')
    file.close()
root.title("Azur lane project")
e = Entry(root)
e.place(x=100, y=300)



def newwindow():
    newwindow = Tk()
    newwindow.geometry("400x450")
    newwindow.title("register new passcode")
    a = Entry(root, text="name")
    a.get()
    b = Entry(root, text="password")
    b.get()
    c = Entry(root, text="website")
    c.get()
    myButton = Button(root, text="save", command=save)


def appennew():
    file = open("info.txt", 'a')

    usrnm = "UserName: " + userName + "\n"
    pwd = "Password: " + password + "\n"
    web = "Website: " + website + "\n"

    file.write("---------------------------------\n")
    file.write(usrnm)
    file.write(pwd)
    file.write(web)
    file.write("---------------------------------\n")
    file.write("\n")
    file.close()



def hh():
    var1 = e.get()
    all = string.printable.strip("")
    temp = random.sample(all, int(var1))
    password = "".join(temp)
    password_label.config(text=password)


def save():
    usrm = a.get()
    pwd  = b.get()
    web  = c.get()






myButton = Button(root, text="register new password", command=newwindow)
myButton.place(x=105, y=235)
myButton = Button(root, text="generate random password", command=hh)
myButton.place(x=100, y=230, )
myLabel = Label(root, text="please put maximum characters for the password")
myLabel.place(x=102, y=270)
password_label = Label(root, text="")
password_label.place(x=100, y=190)

root.mainloop()
#

there is something wronge here

#

error unresolved reference

tawdry mulch
restive mountain
#

global variable?

tawdry mulch
#

2nd of all your a,b,c is not shown into the screen

tawdry mulch
restive mountain
tawdry mulch
#

third of all, newwindow = Tk() should be newwindow = Toplevel()

tawdry mulch
restive mountain
#

currently editing

#

def save():
global a,b,c
usrm = a.get()
pwd = b.get()
web = c.get()

tawdry mulch
#

Bro why is your window and function name same

neat trout
#

Anyways why use python for UI s?

restive mountain
tawdry mulch
restive mountain
#
    global a, b, c
    newwindow = Toplevel()
    newwindow.geometry("400x450")
    newwindow.title("register new passcode")
    a = Entry(root, text="name")
    a.get()
    b = Entry(root, text="password")
    b.get()
    c = Entry(root, text="website")
    c.get()
    myButton = Button(root, text="save", command=save)```
#

here its it ok @tawdry mulch

tawdry mulch
#

But as I said, you are not putting those widgets onto the screen

restive mountain
#

Entry.place(x=20,y=0)?

#

@tawdry mulch

tawdry mulch
restive mountain
#

it put it on win1 on on win2?

tawdry mulch
restive mountain
#

root

#

i replace root with newwindow?

tawdry mulch
# restive mountain root

Bro you know what, do a proper tkinter tutorial, they will explain everything. Slowly move and make progress

restive mountain
#

link?

tawdry mulch
#

Otherwise it will be very hard for you

tawdry mulch
# restive mountain link?

How to create graphical user interfaces with TKinter and Python. In this video we'll create our first hello world program using tKinter and Python.

In this series I'll show you how to create graphical user interfaces for Python with Tkinter. TKinter comes with Python already, so there's nothing to install!

โœ… Watch The Other Videos In This Py...

โ–ถ Play video
restive mountain
#

that thing is where i got my tkinker knowledge

tawdry mulch
restive mountain
#

ok

#

bye

tawdry mulch
restive mountain
#

myLabel = Label(newwindow, Text="Password")
myLabel.place(x=125, y=80) is this command wrong

hasty sable
hasty sable
# tawdry mulch https://www.youtube.com/watch?v=yQSEXcf6s2I&list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrL...

this guy... i learned tkinter from him. but @restive mountain i suggest u use kivy as soon as you learn tkinter(1-2months) and Object Oriented Progremming(1-2 years) it has a much more modern look compared to tkinter. but learn tkinter first as it is base upon which u build others:
Kivy / Other things
Object Oriented Programming(OOPS)
Tkinter
Python base

You should go like this from bottom to top. also i suggest this book Tkinter GUI Application Development Cookbook if u r serious on it.

tawdry mulch
hasty sable
#

but we need python base then gui

#

if python base is not clear u cant

#

also if anyone wants to know how to pckage python tell. also how can i use buildozer in windows

tawdry mulch
hasty sable
#

but java to comppli

tawdry mulch
hasty sable
#

yes

#

also the Great thing bout kivy is

#

in there website it explains

#

everything

tawdry mulch
#

ah good documentation is important

hasty sable
#

also try making a new .py and run this one line of code: import this just copy and paste

tawdry mulch
#

its mentioned in the PEP ones

hasty sable
#

what is it.

#

yes

#

The zen of Python

tawdry mulch
#

hmmm yea

hasty sable
#

noice

#

bye!

hasty sable
#

Why this ain't workin' bois and galis:

window = Tk()
window.title('password')

abc = Entry(window)
abc.pack()

def passcode():
    if abc == 'hello_boi':
        Label(window, text='Hewwo boi').pack()
    else:
        Label(window, text='byeu bowii').pack()

bcd = Button(window, text='sumbimit boi', command=passcode)
bcd.pack()

window.mainloop()```
young yoke
#

try if abc.get() == 'hello_boi'

#

the get() function returns the value of an entry widget (i am not 100% sure though because I haven't used tkinter in a while)

digital rose
#

I have a List I would like to display in the CLI, but every time I do prints the screen flickers (I'm on a RPI3b+). Is there a better way to display tables on screen without calling print() every 1 second? I'm trying to display real time data in the CLI

#

I tried the Rich library but I can't manipulate the data grid, it's more of a stylistic UI framework

obtuse thistle
#

instead of clearing the screen, use \r to return the cursor to beginning of line

#
In [32]: print("hello\rhi")
hillo
thorny star
#

Can anyone explain what exactly an event handler in PYQT5 is ? Ive read up the docs on QT's website but Im left thoroughly confused

#

Is it like a slot?

lavish kindle
#

can someone, help me i just finished my login page using tkinter now i want to link it to my main exe file so when ever i run the exe it runs the login page

kind parrot
#
from tkinter import *

def dados():
    print(f'Com R${vquest:.2f} vocรช consegue comprar US${vquest/5.21:.2f}' % interface.get())

interface = Tk()
interface.title('Converter Dolar') #titulo da janela
interface.geometry('500x300') #Tamanho da janela
interface.configure(background='#636e72') #colorbackground

txt = Label(interface, text='Conversor de Dolar', background='#55efc4')
txt.place(x=170, y=60, width= 150, height=30)

# txt1=Button(interface, text='Conversor de Dolar', background='#55efc4')
# txt1.place(x=170, y=60, width= 150, height=30)

Label(interface, text='Quantos reais vocรช tem?', background='#636e72', foreground='#000', anchor=W).place(x=170, y=95, width=150, height=20)
vquest=Entry(interface)
vquest.place(x=170, y=120, width=150, height=20)

btn = Button(interface, text='Calcular', command=dados).place(x=10, y=270, width=100, height=20)

interface.mainloop()

How do I import a math function into python and print it on this interface?

digital rose
#

what math function do you want to import ?

#

like what are you trying to print?

#

you can just put
import math at the start of your code

hasty sable
#

@young yoke thanksssss boi

hasty sable
#

Also which is the best module thingy for gui. THe most modern, clean and prefferably simple

restive mountain
#

def tezt():
global username
global string
string = username.get()
global hot
global string
string = hot.get()
global het
global string
string = het.get()
file.write("---------------------------------\n")
file.write(username)
file.write(hot)
file.write(het)
file.write("---------------------------------\n")
file.write("\n")
file.close()
is something wrong here

restive mountain
#

yes

proven basinBOT
#

Hey @restive mountain!

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

restive mountain
#

my code

#

@hasty sable

deft knoll
#

how to have internal gui with python?

restive mountain
#

use tkinter

restive mountain
deft knoll
#

any document for internal gui?

restive mountain
#

How to create graphical user interfaces with TKinter and Python. In this video we'll create our first hello world program using tKinter and Python.

In this series I'll show you how to create graphical user interfaces for Python with Tkinter. TKinter comes with Python already, so there's nothing to install!

โœ… Watch The Other Videos In This Py...

โ–ถ Play video
hasty sable
#

dont use that guy coz he has 172 vids in that but hardly anything is covered

#

i suggest u to look for a docmentation jn tkinter websitei

#

if that eben exists

#

in this guy after the 20th vid we can move

hasty sable
#

to kivy

digital rose
#

where the hecc is my pyyqt5 designer

hasty sable
#

u want location?@digital rose

vast wagon
#

Hi, how are you?

hasty sable
#

o
good

#

why

#

@vast wagon im good why

vast wagon
#

I am just asking

tawdry mulch
digital rose
#

my qt_tools folder is empty

#

@tawdry mulch

#

quite deep was a really good explanation

#

thanks :D

digital rose
tawdry mulch
glacial elbow
#

hey folks
how can I upload the files to variables and create a generate button?
appreciate the help ๐Ÿ™‚

#

I need create a GUI that upload two images save them in variables and after that we can click on generate button and my code will continue ..

tawdry mulch
rotund reef
#

hi - I am looking at setting up a keyboard combination in an application I am making, and was looking at using pynput to handle it. However, I would like to define the shortcut key in a config file, and then set the shortcut at run time based on the values in the config file. i have a variable for the string from the config file for a given key called skey , but if I try to use shortcut = pynput.keyboard.Key.skey I get an attributeerror - in this case, the value of skey = ctrl. How can i make this work ?

tawdry mulch
hasty sable
rotund reef
tawdry mulch
rotund reef
tawdry mulch
rotund reef
rotund reef
tawdry mulch
rotund reef
tawdry mulch
rotund reef
tawdry mulch
rotund reef
tawdry mulch
#

Is there any reason you use pynput and not keyboard

rotund reef
#

mostly because everything I saw for setting up a listener for a keyboard shortcut was based on pynput - I am building something that will be running in the background an always listening for a keyboard shortcut

tawdry mulch
rotund reef
#

so the idea is to allow any arbitrary combination of keys - so in my earlier example I was looking at ctrl+alt+w

tawdry mulch
#

Read through pynput documentation for ways to set keys and you might get something

tawdry mulch
lavish kindle
#

can someone, Help me i have this, exe and i wanted to extend it, I wanted to add a log so for when ever, someone open's it it give's me the time and date or there login and i have no clue how to do that

rotund reef
#

The idea is to allow the end user to define what they want as the keyboard shortcuts there instead of having them hardcoded. There is a value for the number of keys, and then you define the keys
numkeys: 3
1: ctrl
2: alt
3: w

tawdry mulch
rotund reef
#

so the idea is that when they enter that keyboard shortcut, it triggers a bunch of other code to run . In this case , it pops up a tkinter entry box where they can enter a number , then when they press enter, that box closes , and more code is called - I am working on a grid snapping tool for moving windows to a specific location on the current screen .

I am using 2 yaml files , 1 called grids.yml, one called layouts.yml . The grids.yml is for defining how many rows & columns you want to use for the layouts .
`

Grids:
12x12:
Rows: 12
Columns: 12
5x5:
Rows: 5
Columns: 5`

In layouts.yml, you define the following:
Which grid you use
The Top Position( in grid squares)
The Left Position ( in grid squares)
The height( in grid squares)
The Width ( in grid squares)
Example :
--- Layouts: "1": Grid: 12x12 TopPos: 0 LeftPos: 0 Height: 6 Width: 6 "2": Grid: 12x12 TopPos: 0 LeftPos: 6 Height: 6 Width: 6

The idea is to make it so that instead of having resolution specific mappings, it is based on your grid squares . Then , when you enter the number from the layouts into the popup when you hit the main keyboard shortcut, it moves the window to that positions and resizes it .

tawdry mulch
#

.ie, while the window has focus

rotund reef
tawdry mulch
rotund reef
#

no - thats why I was using pynput - because I can have a listener in the background . I am using Xlib to get the active window ID, and xlib to move the window- so you could use it on firefox, vs code, discord, etc...

tawdry mulch
#
import tkinter as tk
import keyboard

def output(lines = 'hehehehe'):
    print(lines)

root = tk.Tk()

button = tk.Button(root, text ='HAHAHA', command = lambda:output('hahaha'))
button.pack()

keyboard.add_hotkey('ctrl+alt+w', output, args=('asdasd',))

root.mainloop()
#

Look at this example

#

As simple as this to trigger a bunch of keys

rotund reef
tawdry mulch
#
def usekeys(keyconfig): 
    numkeys = keyconfig.get("numkeys")
    keyiter = 0
    lst = []

    while keyiter < numkeys:
        keyiter += 1 
        sley = keyconfig.get(keyiter) 
        lst.append(sley)
    keyboard.add_hotkey('+'.join(lst), whatever_func_to_run)
#

Something like this might work with you

rotund reef
#

Thanks

tawdry mulch
regal heron
#

Hello !
I'm using PyQt6 and a QTableWidget to show data (a list of list containing integers) to the user. To populate the QTableWidget I iterate over every row and column and use the .setItem() method which take the row, the column and a QTableWigetItem object. However, when I then show the application the table is empty.
Also, if I use the .item(row,column) method which returns the QTableWidgetItem stored in that cell I instead get a NoneType object.
Any idea what I did wrong ?
Here is the exact method I use :

    def setupTable(self):
        data = self.db.get_data()  # returns a list of lists like [[45,36],[88,99]]
        row_count = len(data)
        column_count = len(data[0])
        self.Table.setRowCount(row_count)
        self.Table.setColumnCount(column_count)
        for i in range(0, row_count):
            for j in range(0, column_count):
                item = QTableWidgetItem(data[i][j])
                self.Table.setItem(row_count, column_count, item)
proven basinBOT
#

main/main.py lines 187 to 198

def refresh_table(self):
    con = sqlite3.connect(self.filepath)
    c = con.cursor()
    c.execute('SELECT username,url FROM {}'.format(self.file))
    res = c.fetchall()

    for row_count,row_data in enumerate(res):
        self.ui.table.insertRow(row_count)
        for column_number, data in enumerate(row_data):
            self.ui.table.setItem(row_count,column_number,QTableWidgetItem(str(data)))

    self.ui.table.setRowCount(len(res))```
tawdry mulch
regal heron
tawdry mulch
regal heron
#

No the data is fine it's just testing values : [[88, 88, 100], [88, 66, 82], [36, 63, 60], [31, 65, 34]] , row_count == 4, column count == 3. There is only 1 column because no column is ever inserted .insertColumn(j) for exemple

#

But thanks for trying to help

wary gulch
#

okay so when i start, My exe the exe and the login form start's at the same time and pops up next, to each other what i'm trying to say is i want the login form to start first then after i login then the main program will then load

#

how would i do that can someone help me

buoyant fulcrum
#

what part of the code opens up both?

#

I've never coded/made exe's, but wouldn't you just be able to call the 2nd file from the 1st one?

regal heron
#

what do you use for your gui ? tkinter ?

wary gulch
#

@regal heronyes

regal heron
#

I don't know tkinter but you probably made a class for your login window and another for your main window. When the program start you create a login object and only when it returns a correct flag instanciate your main window

#

Again I don't know tkinter so you might want to wait for someone who does

thorny star
#

i was following a tutorial

#

they didnt exactly explain the differencesd clearly so i am confused

wary gulch
#

@regal heroncan u show me how to do thast

tawdry mulch
tawdry mulch
regal heron
regal heron
proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1629998173:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

wary gulch
#

@tawdry mulchwdym?

tawdry mulch
tawdry mulch
wary gulch
#

@tawdry mulchi did look at dms

digital rose
#

Hi guys! I have a technical question. I created a GUI that presents data to the user, to extract the data I created multiple threads that run their own processes and connect with different servers. Is this called multithreading?

wary gulch
#

okay so when i start, My exe the exe and the login form start's at the same time and pops up next, to each other what i'm trying to say is i want the login form to start first then after i login then the main program will then load
how would i do that can someone help me

digital rose
#

guys whats like a good library to use for making complicated UIs

#

for example: dashboards, something like discord etc

#

modern flat design

jaunty grail
#

how do i display a object/sprite/etc?

#

(using python)

digital rose
frail obsidian
#

Hello everyone, I have a quick question. I'm just starting out in python. I managed to write a little function that gets some data from an API that I find interesting. Now I'd like to represent that data in the form of a graph. What would be the easiest way for a beginner to get a graph to show? I've done some HTML and CSS a very long time ago, but no javascript. So not sure if a web page would be a good way to try that.

#

And the data that I'm working with right now is just list with floats in it. Nothing too difficult.

graceful viper
graceful viper
frail obsidian
graceful viper
frail obsidian
frail obsidian
quasi shore
#

hello everyone, i have made a small tool on tkinter and would like to make an installer for it so users can install it on their machines. could someone point me to a guide i could follow to acheive this ?

#

if i use pyinstaller to make a single file exe, will the pickle and dqlite database get included inside the exe file and will it work ?

vivid pulsar
#

Hey so i have a system tray code thing working but the code below it wont run

#

ui code

#

voice assistant code

ebon tusk
#

๐Ÿ‘

#

Nice

#

Simple but elegant

#

Like apple

digital rose
digital rose
#

Hello anyone here used PyQt5 who's delete with many Attribute errors.

#

Just dealing with issues related to Qt.ui file which can't detect some attributes, thank you.

digital rose
#

wow

proud night
#

I am planning to start a gui project, it is simple enough to be created in Tkinter or PyQt5. I want it to be graphical appealing, which module should I use to do that, Tkinter or PyQT5?

digital rose
#

Hey guys, window_1.iconbitmap("sounds/nat.ico") why wont this work?

#

(Tkinter)

digital rose
#

Had more capabilities then tkinter functionally with all the pre built methods called pyQt5-tools

#

And it's simplicity of using Qt designer which can be either in a ui file contain xml code

#

Or you can compile the file and make it in python code.

proven basinBOT
#

failmail :ok_hand: applied mute to @vapid osprey until <t:1630233433:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @narrow ingot until <t:1630248043:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

quiet timber
rocky dragon
#

Is there any way to get pycharm to understand pyside6's feature import? The generated pyi files work for the new names but I can't find a nice way to ignore the import itself not being valid

plush stream
#

Yeah idk abt that. I've been using pyqt/pyside in pycharm for almost 3 years now and it's still have that "unresolved reference" warning for some function/methods.

cursive basin
rocky dragon
#

Ah, that didn't work but I forgot about the noinspection comments. I couldn't find the ignore yesterday for invalid names but found in hidden away now, PyUnresolvedReferences makes it behave as if it was valid

cursive basin
rocky dragon
#

I mostly wanted to hide the error from from __feature__ import snake_case, true_property

cursive basin
#

oh

nocturne breach
proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @graceful spear until <t:1630331582:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

#

:incoming_envelope: :ok_hand: applied mute to @digital rose until <t:1630331957:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

cursive basin
#

can you show the current layout like screenshot of it

#

like the screen that shows up when you run the code

#

and also show your current code

digital rose
#

im not able to find the proper xpath :(

digital rose
#

oi

static cove
#

hullo

digital rose
#

thanks for taking the time to help out mate

#

so the timer works fine for my program right now thankfully

#

issue is his layout is different then mine I used a loadUi function from pyqt5

#

which just loads a XML file from Qt designer

#

I know this will cause issues long term

#

so I'm wondering how can I load a complied Ui file with pyuic

#

which I did for one window

#

but struggling for the other

#

and other big problem is how will the stop watch timer actually run when it's clicked and switch to the other Window

static cove
#

so what does your code look like now?

digital rose
#

you want me to send it in dms

#

kinda weird looking rn

#

๐Ÿ˜…

static cove
#

!paste you can also use our paste site
With GUIs it's hard to not get it to look weird

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.

digital rose
#

alright give me second

#
import sys
from TimerdesignBreakPause import *
from TimerdesignBreakPlay import *
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication, QLCDNumber, QPushButton, QWidget
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import *
from PyQt5 import QtCore, QtGui
import datetime

# BreakPlay window
class Breakplay(QDialog):
    def __init__(self):
        super(Breakplay, self).__init__()
        
        loadUi("Study timer project\Windows\Break windows\Timer_design-BreakPlay.ui",self)
        
        self.Play.clicked.connect(self.PlayWin) # clicked method to detect action
    def PlayWin(self): #function read's clicked method and calls Breckpaused
        play_break = Breakpaused()
        widget.addWidget(play_break)
        widget.setCurrentIndex(widget.currentIndex()+1)
        
    # timer function setup
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.run_watch) 
        self.timer.setInterval(1)
        self.mscounter = 0
        self.isreset = True
        
        # creating slots for event handling (button press)
        self.ui.Play.clicked.connect(self.start_watch)
        self.showLCD()
        
    def showLCD(self):
        text = str(datetime.timedelta(milliseconds=self.mscounter))[:-5] # changes the digits of miliseconds 
        self.ui.Clock.setDigitCount(10)
        
        if not self.isreset:  # if "isreset" is False
            
            self.ui.Clock.display(text)
        else:
            self.ui.Clock.display('0:00:00.0')
  
    def run_watch(self):
        self.mscounter += 1
        self.showLCD()
    
    def start_watch(self):
        self.timer.start()
        self.isreset = False

class Breakpaused(QDialog): # Switches to another window when action of PlayWin method is detected.
    def __init__(self):
        super(Breakpaused, self).__init__()
        loadUi("Study timer project\Windows\Break windows\Timer_design-BreakPause.ui",self)

app = QApplication(sys.argv)
welcome = Breakplay()
widget = QtWidgets.QStackedWidget()
widget.addWidget(welcome)
widget.setFixedHeight(520)
widget.setFixedWidth(1000)
widget.show()
try:
    sys.exit(app.exec_())
except:
    print("Exiting")

#

one thing though if you look at this part #timer function step up

#

it actually ran the same exact window without using loadUi

#

which made me think LoadUi wouldn't work with the functionally of thinking of

static cove
#

So, I'm a bit confused here. Why do you have 2 def __init__ for Breakplay?

#

also, when you make play_break, could you try something for me? Could you make it self.play_break and make it part of the instance?
Also, in that same function, could you add a self.play_break.show()?

digital rose
#

@static covemy bad mate just went to pray

static cove
#

no worries! I'll be around for at least another hour

digital rose
#

ok

#

thanks a lot bruv

#

honestly mans been dying on this

digital rose
#

I was confused

static cove
#

You can just put the stuff in the second __init__ into the first and have it all together

digital rose
#

because I used a layout from another tutorial it was good but she didn't haven't the functionality I needed.

static cove
#

So that would be inside the def PlayWin(self) function.
We're changing: play_break = Breakpaused() to self.play_break = Breakpasued(), just to make sure it attaches itself to the instance of the class

digital rose
#

my bum ass

#

sorry

#

๐Ÿ˜… I'm getting lost with the amount of shi I got

static cove
#

haha, GUI stuff takes a bit to get used to. You're fine~

digital rose
#

ya it's fun ngl though

#

ya it works

#

ut it highlight's play_break in the widget.addwidget

#

my bad it's because I need to use self.

#

hello

#

@static cove

static cove
#

hi hi

digital rose
#

ya

#

it works

static cove
#

So does that create the new window and all that jazz? Whoo!

digital rose
#

I wish

#

it works normally though which is good

static cove
#

Did you add the self.play_break.show() below that?

digital rose
#

but doesn't switch windows

digital rose
#

like in line below setcurrentindex

static cove
#

So the issue now is that it creates the window, but doesn't switch to it?

static cove
#

So, there's a few different ways to do this depending on what you want. Do you want this new window to always be on top as long as it's active? Do you still want to show the original window or do you want to completely hide that when the new one is active?

digital rose
#

bruv

#

you actually understand this thank you

#

the first one would effect the function in the beginning

#

because when I do that it won't use the window which is running before

#

if that makes sense

#

like the timer function is running in a different window

#

but I want to do the last one where I hide the button what was clicked

#

which is the play button

static cove
#

So just hiding the button?

digital rose
#

like this

#

and switch the button to a pause button

#

which is in a different window

#

and I wanna ask though

#

with this method where as it changes the button which is just Ui file

#

that Ui file which switch different buttons to just as it did with the Play

static cove
#

So you want to hide the Play button, open a new window which will have the Pause button?

digital rose
#

yup

#

it will look like this

static cove
#

How will the play button reappear? When the first window is closed or when the pause button is pressed?

digital rose
digital rose
#

from the tutorial I seen

#

she used the same exact method

#

from the other class

#

which was just flipping through clicked.connect() methods.

#

bruv are you building my whole program

static cove
#

So, in this case, because it's a different window, here's roughly what I would do to start:

def PlayWin(self):
  self.play_break = Breakpaused(self)
  widget.addWidget(self.play_break)
  widget.setCurrentIndex(widget.currentIndex()+1)
  self.play_break.show()
  self.ui.Play.hide() # This hides the button on the first window
  self.play_break.activate() # This makes this widget have the focus

and then, in your Breakpaused class at some point you want something like this as the function that's connected to the Pause button.

For this, we're going to have to change how the Breakpaused class works. Eventually you might have to use pyqt's signal/slot method. But for now, we can actually just reference the parent directly since we don't need the two windows running simultaneously doing 2 different things.

class Breakpaused(QDialog): # Switches to another window when action of PlayWin method is detected.
  def __init__(self, parent_window): #parent_window is window1, it needs a reference to send the signal back
    super(Breakpaused, self).__init__()
    loadUi("Study timer project\Windows\Break windows\Timer_design-BreakPause.ui",self)
    self.pause_button() # Let's pretend this is defining the pause button
    self.pause_button.connect(self.pause_func)
  
  def pause_func():
    self.parent_window.ui.Play.show()
    self.hide() # or you can send an `emit` signal that the parent is connected to and close it from the main window

This is a bit rough, but maybe you get the gist?

digital rose
#

self.ui.Play.hide() # This hides the button on the first window

does it hide it as in making it blured

#

and then, in your Breakpaused class at some point you want something like this as the function that's connected to the Pause button.

exactly to do like vice versa

#

@static covebruv thanks a lot

static cove
digital rose
#

go get some sleep. take care.

static cove
#

feel free to ping me tomorrow if you need more help or have questions~

digital rose
#

np

#

really appreciate this saved so much time

edgy kestrel
odd iris
#

guys... any help about tkinter blank entry problem?

#
    client_id = tkinter.StringVar()

    def printed():

        print(client_id.get())
    
    entry1 = tkinter.Entry(window)
    entry1.textvariable = client_id
    entry1.grid(row=0, column=1)

    button1 = tkinter.Button(window)
    button1['text'] = "Button"
    button1.grid(row=1, column=0)
    button1['command'] = printed
#

ping me

digital rose
#

@static coveoi

#

sorry to bother

#

from what you guided me through yesterday

#

what singals and slots would I used from pyqt5 to have such event's happen

pseudo folio
#

Does anyone here know how to create a "snappable grid" background in python. (For example, like the layout grids that CAD programs use, where lines can only be placed on grid points)

digital rose
#

i have a question, the question being: is there any way to use transparent images in (png) format as button images in tkinter cause when i do so although my image is transparent it seems to add a quadrilateral around the area which is transparent...

brave belfry
#

in pyqt I have two events connected to the same method. A mouse double click and a mouse move, however the mouse move event never triggers

#

does anyone know why this would be the case?

#

the double click works as would be expected and prints mouse coordinates to console

#

the move event however does nothing and according to pycharm's debugger is never even triggered (although my mouse certainly is moving)

brave belfry
#

update: if this were instead to say self.mouseMoveEvent = self.getPos then the method is called however the wrong result is given as the position relative to the window and not the image is displayed. I really do not understand this behavior. Would appreciate any help!

static cove
#

@blazing pine So! What would you like to know about my pyqtgraph usage?
My use case is: I'm in Research & Development and I often code programs that "glue" together and control our various instrumentation (a lot of it built by us or very, very niche). My most recent extensive use of it was we had wind sensors across our test grid. Our testing was highly dependent on the direction and speed of the wind. So I needed to read in at minimum 9 different sensors over network, saved the last X values in memory, and used pyqtgraph to plot them real-time. The pyqtgraphs and subsequent calculations were used a go/no-go decision maker.

blazing pine
#

was mostly curious if you're using line plots, scatter plots, 3D capability, and how "big" your data is (and how frequently it updates)

static cove
#

My fave features in pyqtgraph that keep me coming back:

  • Native interactivity with literally no effort from me (My sponsors love to be able to zoom in/out and adjust the data on the fly, I look awesome when that functionality is there)
  • The real-time reliability of it. I have had literally 0 issues with pyqtgraph being able to process a decent amount of real-time data.
  • A nice feature I like is being able to pass epoch times into the plot and it natively turning it into datetime. I've found pyqtgraph's handling on datetimes on axes to be a bit clunky if I don't go this route.
#

So for real-time, it's a combo between line and scatter. My post processing involves plotting plumes and that is done in 3D.
My data is small but it updates a few times every second. Between all my sensors and instrumentation, I think I pull 10 data points a second.

blazing pine
#

our datetime axis is definitely.... could use some love ๐Ÿ˜†

static cove
#

I was actually looking to contribute to it the next few months since my work project is diving into it again and I could definitely justify getting paid to contribute back for that functionality

blazing pine
#

we always welcome contributors... last few weeks things have been relatively idle... I needed to take a break from after-hours dev work (found myself getting really sleepy really early in the evenings), i'm looking to do another patch release shortly

#

one feature on our horizon that may be of interest to you is not having a massive performance hit when updating line plots with lines > 1px wide

static cove
#

ooooh, that I would definitely be interested in

blazing pine
#

while tinkering w/ QtCharts we noticed they were able to have really good performance w/ lines > 1px thickness, I dove into the source (yay OSS!) and saw they use QPainter.drawLines instead of QPainter.drawPath when tinkering around ourselves we noticed the drawLines method handles thick links much better than drawPath

static cove
#

Oh! One feature I was seeing if I could incorporate is figuring out how to do Matplotlib's quiver within pyqtgraph itself. I managed to cobble something together, but that's one feature I'm missing

blazing pine
#

quiver feature? you have a link/image handy?

static cove
blazing pine
#

while we have highly optimizes our numpy array -> QPainterPath code (it was already fast but we've sped this up tremendously the last 6-8 months) so going from QPainter.drawPath to QPainter.drawlines will be a performance hit, we will need to figure out how to handle this a bit more when to use what method...

#

but drawing thick lines and not having the performance plummet is probably our biggest feature request right now...can't believe we stumbled into a workaround on accident the way we did

static cove
#

Very similar to stream plot but not quite

blazing pine
#

ahh, a stream plot is something I've been thinking about (my background before CS was mechanical engineering, so I have an interest in fluid flow which can be nicely displayed w/ stream plots) but I've never been sure how well they would fit within pyqtgraph so I haven't really pursued it much.

static cove
#

I'm also primarily a fluid flow person! The work I do where I get paid has me dealing a lot with wind vectors. I had the specific request of doing a quiver, but only the data points that we have. No stream plot for interpolation. The sponsors very were touchy about interpolating wind data since our test set-up was a bit wonky

blazing pine
#

now that I'm doing a google image search for quiver plots I see what you're getting at

static cove
#

Also, I have to go. Looks like the Tornado Watch is now a Tornado Warning and I should probably get home before the worst of it hits...

#

But I'm happy to talk more about this in like an hour

blazing pine
#

i have a meeting in an hour, will be happy to talk about it more then too ๐Ÿ˜†

glossy temple
#

hello i was wondering if anyone can recommend a gui framework for a chess game? Ive looked into different comparisons of the main ones but they all just describe the project never mention any features. I need basic features like text, buttons and entry boxes but also more advanced like dragging and clicking as well as moving things, and the ability to insert shapes for the board, as well as other features a chess app would use.

blazing pine
static cove
#

@blazing pine But having a real-time quiver in pyqtgraph would be pretty stellar for me

blazing pine
#

for the record, I have nothing against that feature, and I certainly wouldn't discourage a PR to add it (and I'm fairly sure none of the other maintainers would have an issue with adding it).

#

@static cove what would mouse-interaction on the plot look like (ideally from your perspective)?

#

I guess zoom in/out makes the most sense...

static cove
#

Being able to hover on a line, get the x/y and any other details attached to it. Panning, zooming.
I know this is totally out there, but it would be super neat if there was like... an annotation mode?

blazing pine
#

"annotation mode" ...you're not the first person to bring this up...

#

and I think it's a great idea ....

glossy temple
#

Hey thanks ill start looking into pyqt now

blazing pine
#

i'm still not sure what that would look like (someone referenced the annotation mode in the matlab plot windows)

blazing pine
#

@static cove if you know of companies that are looking for software folks to work w/ flow data let me know; I'm starting to look for other work, would love to be able to put my mechE education to work

digital rose
#

@static covehey mate you free

real wyvern
#

does anyone know a UI framework that supports reinitialization from the same python shell without thread restrictions? ex: without reopening python at all, run a ui script, fully close all the windows, run it again and it works?

static cove
digital rose
#

I'm trying to figure out how to implement signals and slots to the program

static cove
#

just to practice signals and slots or to do something specific?

digital rose
static cove
#

So for this you don't even really need signals/slots yet. You just need the second window to have a reference to the first. Which I think my code walks you through

digital rose
#

I have a second one which contains the pause button

static cove
#

Let me see if I can create a quick example

digital rose
#

Appreciate it

static cove
#
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QLabel, QWidget, QHBoxLayout, QVBoxLayout

class FirstWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.label_a = QLabel("First Window")
        self.label_b = QLabel("Current Status: Stopped")
        self.second_window_btn = QPushButton("Open Second Window & Start", clicked=self.show_second_window)
        
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.label_a)
        self.layout.addWidget(self.label_b)
        self.layout.addWidget(self.second_window_btn)
        self.setLayout(self.layout)
    
    def show_second_window(self):
        self.second_window = SecondWindow(self)
        self.second_window.show()

class SecondWindow(QWidget):
    def __init__(self, parent):
        super().__init__()
        self.parent = parent
        self.start_btn = QPushButton("Start", clicked=self.start_parent)
        self.stop_btn = QPushButton("Stop", clicked=self.stop_parent)

        self.layout = QHBoxLayout()
        self.layout.addWidget(self.start_btn)
        self.layout.addWidget(self.stop_btn)
        self.setLayout(self.layout)

    def start_parent(self):
        self.parent.label_b.setText("Current Status: Started")

    def stop_parent(self):
        self.parent.label_b.setText("Current Status: Stopped")

app = QApplication([])
w = FirstWindow()
w.show()
app.exec()

Take a look at this code and you'll see how from the second window, I can control text on the first. This is done with a simple reference to the first window. So the second window can control things on the first with that reference, which is self.parent = parent in the __init__. Let me know if you have questions

digital rose
#

and would button attributes of each class allow me to have an effect on let's say a LCD timer output

#

to pause it or play it

pseudo folio
#

How do I control the minimum distance someone can move an item in the MouseMoveEvent in PyQt? ( For example, I want the user to only be able to move an item in units of say 10 pictures.)

fossil bronze
#

i'd like to plot continuous wavelets (i'd use pyplot.matshow(coef, fignum=1, aspect="auto") in jupyter) but in pyqtgraph instead, anyone know how to do that?

steel wagon
#

If anyone is familiar with tkinter would you spare the time to see if you could help with my question in #โ˜•help-coffee would be incredibly helpful ๐Ÿ™‚

fossil bronze
#

cm for the user? pixels? some imaginary unit?

pseudo folio
#

So they cannot be placed in between grid lines.

fossil bronze
#

that doesn't really answer the question

pseudo folio
fossil bronze
#

you know those two can differ widely and strongly depend on your physical device you're working with, right?

pseudo folio
#

I want to give predefined points or grids for items to "snap" to. The distance is likely not going to change.

fossil bronze
#

you could just take the position of the mouse and // gridsize

#

or round()

pseudo folio
fossil bronze
#

maybe rather check the position of the mouse on mouse release event

pseudo folio
fossil bronze
#

then you can "snap" to the grid from there

pseudo folio
fossil bronze
#

yeah, but you probably only need it on release

pseudo folio
#

If the mouse is dragging an item, I could check the item position instead, correct?

fossil bronze
#

yep

pseudo folio
#

OK great.

#

Thanks.

fossil bronze
#

wait

#

item position?

pseudo folio
fossil bronze
#

you don't work with item position while dragging, the item moves relative to the mouse

fossil bronze
#

so if your item has width and height, you can add/subtract that from your mouse position

pseudo folio
#

Got it.

fossil bronze
#

position and distance are very weird concepts in computers ๐Ÿ™‚

#

you always need to keep in mind what is your point/frame of reference

#

and the position of an item depends how you define it (some take the center, some take a corner)

fossil bronze
#

translating from pixels to cm is another can of worms

pseudo folio
#

Or might have two ends if it is a line.

fossil bronze
#

you need the physical resolution of the screen for that

pseudo folio
#

I do not need to translate to cm.

#

In this case.

fossil bronze
#

ok

#

units in blender, CAD etc are basically arbitrary

pseudo folio
fossil bronze
#

now, how to visualize continuous wavelets in pyqtgraph? anyone? ๐Ÿ™‚

steel wagon
#

If anyone is familiar with tkinter would you spare the time to see if you could help with my question in help-coffee would be incredibly helpful ๐Ÿ™‚

digital rose
#

@fossil bronzeoi

blazing pine
# fossil bronze now, how to visualize continuous wavelets in pyqtgraph? anyone? ๐Ÿ™‚

there is a "scrolling plots" example in the pyqtgraph library that you can take a look at; granted one of the examples right now is currently broken (there's an open issue already) but it should give you a place to start

here's the code: https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/scrollingPlots.py

if you have pyqtgraph installed already you can run this code by running

python -m pyqtgraph.examples and selecting the "Scrolling Plots" and hit the run button.

blazing pine
#

the code there generates the following plot

fossil bronze
#

@blazing pine thanks so much for replying, i already thought of poking you directly ๐Ÿ™‚

#

i can give you an example of what i'm dealing with, hold on

#

this is how it looks for me

#
coef, freqs = pywt.cwt(data, range(1, 50), pywt.ContinuousWavelet("gaus1"))
pyplot.matshow(coef, fignum=1, aspect="auto")
pyplot.colorbar()
``` that's the code
brave belfry
cursive basin
#
If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
#

QGraphicsView().setMouseTracking(True)

#

class MyQGraphicsView(QGraphicsView):
    def __init__(self):
        super().__init__()
        self.setMouseTracking(True)
    def mouseMoveEvent(self, event):
        print(event.windowPos().x(), event.windowPos().y())
cursive basin
#

@brave belfry

stable mountain
#

Hello could some one help me who knows tkinter i want to make 4 cubes at each side of a window so a cube at a left side right side and left down cube and right down cube

#

I want to make it like this but idc how

tranquil jasper
#

thinking of havnig GUI for a python program , i looked for tkinter. But before diving into it, i was wondering if giving time to learning tkinter would be worth it, considering its use in the industry?

tawdry mulch
tawdry mulch
tranquil jasper
#

nope

tawdry mulch
# tranquil jasper nope

So yea, tkinter has alot of fundamentals that can get you started with GUI and event loops

blazing pine
#

I jumped into Qt as my first GUI framework, never wrote a line for tkinter, I'm sure it's used someplace ... it has some benefits with respect to Qt, probably would look at what the respective trade offs are

#

but generally speaking, I don't think there are that many commercial tkinter applications out there...

tranquil jasper
#

thats the reason i have this question

tawdry mulch
#

I myself, have never went through a tutorial for PyQt but yet I am able to make GUI with PyQt, all I know is tkinter and it made me understand how event loops and event driven programming works. I can create most types of GUI in PyQt now given that I know all the elements to be used.

#

PyQt is OOP based, if you do not know that, tkinter is a very good place to start with procedural code and then slowly move into OOP

blazing pine
#

I mean, any time you learn multiple frameworks you're going to get better at both... for example, my Qt skills improved when I learned Swift + UiKit

#

tl;dr there is no good/bad answer here, do what you want ๐Ÿ™‚

tranquil jasper
#

so thats there too

tawdry mulch
#

Do you know OOP?

tranquil jasper
#

yep a bit

blazing pine
# tawdry mulch Do you know OOP?

ha, Qt was actually my first dive into OOP, it worked well as each GUI widget was its own object/methods and really detailed how inheritance worked

tranquil jasper
#

but i mean would it be worth the time learning tkinter and not electron js?

tawdry mulch
#

Hmmm maybe you can start with PyQt, and then if you feel difficult move down

tranquil jasper
#

im confused what to choose b/w these. Sceptical about tkinter's use in the industry

tawdry mulch
#

Personally I would say you start with tkinter because you learn diff ways to do stuff, and then in PyQt it is all inbuilt, and much easier. So you are progressing forward, anyhow

blazing pine
#

there is no consensus in industry

tawdry mulch
#

It is just a learners tool nowadays

blazing pine
#

each framework has its own downsides and benefits

tawdry mulch
#

It is used it pythons IDLE and also I think Komodo IDE

tranquil jasper
#

im a bit inclined towards electron js just because i 'see' it in use ๐Ÿ‘€

tawdry mulch
#

Python is not meant for GUI, yet there are many great frameworks out there

#

I am 99 percent sure, that you would not be wasting time learning tkinter as it is much bigger than you think and will help you as a great start on GUI

#

Yes I am 100 percent sure, but 99 is just so that you don't end up suing me later ๐Ÿ˜› and also cuz different people are built different

tranquil jasper
#

haha ty for that.
lets begin with tkinter then

#

ty for your time coolCloud and j9ac9k

stable mountain
#

Hello i want to make this but ad far i did only the top blue and down green

#

Here is my code ```py
import tkinter as tk
root=tk.Tk()
width=400
height=400
canvas=tk.Canvas(root,width=400,height=400)
canvas.pack()
ย 
#pravljenje plavog kvadrata
kvadrat1=canvas.create_rectangle(0, 0, 100, 100, fill='blue', outline='blue')
#pravljenje crvenog kvadrata
kvadrat2=canvas.create_rectangle(300, 300,400,400, fill='red', outline='red')
ย 
ย 
#funkcija koja pokrece kvadrate na ekranu
def redraw():
ย ย ย  kordinate_kvadrata1 = canvas.coords(kvadrat1)
ย ย ย  kordinate_kvadrata2 = canvas.coords(kvadrat2)
ย ย ย  if (kordinate_kvadrata1[1] >= height or kordinate_kvadrata2[0]>=width):
ย ย ย ย ย ย ย ย ย ย ย  root.after(1, root.destroy)
ย ย ย ย ย ย ย ย ย ย ย 
ย ย ย  canvas.after(50,redraw)
ย ย 
ย ย ย  canvas.move(kvadrat1,5,5)
ย ย ย  canvas.move(kvadrat2, -5,-5)
ย 
redraw()
root.mainloop()

#

If some one can help me make the yellow and red cube i rly dont know how

tawdry mulch
twin crater
#

Hello, I'm looking for some way to integrate two windows into a frame widget.

#

So, I have the first Script that generates these 2 widows, but I want to import them into my tkinter GUI and insert them into a frame when a Button is pressed. How could do this?

twin crater
#

not a tkinter window()

proven basinBOT
#

:incoming_envelope: :ok_hand: applied mute to @frank whale until <t:1630605907:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

twin crater
#

Do you have any approach to do this?

tawdry mulch
fossil bronze
#

simply because it comes with python

tawdry mulch
brave belfry
#

the next issue I am having is enabling the user to draw resizable rectangles between the point where the mouse was clicked to where the mouse was released. As far as I understand QPainter cannot be used with QGraphicsView and simply using the addRect method upon mouse move seems to crash my program probably due to too many rectangles being drawn. Anybody got any suggestions for this?

fossil bronze
tawdry mulch
brave belfry
blazing pine
#

tkinter applications are likely used in industries where installing dependencies are tricky; and there is value in having something only need the python interpreter

cursive basin
#

is there a way to customize this pop up for hiding the docker in QMainWindow without like create it from whole through createPopupMenu

eager beacon
#

That looks like a QToolBar popup, is that right?

cursive basin
#

currently it doesn't show a text for what is it hiding

eager beacon
#

What is it actually hiding?

cursive basin
eager beacon
#

oh

#

as far as I know you'll have to use createPopupMenu
and set an action with whatever text you want it to display

#

You might be able to get away with setting a QMenu and a contextMenuPolicy but I'm not that familiar with Dockwidgets

cursive basin
# eager beacon as far as I know you'll have to use `createPopupMenu` and set an action with wha...
    def createPopupMenu(self) -> QtWidgets.QMenu:

        menu = QtWidgets.QMenu()
        dock_action = QtGui.QAction("Hide Docker", self)
        dock_action.setCheckable(True)

        def dock_action_func():
            if dock_action.isChecked():
                self.initialise_right_docker()
            else:
                self.removeDockWidget(self.right_docker)
        dock_action.triggered.connect(dock_action_func)
        menu.addAction(dock_action)
        return menu

alright i did this but it doesnt pops when right clicked on the menu bar

#

eh leave it fixed

eager beacon
#

what was the problem?

twin crater
#

Does anybody know how I could get the index of a Combobox option selected?

#

i mean, if the values of the combobox is a List, how could I get the index of the selected option?

#

i've tried this but it does not work: py camBox=ttk.Combobox(fAct, values=user_list, width=20) camBox.place(x=140,y=50) user_selection=camBox.get() user_index=user_list.index(user_selection)

tawdry mulch
blazing pine
#

so, I'm migrating my project from PySide2 to PyQt5 for #reasons; but I'm stuck on one behavior I'm not sure how to work around.

I had something like ...


myQThreadSubClassInstance.disconnect(myQObjectSubclassInstance)

basically, I was trying to disconnect all signals from a specific QThread instance that were connected to another QObject subclassed object...

this was fine in PySide2 but PyQt5 raises errors ...

TypeError: arguments did not match any overloaded call:
  disconnect(QMetaObject.Connection): argument 1 has unexpected type 'Spectrogram'
  disconnect(self): too many arguments

I've tried a bunch of variants (disconnect() with no args for example) but I'm not able to get it quite working; any suggestions?

#

with no args:

    self.spectrogramController.currentThread.disconnect()
TypeError: disconnect() of all signals failed

also tried with passing the signal name in string form QThreadSubclass.disconnect("signalNameAsStr", self.slot)

    self.spectrogramController.currentThread.disconnect("sigSpectrogramComputed", self)
TypeError: arguments did not match any overloaded call:
  disconnect(QMetaObject.Connection): argument 1 has unexpected type 'str'
  disconnect(self): too many arguments
#

at this point, I'm considering wrapping the disconnect call w/o any args in a with suppress(TypeError): and see if that works better

eager beacon
#

I went through this a few months back but ended up reverting the code so I don't have it anymore. It was a huge pain to figure out how to get it working correctly. I remember I had to use QMetaObject.Connection in the call to disconnect

blazing pine
eager beacon
#

Neither had I and from what I remember the documentation wasn't super helpful

#

I ended up looking for examples on github to see how it was being used before I got it working correctly

blazing pine
#

that's what I'm doing just now, and remarkably, I'm seeing zero examples in python

#

@eager beacon thanks for sharing; I felt like this was a bit of a too specific ask for this community, clearly I was mistaken ๐Ÿ˜†

eager beacon
#

Sorry I couldn't be more helpful.. I even grepped through my git history but apparently i never even added the changes ๐Ÿ˜ฆ

blazing pine
#

it's fine, seeing some stack overflow examples I think I can sort this out...

eager beacon
#

I hope you find something thats easier to implement that what I had. There must be a better way to go about it, but all of the simple ways that i found where people mentioned it had worked for them no longer worked for me.

blazing pine
#

i got it!

#

wasn't too bad at at all...

eager beacon
#

What did you end up with?

blazing pine
#

two different files...

        metaSpectrogramComputed = spectrogramCalcThread.sigSpectrogramComputed.connect(
            self.plotView.spectrogram.newSpectrogramImage
        )
        metaSpectrogramCalcThread = spectrogramCalcThread.sigFrameComputed.connect(
            self.plotView.logEnergyPlot.updateEnergyPlot
        )

        self.metaObjects = (metaSpectrogramComputed, metaSpectrogramCalcThread)

other file:

        if self.spectrogramController.currentThread is not None and hasattr(self.spectrogramController, "metaObjects"):
            for metaObject in self.spectrogramController.metaObjects:
                self.spectrogramController.currentThread.disconnect(metaObject)
#

sorry for the long namespace here ๐Ÿ˜›

#

it's the Qt way ๐Ÿ˜†

fluid mica
eager beacon
#

Yeah that looks familiar

#

You found an example on Stackoverflow?

blazing pine
#

tl;dr I saved the output of the "connect" calls; and used those references in the disconnect...

#

not an example, but a comment, let me dig it up...

eager beacon
#

Oh nice, I must have glossed over it

blazing pine
eager beacon
#

ouch, I think I probably saw that and ignored it because it was posted back in 2014 and assumed it only applied to pyqt4.

blazing pine
#

ha yeah ....that gets me all the time, now if only qtpy and fbs would get on with supporting Qt6 ๐Ÿ˜ˆ

eager beacon
#

yeah, fbs is in serious need of an update

blazing pine
#

i paid for "fbs pro" which works w/ latest qt5 + latest pyinstaller

#

it's for a work project, the money for that license easily made it worthwhile

eager beacon
#

Oh cool, I didn't even know that was an option.

blazing pine
#

yeah, for work stuff it's a bit of a no brainer

eager beacon
#

Oh cool, I didn't even know that was an option.

#

You use PyQt professionally?

blazing pine
#

I maintain an internal PyQt application at my (small) company

#

my user-base is in the couple of dozen range... not huge, but they are on all platforms, and distributing the source was a pain point I've been avoiding

eager beacon
#

Oh, thats cool, I don't come across many people who actually work with PyQt

blazing pine
#

unfortunately the last few months I've been pushed to other projects, went to tackle a bug, and ran into a variety of build issues...

#

I'm also a maintainer of pyqtgraph

#

so I work w/ Qt a fair amount (wouldn't say I know it all that well though ๐Ÿ˜† )

eager beacon
#

and yeah, with a couple of dozen users and distributing the source code... you'd probably not have much time to work on the app with all the tech support you'd be doing

blazing pine
#

my users are somewhat tech literate, they are expected to remote ssh into users and run basic bash commands....

#

but yeah, I really don't want to be talking people through setting up virtual environments a million times over

#

especially if I can give them a .exe, .app or .deb bundle

green stump
#

Is it possible for certain elements inside a QT layout to occupy more space than other elements and how do i do that?

eager beacon
#

like widgets in the same row that have a different height, or..?

green stump
#

I don't want this sort of unification

eager beacon
#

what are you trying to change?

viscid sluice
#

hello iwant to ask iam using kivy i want using dropdown function but iam cnnot using bind

#

data_1 = DropDown()
for pilihan in range(3):
delete_1 = Button(text='Value %d' % index, size_hint_y=None, height=44)
delete_1.bind(on_release=lambda btn: dropdown.select(btn.text)

#

like that

#

data_1 = DropDown()
for pilihan in range(3):
delete_1 = Button(text='Value %d' % index, size_hint_y=None, height=44)
"delete_1.bind(on_release=lambda btn: dropdown.select(btn.text)" (in hier the proablem)

green stump
green stump
#

Is it possible for certain elements inside a QT layout to occupy more space than other elements and how do i do that?

viscid sluice
#

iam using kivy and after iam using spinner i got an eroor

#

this my line

#

import kivy
kivy.require("2.0.0")
from kivy.config import Config
Config.set('graphics', 'width', '900')
Config.set('graphics', 'height', '700')
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.base import runTouchApp
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.spinner import Spinner
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput

class tampilan_app(FloatLayout):
def init(self, **kwargs):
super(tampilan_app, self).init(**kwargs)

    spinner = Spinner(text='Home',
                      values=('Home', 'Work', 'Other', 'Custom'),
                      size_hint=(None, None),
                      size=(100, 44),
                      pos_hint={'center_x': .5, 'center_y': .5})

    def show_selected_value(spinner, text):
        print('The spinner', spinner, 'has text', text)
        
    spinner.bind(text=show_selected_value)

    runTouchApp(Spinner)

    add_note = Button(text="Make note",
                      color="red",
                      size_hint=(.1, .05),
                      pos=(15, 650))
    self.add_widget(add_note)

    delete_note = Button(text="Delete note",
                         color="red",
                         size_hint=(.1, .05),
                         pos=(400, 650))
    self.add_widget(delete_note)

    edit_note = Button(text="Edit note",
                       color="red",
                       size_hint=(.1, .05),
                       pos=(790, 650))
    self.add_widget(edit_note)

class app_peyimpanan_scedule(App):
def build(self):
return tampilan_app()

if name == "main":
app_peyimpanan_scedule().run()

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.

brave belfry
#

in PyQt is there a way of enabling QGraphicsView dragging and mouse move event at the same time

#

I would like to enable mouse coordinate tracking at the same time as being able to pan the image etc (ignore the placeholder image lol)

distant swift
#

Please someone explain to me what this error says:
TypeError: descriptor 'fbind' for 'kivy._event.EventDispatcher' objects doesn't apply to a 'str' object

eager beacon
brave belfry
#

yes

eager beacon
#

Then that means that the X/Y values do not change since when you pan the image, the mouse grabs the PixmapItem and moves it around the view

#

The X/Y values are not that of the graphics view but the current position of the mouse cursor over the pixmap

rain spade
#

This pinned link is dead

twin crater
#

Does anyone know how I can change the value of a variable "x=cv2.VideoCapture(0)" belonging to a script, lets call it A, and from a script B, pick the argument of variable x, (which is 0), and change it to another one?

green stump
#

Is it possible for certain elements inside a QT layout to occupy more space than other elements and how do i do that?

eager beacon
#

You can use a grid layout and set the column/row stretch or you can set a minimum height or width on whichever widget you want to change.

#

you can also set a minimum row/column size with a grid layout for each col/row in the layout

#

you can do all of that in Qt Creator/Designer

green stump
#

Btw, I haven't been able to find Qt Creator

#

Is it paid?

eager beacon
#

No, its not paid but it usually comes bundled with the C++ installer although you can find it as a standalone by googling for 'QtCreator offline installer'

#

heres a simple example of the row/column stretch in creator

green stump
#

Okay thanks! do you recommend it for pyqt dev?

eager beacon
#

yes, PyQt or Pyside are the best options

green stump
#

I mean do you recommend Qt Creator for pyqt?

eager beacon
#

Oh, i misread that.. Yes, it can speed up your design a ton

green stump
#

gotchu!

eager beacon
#

Designer is pretty much the same thing without the code editor though so you could stick with that.

#

I'm not sure how good the editor that comes in creator is for python code