#user-interfaces
1 messages ยท Page 81 of 1
Uhhh sure, let me get to my computer
okay
brb
My code is above if you wanna do it I'll be back gotta do something
ok back
Okay, I'll post a shortened snippet, just so it's easier to see what's going on
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"
)```
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()
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
Is there a way to make vsc do what idle does
because I have to use idle because vsc doesn't open the boxes
hmmm... let me test it in VSC
ok
What boxes is it supposed to open?
hmmm, it's opening up for me. Let me check something
ok
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?
just make sure the path is specified to your file
So! To get a Label or another widget to update based on a variable, you want to use a special tkinter class, called StringVar
example?
typing up one now~
okk
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
happy to help~ Feel free to ping if you have any questions or hit some blocks
okay
ty
Actually
I will message you some time about how to publish this on the play store
That is not something I know much about unfortunately
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
So a StringVar is used in a Label, not in the grid itself
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
Sooo it would be:
money_var = StringVar()
money_label = Label(textvariable=money_var)
money_label.grid(row=0, column=1, columnspan=2)
Not really? There is a config method too
coolcloud
yes?
can you do it for me
What is your code
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
@digital rose This should work
I don't understand where I would put my stuff though
could you add the required thing to mine
Where is your code
I sent it
Can you please send again
current_money = StringVar()
current_money.set(f"You currently have {money}$")
current_money.grid(row=0, column=1, columnspan=2, sticky='')```
Do you have a label
StringVar is not a widget so they cannot be grid. They must be associated to a widget.
okay so what would I do
You should be asking that to your self, I do not know what you want. Usually people want a label, prolly you too
what the fuck
what
You can create a label and associate it with this stringvar
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
I think you should explain what all you have so far
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
Look at you, you just broke a rule
Why are you getting so mad because you dmed me a invite to a server
Because you act up all informative about rules, but dont follow one yourself
Rule is a rule bruh.
Says nothing about profanity
ok
Also you're getting blocked for an unannounced server invite.
noo, please dont block me...?
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.
dababy profile pic, definitely a kid
its literally a meme, you would expect normals to have it
!ot
Off-topic channels
There are three off-topic channels:
โข #ot0-psvmโs-eternal-disapproval
โข #ot1-perplexing-regexing
โข #ot2-never-nesterโs-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
why is my PyQt5 window only showing for a second when i do .show()
maybe some error..?
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()```
@odd iris use ttk instead of tk
where? the import? or window = tkinter.ttk?
zankyu
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
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.
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
...
tkinter.ttk.Button instead of tkinter.Button
whats the difference between tkinter and tkinter.ttk
Android ui? Kivymd are kivy widgets styled as per material.io if thats the sort of thing you're after
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()
So i am getting the _tkinter.TclError and i don't really understand what is wrong. So could someone please tell me ?
show your imports
Open your image with any image editing app, maybe paint, and then save it again as a png and try using that image
@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!
@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.
It basically means that the image is not a valid png image, i guess
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()
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()
why doesnt that work?
what doesnt works?
self.textCursorPostionChanged.connect(self.foo)
looks pretty fine to me
do dir(self)
to see what exactly it is
becuase nothing exists like that
i am asking if there is something like that
?
ok
wait
the imgs are transparent but in the program int's not
๐
plz give me a solution
help plz
are you using tk?
found it is cursorpositionchanged
yes
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()
help bro
which image
there is it
only canvas.create_image supports RGBA(transparency).
can you explain more
If you want it to be transparent, then use a canvas to show the image, no other can widget can show the transparency of images
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
PyQt Kivy
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.
@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
Do someone can help me?
@digital rose
Maybe.. whats your question?
(I'm new to Qt Designer)
hey, So the problem im getting is i've added a background-image to the QmainWindow and now whenever i add any label or anything, it copies the background image of the qmainWindow.
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,
try to add a background color to the stylesheet of the lables/...
ive tried it
because with no backgroudn color it could be transparent
let me send you a screenshot
kk
ok lemme do some research
ok
i tried to recreate your problem but when i try to add a background image it does not even show up. wtf
You need to add the resources first
yes but i my image is a .png and not .qrc and then i cannot add it
You can add it,
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
@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.
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
do someone know how to solve this?
(TKinter Related) How do i get the current value of a Combobox?
Anyone know why my PyQT5 emits are randomly taking 1000x as long? 0.02ms vs 20ms? I can provide details if you need
.get()
Hi! Yes! This is an okay resource for generally understanding some terminology: https://runestone.academy/runestone/books/published/thinkcspy/GUIandEventDrivenProgramming/01_intro_gui.html
It uses tkinter as an exmaple, but the concepts should be able to translate over
I changed it to DirectConnection on the connect side of the signal and it worked much better
Thank you!
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
@mystic crescent make a hybrid layout by combining more than one layout
Oh,right! Thanks
What is the setting to set those layouts to autoresize?
For the bike logo, username text field, password field, and login button use QVBoxLayout
You can get creative with the other widgets
i would move the caret to the right a little more
its the white line
Anyone recommend a good GUI library for python that works on linux?
I'm running arch linux with I3
Major cross-platform (Windows, macOS, Unix-like) GUI toolkits are available for Python:
https://docs.python.org/3/library/othergui.html
thanks
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?
Just like how you would store any other thing in python
Is it possible to get transparent blurred background in tkinter just like the new windows 11 ui?
@digital rose i think https://github.com/Peticali/FluentTkinter
Thank you very much
@plush stream and also if there is any thing with the rounded buttons in tkinter
I don't use tkinter that much so idk sorry
While making a wxpythoj windows app..can i include all my functions inside frame class ?
Even those who are not event driven.
Is that possible?
give me some resource to learn ui ux
Yes of course! You can set the padding in the stylesheet.
Is interpolated animation possible in pyqt
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
no, vl have to make ur own
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
I was using the wrong names ๐ For an hour ๐ Figured it out
QEasingCurve
@marble island You may also like to investigate Kivy if you haven't already.
How to keep a Kivy window always on top?
@distant swift ^^
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) ?
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?
So you could have the function essentially be a while btn.isDown(). isDown is a property available for any of the buttons
The clicked could start the function and it'll only run while that's true
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
can you print event for me?
print("reached")
print(event)
state = self.home_ui.key_2.isDown()
while state:
print("yesss")
state = self.home_ui.key_2.isDown()```
key_2 is your QPuishButton?
yes
Why don't you use the signal pressed instead of mousePressEvent?
Ok, let me try that
here's how to code looks now But it prints out the "yesss" infinitely and make the UI unresponsive
You want other aspects of the UI to update while the button is being pressed down?
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
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
So if you want something to have in the background, but still have other parts of the GUI be responsive, you need to use threading
That's just the basics of working with GUIs
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
Right now with this code, it does print "yesss" when i press the button but it never stops, it just infinitely prints that out,
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
so that's you wanting it to do something while the GUI is doing something else. You need a thread for that.
Okay, thank you,
does anybody know something better than tkinter cause i want to make a pretty simple UI but cant find what im looking for
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?
Check the channel description! Some good libraries mentioned there
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
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')
Well, it is, however, it's just defined as a simple variable which will be gone by the time the constructor is done with it's tasks, so you would want to make widget an actual instance attribute by prefixing it wiht self. when declaring it (and using it) in the constructor (__init__)
wait so just widget is a standard variable that cant be used in buttonRelease() because its only in the scope of the __init__?
Yes
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?
I think it is called context menu
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
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() ?
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?
(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
Those are emulated presses for multiple fingers, can remove via config
how to store text in textboxes in tkinter
yes
ok
This isnt Entry.
its nowtworking
What?
?
text = Textbox.get()```
ok
Bro, this isnt tkinter...?
;
It is.
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)```
That? No way
is something wrong here
Yes, usrnm is ''
You are fetching the value as soon as the box is created, hence it is empty
Read about event driven programming
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)```
here
He asked about how to store the value from a textbox in a variable
Textbox = Entry(root, colum= whatever, row=whatever)?
Dont mind the whatever part
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
Still the code given was wrong, there are no arguments colum or row for Entry widget.
Ah its fine, appreciate the effort
def save():
usrm = a.get()
pwd = b.get()
web = c.get()
i claimd chat #help mango
that was unnecessary, anyway carry on
def save():
usrm = a.get()
pwd = b.get()
web = c.get()
looks fine
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
a,b,c is created inside newwindow and save does not know it exists, so you should say global a,b,c inside newwindow.
global variable?
2nd of all your a,b,c is not shown into the screen
yes
third of all, newwindow = Tk() should be newwindow = Toplevel()
I told you what to do.
currently editing
def save():
global a,b,c
usrm = a.get()
pwd = b.get()
web = c.get()
No, inside newwindow
Bro why is your window and function name same
Anyways why use python for UI s?
is that problem
in the future, maybe
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
seems fine, run and check
But as I said, you are not putting those widgets onto the screen
Bro, a.place(x=20,y=0) bla bla
it put it on win1 on on win2?
Whereever it is created
Bro you know what, do a proper tkinter tutorial, they will explain everything. Slowly move and make progress
link?
Otherwise it will be very hard for you
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...
that thing is where i got my tkinker knowledge
Watch more videos and practice?
bye
myLabel = Label(newwindow, Text="Password")
myLabel.place(x=125, y=80) is this command wrong
How to remove :< (just had a pretty bad day thanx to my irl frends, all hail discord)
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.
On a regular day, I wouldn't recommend learning from him. Does not explain the "concepts" and has some bad coding practices taught there too.
yes i agree
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
he teaches just the basics
I mean if you are looking to build on GUI(as a dev), then no more python.
yes
but java to comppli
I remember I had to spent hours, not knowing what the issue was when the issue was with him not explaining properly
ah good documentation is important
also try making a new .py and run this one line of code: import this just copy and paste
Yea I know this
its mentioned in the PEP ones
hmmm yea
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()```
abc is an Entry widget, not a string so it will never be equal to "hello_boi" thus if abc == 'hello_boi' will always be false
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)
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
instead of clearing the screen, use \r to return the cursor to beginning of line
In [32]: print("hello\rhi")
hillo
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?
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
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?
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
@young yoke thanksssss boi
Also which is the best module thingy for gui. THe most modern, clean and prefferably simple
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
tkinter?
yes
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:
how to have internal gui with python?
use tkinter
use tkinter
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...
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
to kivy
where the hecc is my pyyqt5 designer
u want location?@digital rose
Hi, how are you?
I am just asking
its quite deep
my qt_tools folder is empty
@tawdry mulch
quite deep was a really good explanation
thanks :D
i check its not in there
yea i know ๐
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 ..
You can save anything to variables by assigning it to them, var = 'WhateverFileObject'
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 ?
Need to see how you are getting the file
ohh
in this case, I am pulling in the data from a yaml file . Getting to the values in the yaml is not an issue for me, it is getting the string 'ctrl' to be added to a key combination for pynput
Any specific reason you chose yaml?
mostly for ease of reading the file for humans and it lets me structure stuff in a way that I like
Anyway show the code please, is ctrl coming out as a string?
here is what my code looks like so far
`def usekeys(keyconfig):
numkeys = keyconfig.get("numkeys")
keyiter = 0
while keyiter < numkeys:
keyiter+= 1
sley = keyconfig.get(keyiter)
keyinput = pynput.keyboard.Key.skey`
What is the error
When I am running this in the debugger, skey= 'ctrl'
and the error I get is
Exception has occurred: AttributeError skey
How would you set the key normally?
keyComb = {pynput.keyboard.Key.ctrl, pynput.keyboard.Key.alt, pynput.keyboard.KeyCode(char='w')}
Will pynput.keyboard.KeyCode(char='ctrl') work?
no, it only accepts 1 character or a number
Idk pynput, so is there any other way to set keys? Other than these
found a place that has key code mappings - that lets me use keycode(105) for ctrl
There are plenty of ways that come to my mind, like you can check if the key is ctrl and then Insert 105 or you can Create a dictionary and map Ctrl to 105.
Is there any reason you use pynput and not keyboard
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
Mmmmm, what all keys are allowed, just Ctrl?
so the idea is to allow any arbitrary combination of keys - so in my earlier example I was looking at ctrl+alt+w
Mmmm out of ideas for now, and I gtg. I'll take a look when I'm back
Read through pynput documentation for ways to set keys and you might get something
Then what's the use of yaml file?
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
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
And what happens when the click this
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 .
So the inputs(shortcuts) are basically expected to be inputted within the tkinter window right
.ie, while the window has focus
so the key combination(ctrl+alt+w for example ) will be entered when you have any window active , then the tkinter box will appear for you to enter the layout number and press enter (which will close the tkinter entry ) , and then the window you had active will be moved to thelocation defined by the layout
"...will be entered when you have any window active....": you mean any tkinter created window?
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...
Ah kay, you could use keyboard too
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
interesting.. and that hotkey will be picked up by the application even if it does not have focus?
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
yep
Thanks
Try it out ๐
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)
Try referring to this: https://github.com/nihaalnz/PassLost/blob/main/main/main.py#L187-L198
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))```
for i in range(0, row_count):
self.Table.insertRow(i)
for j in range(0, column_count):
item = QTableWidgetItem(data[i][j])
self.Table.setItem(row_count, column_count, item)
Might work for you
With this I still get a table with no value in it but it also only have 1 colum while the data for my test is 4 rows and 3 columns
might be because you are not getting correct data? Try printing it
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
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
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?
what do you use for your gui ? tkinter ?
@regal heronyes
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
Anyone?
i was following a tutorial
they didnt exactly explain the differencesd clearly so i am confused
@regal heroncan u show me how to do thast
Ah, can you try with the method I did, using enumerate()
What is your code, that does this
No sorry I have never used tkinter. To get you started make sure you understand classes and objects
Same result, enumerate() only change how you get row and column indexes
: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).
@tawdry mulchwdym?
Yes I was asking you to do a different approach
Show the code
@tawdry mulchi did look at dms
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?
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
guys whats like a good library to use for making complicated UIs
for example: dashboards, something like discord etc
modern flat design
I think you can use PQT or Kivy is also popular
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.
there is matplotlib for desktop apps. The web has multiple javascript libraries
I saw people were using unity
Yeah but my javascript knowledge is real bad, I'll check out matplotlib. Thanks!
depends on your situation. If you want web - javascript is your choice
Not necessarily, I just want to look at a graph for now. What ever it is generated by ๐
ah, then - matplotlib
๐
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 ?
Hey so i have a system tray code thing working but the code below it wont run
ui code
voice assistant code
pqt is too heavy. i should check kivy tho ive been minding to check it for months
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.
wow
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?
I can send you some resources but use pyQt5
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.
What error
No I do not think so
: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).
: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).
finished my first app
https://github.com/gr-imm/password-generator
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
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.
# noinspection PyBroadException add this line above the class you are using
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
in my case when using @QtCore.Slot() it highlighted it as warning and when I used connect
I mostly wanted to hide the error from from __feature__ import snake_case, true_property
oh
Might be better asking in #web-development rather than UIs
: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).
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
im not able to find the proper xpath :(
oi
hullo
thanks for taking the time to help out mate
@static covehttps://www.codespeedy.com/digital-stopwatch-gui-application-in-python-pyqt5/
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
so what does your code look like now?
!paste you can also use our paste site
With GUIs it's hard to not get it to look weird
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.
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
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()?
@static covemy bad mate just went to pray
no worries! I'll be around for at least another hour
ya about that when I seen that init was already in the other method
I was confused
You can just put the stuff in the second __init__ into the first and have it all together
because I used a layout from another tutorial it was good but she didn't haven't the functionality I needed.
where's self.play_break
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
I see
haha, GUI stuff takes a bit to get used to. You're fine~
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
hi hi
So does that create the new window and all that jazz? Whoo!
Did you add the self.play_break.show() below that?
but doesn't switch windows
ya
like in line below setcurrentindex
So the issue now is that it creates the window, but doesn't switch to it?
actly
exactly
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?
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
So just hiding the button?
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
So you want to hide the Play button, open a new window which will have the Pause button?
How will the play button reappear? When the first window is closed or when the pause button is pressed?
that's what I wondering
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
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?
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
just removes it totally from sight
go get some sleep. take care.
feel free to ping me tomorrow if you need more help or have questions~
PyQt5 problems...
Link to a message in #๐คกhelp-banana
#๐คกhelp-banana message
(its fixed now)
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
@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
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)
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...
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)
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!
@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.
good call on migrating the discussion here
was mostly curious if you're using line plots, scatter plots, 3D capability, and how "big" your data is (and how frequently it updates)
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.
our datetime axis is definitely.... could use some love ๐
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
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
ooooh, that I would definitely be interested in
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
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
quiver feature? you have a link/image handy?
link: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.quiver.html
let me see if I can find an image, but it's essenitally an easy way to plot 2-D vector data with magnitude expressed by scale.
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
Very similar to stream plot but not quite
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.
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
now that I'm doing a google image search for quiver plots I see what you're getting at
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
i have a meeting in an hour, will be happy to talk about it more then too ๐
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.
Qt can definitely do that; depending on how much control you want over the board that's being drawn, you can do it as a simplified QGridLayout, or if you wanted more control over how the board is drawn, you can use a QGraphicsView bit
@blazing pine But having a real-time quiver in pyqtgraph would be pretty stellar for me
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...
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?
"annotation mode" ...you're not the first person to bring this up...
and I think it's a great idea ....
Hey thanks ill start looking into pyqt now
i'm still not sure what that would look like (someone referenced the annotation mode in the matlab plot windows)
@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
Will do!
@static covehey mate you free
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?
hey, what's up?
sorry to bother
I'm trying to figure out how to implement signals and slots to the program
just to practice signals and slots or to do something specific?
to do that specific thing you were explain with the code last time.
@static covehere
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
what do you mean by second window which has reference to the first
I have a second one which contains the pause button
Let me see if I can create a quick example
Appreciate it
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
Thanks mate
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
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.)
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?
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 ๐
distance in what sense?
cm for the user? pixels? some imaginary unit?
Like how in a CAD program there is a grid and items 'Snap" to it.
So they cannot be placed in between grid lines.
that doesn't really answer the question
Either CM or pixels would be fine.
you know those two can differ widely and strongly depend on your physical device you're working with, right?
I can use pixels.
I want to give predefined points or grids for items to "snap" to. The distance is likely not going to change.
Can you point me to an example of what you mean? I am pretty new to pyqt.
hmm.. https://stackoverflow.com/questions/41688668/how-to-return-mouse-coordinates-in-realtime maybe?
maybe rather check the position of the mouse on mouse release event
ARe you proposing dividing the mouse position by the grid size to figure the closest "grid point", then set the item position to that?
then you can "snap" to the grid from there
exactly
If I checked it during mouse move, then I could do something similar?
yeah, but you probably only need it on release
If the mouse is dragging an item, I could check the item position instead, correct?
yep
For example, in this program users drag pre-defined objects onto the scene, and then are able to move them around.
you don't work with item position while dragging, the item moves relative to the mouse
Oh ok.
so if your item has width and height, you can add/subtract that from your mouse position
Got it.
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)
Got it.
translating from pixels to cm is another can of worms
Or might have two ends if it is a line.
you need the physical resolution of the screen for that
Gotcha.
now, how to visualize continuous wavelets in pyqtgraph? anyone? ๐
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 bronzeoi
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.
actually on re-reading, could you provide a screenshot/image of the kind of plot you want ... oh matshow displays images, so disregard the scrolling plots example I referenced, look at the "Matrix Display" example here: https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/MatrixDisplayExample.py
the code there generates the following plot
@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
PyWavelets is a scientific Python module for Wavelet Transform calculations.
If anybody knows, upon some further digging, it would appear that pyqt's QGrapicsView does not allow the mouseMoveEvent without a previous mouseClickEvent being issued. Does anybody happen to know a workaround for this?
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())
@brave belfry
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
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?
Would you start learning thermodynamics before you learn the basic physics and chemistry๐ค
What is your code so far
nope
So yea, tkinter has alot of fundamentals that can get you started with GUI and event loops
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...
thats the reason i have this question
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
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 ๐
so thats there too
Do you know OOP?
yep a bit
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
but i mean would it be worth the time learning tkinter and not electron js?
Hmmm maybe you can start with PyQt, and then if you feel difficult move down
im confused what to choose b/w these. Sceptical about tkinter's use in the industry
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
there is no consensus in industry
tkinter is not used in industry.
It is just a learners tool nowadays
each framework has its own downsides and benefits
Yea it is quite deep
It is used it pythons IDLE and also I think Komodo IDE
im a bit inclined towards electron js just because i 'see' it in use ๐
If you want to make webapps, then yea sure learn js
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
haha ty for that.
lets begin with tkinter then
ty for your time coolCloud and j9ac9k
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
it is much easier if you visualize stuff
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?
Window inside a frame..?
not a tkinter window()
: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).
Do you have any approach to do this?
No I do not think so
you're wrong, many installers use tkinter
simply because it comes with python
Suddenly, that is industry?
Thank you so much for this!
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?
use the mouseMoveEvent there and there only
industry can be many things
ok installers, great
Hmm, thank you, I am not at home at the moment but I will look into this when I get back!
tkinter applications are likely used in industries where installing dependencies are tricky; and there is value in having something only need the python interpreter
is there a way to customize this pop up for hiding the docker in QMainWindow without like create it from whole through createPopupMenu
That looks like a QToolBar popup, is that right?
umm no like this pop is for like hiding toolBars, dockwidgets and stuff it comes with QMainWIndow
currently it doesn't show a text for what is it hiding
What is it actually hiding?
a dock widget
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
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
what was the problem?
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)
Yea this should work, but you should put the getting and searching inside a function
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
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
huh, never used that object before...
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
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 ๐
Sorry I couldn't be more helpful.. I even grepped through my git history but apparently i never even added the changes ๐ฆ
it's fine, seeing some stack overflow examples I think I can sort this out...
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.
What did you end up with?
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 ๐
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...
Oh nice, I must have glossed over it
You can save QMetaObject::Connection objects returned by QObject::connect and use them in QObject::disconnect. It's not so much extra work. โ
from here: https://stackoverflow.com/questions/21384900/disconnecting-slots-from-signals
ouch, I think I probably saw that and ignored it because it was posted back in 2014 and assumed it only applied to pyqt4.
ha yeah ....that gets me all the time, now if only qtpy and fbs would get on with supporting Qt6 ๐
yeah, fbs is in serious need of an update
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
Oh cool, I didn't even know that was an option.
yeah, for work stuff it's a bit of a no brainer
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
Oh, thats cool, I don't come across many people who actually work with PyQt
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 ๐ )
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
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
Is it possible for certain elements inside a QT layout to occupy more space than other elements and how do i do that?
like widgets in the same row that have a different height, or..?
Yeah, different length/height
I don't want this sort of unification
what are you trying to change?
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)
My bad, I want to change the size of the middle ListView to occupy more space to the left
Is it possible for certain elements inside a QT layout to occupy more space than other elements and how do i do that?
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()
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
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)
Please someone explain to me what this error says:
TypeError: descriptor 'fbind' for 'kivy._event.EventDispatcher' objects doesn't apply to a 'str' object
Are you using a QGraphicsPixmapItem to get the coords?
yes
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
This pinned link is dead
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?
Is it possible for certain elements inside a QT layout to occupy more space than other elements and how do i do that?
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
awesome thank you
Btw, I haven't been able to find Qt Creator
Is it paid?
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
Okay thanks! do you recommend it for pyqt dev?
yes, PyQt or Pyside are the best options
I mean do you recommend Qt Creator for pyqt?
Oh, i misread that.. Yes, it can speed up your design a ton
gotchu!
