#user-interfaces
1 messages ยท Page 65 of 1
@digital rose can you send me an invite to your tkinter server?
Yes
(If i understood you)
create another function with all the game content and then add py myButton = Button(root, text="Play!", pady=50, command = **yourfuncname**)
then it will link the button to the function and move to the function
ofcourse u will need to create screen2 in the new function
then paste the code of this into big function then type it in the startupgui.py
How can i run my app without pycharm?
google panda3d
go to command prompt and copy your project path then, write (if u use windows) cd 'path' in your command prompt
and write python projectname.py
python <python file>
.
but u gotta cd into it though
I explained above
What's the best UI framework to handle a Text widget like buffer?
Hii! This is new to the server a CS student ... just learning ....would you guys please help me regarding new concepts...
help with what
Its tell me about new programs how to operate them like thiss...
learn python basic then tkinter as example
i would say learn the basic even more good
then learn how to use tkinter
sure y not
mmm its some kind of libary or something that allowd you to make windows using python
buttons, inputs,labels and stuff
as example this
im using ursina not panda3d
from tkinter import *
def login_button_clicked():
login_window = Tk()
login_window.geometry("400x400")
login_window.title("Login Page")
welcome_window = Tk()
welcome_window.geometry("400x400")
welcome_window.title("Password Hasher Tester")
welcome_window_header = Label(welcome_window, text="Welcome! You can either login or register here.", font='Helvetica')
welcome_window_header.place(x=45, y=80)
login_button = Button(welcome_window, text="Login", fg='white', bg='gray', command=login_button_clicked())
login_button.place(x=180, y=180)
register_button = Button(welcome_window, text="Register", fg='white', bg='gray')
register_button.place(x=175, y=230)
welcome_window.mainloop()
i want to make it so that when i click the login_button
the login_window opens
but right now that window opens as soon as i run the program
can anyone help?
command=login_button_clicked()
Make sure to not call the function
When you want a button to run a function, you do not put the parentheses
ok i see what u mean i removed the parentheses
also another question
now everytime i click login it opens a new login window
do u know how i can prevent this? @lofty pond
like if the login window is already oepned i dont want to allow another one to open
Probably assign the window to a variable and when you press the button, check the variable.
ok thanks
im trying to make my gui class structured
does anyone know how i can make a function that opens a new window when i use it as a command for a button
Im using npyscreen and i have a weird issue
https://kitsunehosting.net/nextcloud/index.php/s/bKqAeq2ZcoTTFtR/preview
if line 22 is above line 23, it works fine, if they're the other way around, i get this
https://kitsunehosting.net/nextcloud/index.php/s/yecgJSPLGBLgTDF/preview
Code here: https://kitsunehosting.net/gitea/Kenwood/SNHU-IT-140/src/branch/npyscreen-adventure-game/Adventure Game/adventure_game/main.py
Im just very confused~
I'm using tkinter to make an application, and for the application I am making a custom title bar. I used overrideredirect(1) to get rid of the native OS title bar, but how would I go about adding the program back into the native Window Manager so that it shows up in Task Manager and on my Taskbar. I don't want the native title bar to reappear though, and that's where I am stuck.
Best answer I can give you: http://tkinter.programujte.com/tkinter-dialog-windows.htm
Either that, or use a Label() as an alternate titlebar. Then you have to bind() several events to achieve the same result.
So this will let me change the color, correct?
You can change the color of the label if you go that route.
Alright, Iโm thinking about just switching to PyQt... I only have a couple buttons in my UI right now, still have a lot to go. Would you recommend this?
It seems to better handle what Iโm trying to do
I dunno. I've been messing with tkinter for awhile now. I've gotten pretty far myself:
https://github.com/ayourk/HostsManager/blob/main/hostsman.py
It's a text editor I'm working on. Still have a ways to go. I think I'm 60% of the way done.
I don't know PyQT
Looking good so far. Qt seems to better suite me I feel now that im really thinking about it. I want a nice looking UI and tkinter makes that hard to do.
yup
its easier to make better looking GUI's
thats pretty nice :D
Just adding keyboard ESC/Enter to the dialogs now.
can someone help me with grid on tkinter
hello, tkinter starter here. I coded a button but the button isnt showing as you see in this screenshot
will send the code in a minute
import tkinter as tk
#from tkinter import *
import os
# designing the gui
root = tk.Tk()
canvas = tk.Canvas(root, height=700, width=700, bg = "#302f2f")
canvas.pack()
frame = tk.Frame(root, bg="#7d7c7c")
frame.place(relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1)
register = tk.Button(root, text="Register License", padx=10, pady=5, fg="white", bg="#302f2f")
register.pack()
root.mainloop()```
try to use place :D
Is it OK to use the MIT license for a project that uses Pyside/Qt for Python?
With tkinter is it possible to add comma seperator for 1000s in the entry module? So 260000 would be displayed as 260,000 as the user inputs the numbers or changes the sliders
That sort of stuff is a real pain to do with tkinter.
You would basically need this entry to work three ways; being able to change itself if it's modified, properly formatting itself when changed from the slider and probably also be able to convert a formatted input back into a number. You could use an amalgamation of a focusout validation command and a textvariable that listens to changes, and constantly calculate forth and back between string and int; but those are dangerous to mix: https://www.tcl.tk/man/tcl8.6/TkCmd/entry.htm#M12.
I would almost recommend subclassing tkinter.Entry into something like FormattedEntry which keeps track of the true value internally and only uses the entry as a front to display this value in a formatted fashion
Which is the easiest module to use to make a basic User Interface?
Ping me of u know!
If*
Yeah
Anything better and easier than tkinter?
I think its a good place to start
Well I just wanna make a prototype of an app for now, I just wanna make a basic example of how it will work and stuff
What exactly would you be trying to make?
You asked for easy and basic; tkinter checks both of these (also in its general look, unfortunately)
There is PySimpleGUI, which is able to build a tkinter UI from a really easy to write layout list, but it runs on a special event loop; should be understandable with its docs
What of GTK? I've heard of it but never knew if it was good.
It's like sort of an app which can help u make a discord bot, like having many options, like adding events, commands and stuff like that
Neat. If you ever finish it let me know ๐
Me?
Sure
@amber roost , think I'll drop doing it for now as its a class assignment and I think its best not to overcomplicate things haha
but thanks for your reply! ๐
How do I change the border of a QComboBox when the cursor is hovered over it I tried this: css QComboBox::hover { border: 1px solid rgb(0, 145, 133); } but it didn't work
This is for PyQT5 Stylesheet
This is QSS, Qt's version of CSS
I don't know much about licensing. Does "PyQt5 is released under the GPL v3 license and under a commercial license that allows for the development of proprietary applications" mean I can create an application with PyQt5 for commercial use for free?
Using Tkinter, I'm following along in this tutorial from youtube, and at one point when I ran this code -
import tkinter as tk
HEIGHT = 700
WIDTH = 800
root = tk.Tk()
canvas = tk.Canvas(root, height = HEIGHT, width = WIDTH)
canvas.pack()
frame = tk.Frame(root, bg = '#80c1ff', bd=5)
frame.place(relx = 0.5, rely = 0.1, relwidth=0.75, relheight=0.1, anchor='n')
entry = tk.Entry(frame, font=40)
entry.place(relwidth=0.65, relheight=1)
button = tk.Button(frame, text="Test button", font=40)
button.place(relx=0.7, rely=1, relwidth=0.3)
# label = tk.Label(frame, text = "This is a label", bg = "yellow")
# label.place(relx=0.3, rely=0, relwidth=0.45, relheight=0.25)
root.mainloop()
There was a button behind the light blue frame. For him, the button was infront like it should have been. Mine was hidden behind the frame. Does anyone know why?
Are you sure the the code is the same as in the video?
I'm not really seeing anything wrong with this since widgets placed/packed/gridded later should appear in front of others unless you mess around with tkraise and lower
Yeah I checked line for line, I didn't see anything wrong.
I'll keep looking though
Although, shouldn't the canvas appear in front of everything?
I never used the place manager, no idea how these widgets are laid out; I'll run this myself real quick
well i'm getting this now
skimming over it, shouldn't it be rely=.1 or something to line up with the entry?
no what am i saying
The entry doesn't have any rely so it should just be possible to omit it entirely
Changed the button's place command to button.place(relx=0.7, relwidth=0.3, relheight=1), that makes it visible at least; could you send the youtube link though? I want to find that error
How do I make my PyQT5 GUI Frame look like this:
and how do I put the percentage sign there
Oh sorry @amber roost Just saw your response - here is the link: https://www.youtube.com/watch?v=D8-snVfekto&t=1845s
Code faster & smarter with Kite's free AI-powered coding assistant!
https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=keithgalli&utm_content=description-only
In this video, we learn how to build an application with a graphical user interface (GUI). This is a great video to learn how to use the Tkinter library as...
Omg
I just found the problem
I feel like an idiot
When you place the button, I put rely = 1, but it should be relheight = 1
Sorry about that
this sort of stuff happens all the time, nice you got it figured out ๐
from tkinter import *
# Sets the welcome window
welcome_window = Tk()
welcome_window.geometry("400x400")
welcome_window.title("Password Hasher Tester")
Label(welcome_window, text="Welcome! You can either login or register here.", font='Helvetica').place(x=45, y=80)
# Sets the username and password variables for login page
login_username = StringVar()
login_password = StringVar()
# Sets the username and password variable for register page
register_username = StringVar()
register_password = StringVar()
def login_submit_button_clicked():
print(login_username)
print(login_password)
# Sets the login page when the login button is clicked
def login_button_clicked():
login_window = Tk()
login_window.geometry("400x300")
login_window.title("Login Page")
Label(login_window, text="Login Here", font='Helvetica').place(x=160, y=40)
Label(login_window, text="Username", font='Helvetica').place(x=60, y=100)
Label(login_window, text="Password", font='Helvetica').place(x=60, y=140)
Entry(login_window, textvariable=login_username, font='Helvetica').place(x=160, y=100)
Entry(login_window, textvariable=login_password, font='Helvetica').place(x=160, y=140)
Button(login_window, text="Submit", fg='white', bg='gray', command=login_submit_button_clicked).place(x=180, y=210)
# Sets the register page when the register button is clicked
def register_button_clicked():
register_window = Tk()
register_window.geometry("400x300")
register_window.title("Register Page")
Label(register_window, text="Register Here", font='Helvetica').place(x=160, y=40)
Label(register_window, text="Username", font='Helvetica').place(x=60, y=100)
Label(register_window, text="Password", font='Helvetica').place(x=60, y=140)
Entry(register_window, textvariable=register_username, font='Helvetica').place(x=160, y=100)
Entry(register_window, textvariable=register_password, font='Helvetica').place(x=160, y=140)
Button(register_window, text="Submit", fg='white', bg='gray').place(x=180, y=210)
# Sets the login button
Button(welcome_window, text="Login", fg='white', bg='gray', command=login_button_clicked).place(x=180, y=180)
# Sets the register button
Button(welcome_window, text="Register", fg='white', bg='gray', command=register_button_clicked).place(x=175, y=230)
welcome_window.mainloop()
so im tryng to retreive the users entry
but this is what i get
its realy complicated for no reason
.get()
Also, where is the StringVar() function you set login_username and login_password to?
I might just be blind, or not getting something, but I don't see it
Yeah, I messed around with your code, @olive quartz, and I get messages saying StringVar() is undefined, so write the function for that, or, just change it to something else : D
login_username = StringVar()
login_password = StringVar()
i did this at the top
@digital rose
is that not enough?
oh
Those should come from the star import.
yeah i thought it did
You'd think.
I've been having trouble with the star import too
I would get errors for Labels not being a thing, when I imported with the star
so how can i import it then
Try writing - from tkinter import StringVar() or something
In your case it looks fine, just missing the get()'s when you try and print
Did you type in the entries?
Yeah?
(How to create a graphical register and login system in python using Tkinter) - This video is a basic tutorial which uses tkinter to build a program which will allow users to register an account on the software which they can later log in to. The second part of this tutorial will be uploaded very shortly.
Link to code: http://zipansion.com/41uo...
watch this vid
make sure u understand what each part means dont just copy what he says
@ionic moat what are you using?
PyQT5
Why you using PYQT5 when we got pysimplegui
Because PyQT5 is better
Nope
Oh ok
Each UI has its strengths and faults.
?
On tkinter Text() widgets, you can do .search() and search for a regex. How do you know when you've reached the end of the regex?
idk dollar sign
From what I'm reading in the docs, it only returns the starting pos of the search, not the ending pos.
okay well I still need to change the frame
@digital rose PyQt5 is better
@ionic moat you have to make it yourself, and remove the default onr afterwards
is it later now
Found it!
Anybody around?
Id just like to bounce some ideas around
having some, trouble implementing npyscreen
im a bit worried but, i think im getting there..
Hey uhm, is this the right place?
im really, not like, super stressed but.. i dont ususally get no response on irc, discord, i feel like.. maybe my choice of library was wrong and
thats stressful since, i only have so much time to get all of this done, i dont want to be changing libraries and ive already gotten pretty far with npyscreen
im sure i can make this work, i just dont know how yet
Oh, heres the code btw https://kitsunehosting.net/gitea/Kenwood/SNHU-IT-140/src/branch/npyscreen-adventure-game/Adventure Game/adventure_game/main.py
thats important, haha
How to implement navigation in PySide?
yes
root.geometry("300x50")
if you want min size for the window:
root.minsize(width=900, height=720)
the same as max size:
root.maxsize(width=900, height=720)
if you want to make a window not resizable you should use root.resizable(False, False)
self.setWindowFlag(Qt.FramelessWindowHint)
This will remove title bar
Now you need to create whole title bar which contain close , minimize button , etc as per you requirements
the import has to be : from PyQt5.QtCore import Qt btw
Yeah
does someone have a good source to read about all this pyside{1,2,6} vs. pyQT stuff, I feel kind of lost of what is going to be used in the future or what should be used...
But what about all this pyside vs. pyqt stuff beside of ideologies I would love to read about the differences and potentially which one is going to stay
is there any good library for creating "click-through" overlay stacked on a full-screen application which is only visible and all events are going into the application instead of overlay? i know in c++ i can achieve that by using directx but in python? dunno if its a good channel for that. I tried tkinter, but moving sprites in that isn't what satisfies me
How to implement navigation in PySide?
Hey guys , what about kivy/kivymd? Building apps with python?
i would say that going to #game-development
as this channel is for pyqt, tkinter and so
i saw userinterface my bad
Shityy deals this seems like the spot to discuess g.u.i's and modules used to create them, curious on a python script in pyqt or tkinter with just a textfield and button?
How many lines of code can do this on a curiosity point of view and how readable can it be to say a non programmer?
sorry to bother you, as im not really looking for a tutorial , just curious
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager
KV="""
MDScreen:
md_bg_color:0,0,.4,.3
MDBoxLayout:
orientation:'vertical'
MDToolbar:
title:"Practice App"
anchor_title:"center"
MDFloatLayout:
MDLabel:
text:"Hello World"
pos_hint:{"center_x":.5, "center_y":.9}
halign:"center"
bold:True
font_style:"H4"
outline_color:1,0,0,.4
outline_width:3
MDTextField:
id:username
size_hint:.7,None
pos_hint:{"center_x":.5, "center_y":.6}
hint_text:"Username:"
MDTextField:
id:password
size_hint:.7,None
pos_hint:{"center_x":.5, "center_y":.5}
hint_text:"Password:"
password:True
MDTextButton:
pos_hint:{"center_x":.5, "center_y":.4}
text:"Login"
outline_color:0,1,1,.4
outline_width:3
font_size:"32dp"
on_release: username.text =""; password.text =""
"""
class My(MDApp):
def build(self):
self.manager =ScreenManager()
self.manager.add_widget(Builder.load_string(KV))
return self.manager
My().run()
Hey guys sorry to intrude anyways your all doing good!! :) byee
it is also for kivy
kivy is a GUI module
What is the best cli framework
!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.
@hazy cosmos Kivy is a GUI module also
i wish it could be possible to do GUIs like in visual studio c#
winforms
but python
with c# there's no GUI code
Can anyone help me?
so o ones knows a solid cli
When I get the value of QSpinBox, I wanna wait for it change to something else, anything that's not the initial value, in this case, wait for the value of it to change to something that is not 0
Just like c# pyqt and pyslide also have there designer tool to create design without writting any code
You can set initial value and you can use that initial value if value of QSpinBox is not changed
wdym?
like py while True: if QSpinBox.value() != 0: break like this?
this is resource intensive
there shouldn't be a delay either
how do u put code in here? just copy and paste ?
as in designing in an app? QtDesigner provides for that
!paste
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.
@meager niche
does anyone know?
class MyMainWindow(QMainWindow):
def __init__(self, parent=None):
super(MyMainWindow, self).__init__(parent)
class FormWidget(QWidget):
def on_combobox_changed(self):
output = self.combo.currentIndex()
print(output)
def __init__(self, parent):
super(FormWidget, self).__init__(parent)
self.combo = QComboBox()
class Delegate(QtWidgets.QStyledItemDelegate):
def createEditor(self, parent, option, index):
if index.column() == 3:
woho
perfect
i want help reading the value of output from the method on_combobox_changed and insert it in index.column()
deleted a lot of irrelevant code to get the issue
Welp! Ping me if u think u could help. Cheers
No, You don't need loop for this For which type of data you need QSpinBox?
Then set initial value
Now if you will fetch the value you will get that initial value
The approach I've taken is to connect a slot to the combobox.currentIndexChanged signal
# In the objects's __init__ method, typically.
self.comboBox.currentIndexChanged.connect(self.handler)
# Then you can check if it's non-zero
def handler(self):
digit = int(self.comboBox.currentText())
if digit > 0:
# do the thing
This will avoid any unnecessary loops that check for changes every x milliseconds.
I'm not entirely sure what your on_combobox_changed function does though.
ohhhhhhhh
that looks like it makes sense
lemme try it
does this also work for spinBox?
Ah, I just noticed that I was looking at my combobox, the qspinbox has the signal valueChanged
oh okay
Signals and slots are easy to set up, they are definitely the way to go whenever you need to wait for an interaction, and wish to trigger action in another widget.
You may want to look into signals and slots, I have an example above.
I have another question
Is there a way to make it so I can actually see the error raised if something goes wrong
it doesn't show any error
all it does it crash the GUI and end
no error
Hm, the only cases I can think of is if you are catching the error in a try except block somewhere
If you're crashing Qt's GUI, that's an accomplishment. It won't divulge any errors though, since it runs natively in C++
You can insert print statements to see at what point the code crashes, to narrow down the search.
also another problem
Here's how it goes
So I have separate classes for separate GUIs
now I wanna access the spinbox in GUI2 in GUI1 and connect it to a function in GUI1, but I can't because the instance of GUI2 is not defined at the stage for some reason
I want to connect spinBox from GUI2 to function in GUI1
because button functions can't return anything for some reason
I would set up a signal the spinbox emits, then connect the signal to a function in GUI1.
You can also send data with a signal.
First, you need to declare the signal within GUI1 like this: (as a member variable)
sigSomethingHappened = QtCore.Signal(object, object, ...)
You can optionally add as many data snippets the signal should carry.
You can then emit the signal when the time is right, like at the end of your spinbox's handler function
self.sigSomethingHappened.emit(data0, data1, ...)
How to implement navigation in PySide?
is there a way for me to this in a function py return_value = PyQt5.wait_for(signal) and then somewhere else I can do py signal.emit(value_of_spinbox) where the first line waits for the signal to emitted and the return_value is what it emitted
You'll also need to connect that signal from GUI1 to a function in GUI2 like with the valueChanged signal.
but the return value doesn't have to matter if that's impossible
just wait
just make it wait
You'll want to connect the signal to a local function, one with the following decorator:
@Slot(int)
def do_what_Ive_been_waiting_for(self, index):
The slot decorator with capture an integer from the signal and pass it on to your function's first argument, index
what about waiting
I need my program to wait
actually I just need to function to wait
wait until I recieve this signal
@silver widget can you answer my question?
Could you elaborate, @meager spoke ?
Yeah, by connecting it to the signal, the function will only fire once the signal was emitted.
wdym connecting it to the signal
I have two Widget which works as a page i want to redirect user to second widget if user clicks a button on first widget
You'll need to do the GUI1.sigSomethingHappened.connect(do_what_Ive_been_waiting_for) in GUI2
Are you using a stackedwidget?
No
ohhhh
Wait
I want do_whatIve been watiing for in gui1
becaue I need index in that class
is that okay?
because the spinbox comes from GUI2
GUI2 is useless except for the spinbox
but how do i render the second widget?
Yeah, just make sure you pass the reference of GUI2 to GUI1 so you can connect its signal.
How is your window laid out?
There's a button in GUI2 that should be pressed
so by doing this, it'll wait for that button to be pressed (it's going to wait for that button to be pressed in a function in GUI1) and when it is pressed, it'll resume that function in GUI1 by emitting a signal
correct?
Okay I think it'll be easier if I give a code example
I'm sorry if I'm being a bit hard right now
i am using grid layout
Yes, if you link the function that will carry on with your work to the other GUI's signal, it will have to wait for it to be emitted.
So both widgets are visible at the same time? Then you should have access to both in the same class, right? Some sample code could help me understand.
Let for example say I have a login Widget when user successfully logins the user should see the dashboard?So how to implement navigation between login Widget & Dashboard Widget?
class GUI1(MainwWindow):
def __init__(self):
self.button = pyqt5.button()
self.button.clicked.connect(self.function)
def clicked_button(self):
# do things
if variable == "this":
return_value = pyqt5.wait_for_signal(gui2.signal) # nothing below this runs until the signal is emitted
# after the signal gets emitted, do the rest of the code
...
class GUI2(OtherWindow):
def __init__(self):
self.spinBox = pyqt5.spinBox()
self.signal = QtCore.Signal(int)
self.spinBox.valueChanged.connect(self.emit_signal)
def emit_signal():
value = self.spinBox.value()
if value > 0:
self.signal.emit(value) # this activates the wait function above in GUI1 and emits the value
You can retrieve the data from the login widget to a parent class, then delete the login widget, and create the dashboard widget in its place. Then pass the dashboard whatever info you need.
something like this
But then there will be white screen when login widget gets unload and dashboard Widget gets load?
Ah, the thing with clicked_button, you'd put that in place of the self.function, so self.clicked_button. That will call the clicked_button function every time the button is pressed.
You cannot halt execution to wait for a signal, you will need a second function to handle the return value.
The GUI2 code looks good to me
Well, if you want both to be visible next to each other, what is it really you want to do?
no
i want navigation some what like that in web sites?
What you could do, is simply query the value of the spinbox on the fly.
Yes, then in that case, deleting the widget will make the other widget fill its space. You're using layouts, after all. They should resize automatically to fill the white space.
Ok.I will try it.Thanks
But I still have a question, sorry if I'm being repetitive or annoying but what about waiting?
Like a wait thing for signal?
I'm still confused about that
If you only need to know the value of the spinbox, simply do a self.otherGui2.spinbox.value()
And keep a reference to the other GUI in GUI1
@silver widget can you tell some nice resources to learn PySide?
this is how it goes
they choose image polishing and press the button edit image
edit image opens that GUI and asks for a number
the other GUI is GUI2 here
If you wish to open the login page later, you can also use the stackedwidget, then simply change the stackedwidget.setCurrentIndex() to the dashboard's index without deleting anything.
when they choose their number in GUI2, they press OK and that sends the in to GUI1 button "Edit Image"
ok. I will try it also.
https://doc.qt.io/qtforpython/contents.html This is very helpful pyside6 documentation
Good luck!
Ah, you should totally use a dialog!
I did
Thanks
With dialogs I've done this in the past:
reply = QMessageBox.question(self, "window title", "Are you sure", QMessageBox.Yes, QMessageBox.Cancel)
if reply == QMessageBox.Yes:
Something like that will be possible, lemme see how that would be done with a custom widget.
Alright, so it's pretty easy:
You'll need to open your dialog like this:
class GUI1(MainwWindow):
def __init__(self):
self.button = pyqt5.button()
self.button.clicked.connect(self.clicked_button)
def clicked_button(self):
# do things
if variable == "this":
dialog = GUI2()
if dialog.exec_() == #This will halt execution until GUI2 is closed, and be true if GUI2 was closed with self.accept() or similar
# do the thing
if dialog.value is None: #Welp, something went wrong here
...
class GUI2(OtherWindow):
def __init__(self):
self.spinBox = pyqt5.spinBox()
self.signal = QtCore.Signal(int)
self.spinBox.valueChanged.connect(self.emit_signal)
self.value = None
def emit_signal():
self.value = self.spinBox.value()
if value > 0:
self.accept()
I'm pretty sure that's the answer you needed
You can also cancel your dialog by calling self.close() or self.reject() I think
yeah I did self.close_button.clicked.connect(self.close)
pretty cool
lemme try this
Calling exec_() generally isn't all that recommended, since it halts all other windows, but it's what you want in this case. Otherwise just call open()
so what do I do for that though
Like I'm comparing it
if dialog.exec_() ==
there has to be a value on the right side right?
It'll return some boolean, true for accept(), I think
so if the value of dialog is not None, it means the signal was accepted right?
If it's none, that means the spinner wasn't updated and the window was closed forcefully.
yeah
Have you imported signal?
import signal?
it's in QtCore, iirc
but it says QtCore has no attribute 'Signal'
It seems you're still on the old Qt5, with pyqt5.
The transition seems to be pretty easy, just a couple differences in the import statements.
So that's probably one of the things changed since PyQt5
I haven't heard of pyqtsignal, but maybe that's the old name for it, you'll have to find out.
oh
So I have to update PyQt5
what about 'CustomResizeGui' object has no attribute 'exec_'
I get that
I initialized the class
idk why I get that
Is it not inherited from a QDialog?
Well I mean
it's inherited from a class that inherits that
but I can QDialog as a second inherited class
because exec_ is a QDialog method, so I'm not too sure what's going on
okay I added QDialog as a second inhertied class
I don't get that error anymore
but the GUI just crashes again
Oh boy
All of it?
Because a window can also close when its reference goes out of scope.
The CustomResizeGui crashes
and that causes the Main Window to crash
It's not in GUI1 though
because I have an exception handler there
what the heck, I guess GUI2 is not happy about something
I should update PyQT5 first
You can try, not sure it'll fix the problem. There weren't many new features in Qt6, but they did focus on a lot of internal restructuring and bug fixes.
Qt6 launched a few months ago, the Python bindings for the C++ libraries are now called PySide6
Side is Finnish for connection, so it's the python connector.
Their numbering is as messy as Nvidia's.
Good luck! I'll have to get back to work. Cya!
wait if I need your help later may I ping you?
you've been the biggest help ever and I really thank you for it
Sure, go ahead.
Ah, that would do it.
yeah but there's another error that I can't find
I wish it would tell me
but I just have to guess where it is
okay it was just an indentation error
llol
this is really confusing
I got the dialog.value is None thing
it's None
anyone have experience with WXpython AUI or dockable windows
tkinter guys please look on #databases
@silver widget I have another question about PyQT5
it doesn't have anything to do with before
so I have this piece of code that runs, but it takes a few to run and it interrupts the main GUI
how can I run it and not interrupt it
interrupt it as in it makes the main GUI stop responding
and then after it's done running, the GUI comes back to life
You will want to spin up a second thread, possibly a daemon.
https://www.geeksforgeeks.org/python-daemon-threads/
I haven't done much threading, but this will probably be what you'll need to get started.
okay but I also need to to wait for the code to finish running
it can't just spawn the thread and continue
You'll probably be able to connect a signal from the daemon to your main gui
Then simply wait for the signal.
How do I wait for the signal in the function GUI 1
because the signal should be emitted from another class
actually it doesn't matter where the signal is being emitted
as long as it doesn't make the main GUI unresponsive
Yup, all the interconnections are handled by qt, thatโs the nice thing about it.
so I make a new class that spawns a thread and then after the code finishes, inside of that thread I emit the signal to continue the code in GUI 1
You'll just have to have a function that starts the process, and then a function that gets called once the thread is done.
Yup
what's the code to wait for the signal again?
You don't want to wait for something, per se, you want to simply react to when it happens.
Otherwise waiting might mean leaving the gui unresponsive
but if I react when it happens, the code will be finished
Isn't that what you want?
I suppose that would help
class OtherThreadClass:
def __init__(self, arg1, arg2):
self.arg1 = arg1
self.arg2 = arg2
self.signal = QtCore.Signal(bool) # dunno if it requires an argument so I just put bool
def start(self):
code_that_causes_the_gui_to_go_unresponsive() # takes time to run
self.signal.emit(True) # This stops running things_to_run_while_the_signal_has_not_been_emitted_yet() because the signal has been emitted at the point
class GUI1(MainWindow):
def __init__(self):
self.button = pyqt5.button()
self.button.clicked.connect(self.on_click)
def on_click(self):
thread = OtherThreadClass()
while thread.signal.is_not_emitted: # I wanna do things while code_that_causes_the_gui_to_go_unresponsive() is running:
things_to_run_while_the_signal_has_not_been_emitted_yet()
#finish up code
self.close()```
here
Ah, you don't actually want to lock up the gui, that would make the user think it just froze, especially if the code takes more than a few seconds. What you'll want to do is set the setEnabled(bool) property on the relevant GUI elements, which will disable user input when false, graying everything out, without windows thinking it's unresponsive.
If you disable the top level widget, all nested subwidgets will also be disabled.
oh
That's the proper way to do it. If you attempt to freeze the gui by entering an infinite loop, it will seem like the window crashed.
This way, you can still leave a progress bar and a cancel button enabled.
You'll be able to update the progress bar with signals, I guess
Oh yeah I'm trying to run a progress bar while it does the thing that crashes the gui
Hm, sounds like the daemon thread isn't properly separated, or is that working?
lemme check
okay well
nothing errors
but I need to implement a loading bar in the main GUI that gets signals from the thread
so we're doing so far
@silver widget ideas?
Hmm, treading new ground here for me, so I'll take my best guess.
You'll want the daemon to emit signals, right? That means we'll need to connect the signal from the daemon to a local function that then updates the bar. Since threads share the same memory, it shouldn't be a problem to access the daemon's object, or? It'll need to inherit a qobject, perhaps, if it doesn't work out of the box.
Hmm, this is getting tricky
Wait but I thought the signal can be emitted through classes, why local function?
I mean that you catch the signal in a local slot
Of the parent's GUI object, like with the GUI1
Hm, I'll try getting it working on my end. Sounds fun.
I also need the return value of the threaded target function
You can return values through slots, that may work. Or the traditional way of passing data back from threads.
Can I ask some -really- stupid question about PyQt5 here? :/ I haven't properly start it.
Ooh, I've never tried that, though I'm pretty sure it's a vestige to support the C++ variant
If you've got really dumb questions, you probably haven't found a good resource to look things up yet, try this https://doc.qt.io/qtforpython/contents.html
agh PyQt5 is confusing
Thank you I'm looking it now!
Good luck!
Also, know that pyqt has been updated to PySide6, that's the newest version for Qt6
ow! I see that PyQt is different from PySide ๐ฎ I wasn't heard about PySide.
That was what I'm writing! Thank you :)))
It's basically the same, their naming is just screwed up lol
ahah okey, thank you again. I'll try this documentation, my old one is out-dated then.
Yup, have fun!
@silver widget look https://realpython.com/python-pyqt-qthread/
maybe we can use this to work this out
So I got the signal progress bar working from this
but now I need to 1. run the long function in the thread, and 2. get that return value, and 3. send it to GUI1's function
Oh that's neat, I'll have to read up on this
The pyqt docs are kinda saturated with c++ at times, so it's nice to have this proper article.
Yeah, using a QThread sounds like the way to go here, as it's got the signal and slot support that you need here.
Fantastic!
Hey, I learned something new, too, so it's been an all-round success.
I need a bit more help
this one should be less confusing
fname = QFileDialog.getOpenFileName(self, "Select Download Directory", "", "*.png, *.bmp") why does this one show .bmp files in the file explorer but not .png
the only way to get .png files is by typing them
use the following format (make sure to edit to your file types, etc.)
filename, _ = qtw.QFileDialog.getOpenFileName(
self,
"Select Download Directory...",
qtc.QDir.homePath(),
'Text Files (*.txt) ;;Python Files (*.py) ;;All Files (*)',
'Python Files (*.py)',
qtw.QFileDialog.DontUseNativeDialog |
qtw.QFileDialog.DontResolveSymlinks
)
where as
1.) the parent widget
2.) the caption, used in the window title
3.) the starting dir
4.) the available filters
5.) the default selected filter
6.) option flags
lmk if that solved your problem
filename, _ = qtw.QFileDialog.getOpenFileName(
self,
"Select Download Directory...",
qtc.QDir.homePath(),
'PNG Files (*.png) ;;BMP Files (*.bmp) ;;All Files (*)',
'PNG Files (*.png)',
qtw.QFileDialog.DontUseNativeDialog |
qtw.QFileDialog.DontResolveSymlinks
)
did u try like that
cause otherwise i dunno
Where does root come from?
thanks for this, i might want to do that, id just like to specify a specific size since im doing a lot of drawing and im using exact coridinates, i dont need the screen to change size
hi everyone, how would i start creating the rest of my gui under each tab? ```python
#tab section
tab_control = ttk.Notebook(window)
ip_scanner_tab = ttk.Frame(tab_control)
ticket_create_tab = ttk.Frame(tab_control)
tab_control.add(ip_scanner_tab,text='IP scanner')
tab_control.add(ticket_create_tab,text='Ticket Creator - Spiceworks')
tab_label_ip_scanner = tk.Label(ip_scanner_tab,text = 'Welcome to my IP scanner')
tab_label_ticket_creator = tk.Label(ticket_create_tab,text = 'Welcome to my Ticket Creator for Spiceworks')
#packs
tab_control.pack(expand =1,fill='both')
FYI i'm using tkinter
@chrome saddle ttk.Label instead of tk.Label and you need to tell the labels their positioning, either with pack, or with grid.
tab_label_ip_scanner = ttk.Label(ip_scanner_tab,text = 'Welcome to my IP scanner').grid(row=1,column=1)
or
tab_label_ip_scanner = ttk.Label(ip_scanner_tab,text = 'Welcome to my IP scanner').pack()
(Side note: I highly recommend using Qt or wxwidgets instead of tkinter, tkinter is pretty strange at times)
@digital rose Sorry to @ you directly, id really love some clarification though..
root is a Tk() object i guess
A what object?
oh ok, shihab was talking about tkinter as far as i know
:c
best to ask him
shoot
Yeah, sorry
its really uncool to @ like that but
its been hours
ive also been lurking in #python on irc
feel kinda lonely
Lol sorry guys.
Yes I wanted to use tkinter. I imported to from tkinter
@ me is cool. It helps distinguish between whoโs actually talking to me
When downloading opening the discord app it opened a pop up to link to my browser and check for my previously signed in user name, does anyone know what kind of process this is? Selenium based? Puppeteer?
why is there a white outline in this? I made this with tkinter
https://cdn.discordapp.com/attachments/811889688208998450/812256456220606474/unknown.png
Ping me if u know!
Hello, I am fairly new to PyQt5 and have been working on my first project with the library for the past few days. I've been struggling with some strange behaviour from my QtWidgets.QSplashScreen SplashScreen. It succesfully displays itself and shortly closes after 3 seconds as specified here QtCore.QTimer.singleShot(3000, self.closeSplash). But as soon as the main app opens, If I try to display anything else, the SplashScreen reapears. And for some reason it only occurs on macOS. It got me wondering, "I'm I properly closing the SplashScreen?". I would highly appreciate any hints on what could possibly be wrong with my code, here's the SplashScreen class for reference, and please do let me know if you need anything else.
###--------------------------- SplashScreen ------------------------------###
class splash(QtWidgets.QSplashScreen):
def __init__(self, parent=None):
super(QtWidgets.QSplashScreen, self).__init__(parent)
self.splash = QtWidgets.QSplashScreen(QtGui.QPixmap(SplashScreenIMG))
self.splash.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.splash.show()
QtCore.QTimer.singleShot(3000, self.closeSplash)
def closeSplash(self):
self.close()
self.main = MainWin()
self.main.show()
# SplashScreen
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
main = splash()
main.show()
sys.exit(app.exec_())
MainWin() is my main app
Hi, i wanted to learn mobile development and was wondering if react was a good choice. I would only use this framework to create UIs and animations, while the sauce of the app would be written in C. Any of you know if this is possible, if it is, which frameworks do you advise?
can anyone help at #help-cheese
hey guys how would i take a pyqt python code and edit it in qt designer knowing i dont already have the main .ui file
you can try converting into .ui file with pyuic5
alright thanks
I'm with tkinter, i have a main window with 3 row and 0 column, and i want to put 8 variables of a list in 8 LabelFarme in the 2nd row of the window, how can i do ?
def create_frame_cntr(principal):
global nmbr_boules
frame = ttk.Frame(principal)
frame.rowconfigure(0, weight=3)
nmbr1 = ttk.LabelFrame(frame, text=str(nmbr_boules[0]))
nmbr2 = ttk.LabelFrame(frame, text=str(nmbr_boules[1]))
nmbr3 = ttk.LabelFrame(frame, text=str(nmbr_boules[2]))
nmbr4 = ttk.LabelFrame(frame, text=str(nmbr_boules[3]))
nmbr5 = ttk.LabelFrame(frame, text=str(nmbr_boules[4]))
nmbr6 = ttk.LabelFrame(frame, text=str(nmbr_boules[5]))
nmbr7 = ttk.LabelFrame(frame, text=str(nmbr_boules[6]))
nmbr8 = ttk.LabelFrame(frame, text=str(nmbr_boules[7]))
nmbr1.grid(column=0)
nmbr2.grid(column=1)
nmbr3.grid(column=2)
nmbr4.grid(column=3)
nmbr5.grid(column=4)
nmbr6.grid(column=5)
nmbr7.grid(column=6)
nmbr8.grid(column=7)
return frame
for the moment, i have something like this
sorry if my code is terrible X), i'm like a beginner (but not too much)
def create_main_window():
principal = tk.Tk()
principal.rowconfigure(0)
principal.rowconfigure(1)
principal.rowconfigure(2)
Frame2 = create_frame_cntr(principal)
Frame2.grid(column=0, row=1)
principal.mainloop()
i've given the essantial
ping me if you respond :)
hey what u need
as example if you have window of
hello world
whasapp?
and you pack label with text im great it will just do
hello world
whasapp?
im great
not realy useful tho since you cant realy control thing
way to space is do like
hello world!
*imagine we having label here but with no text*
whasapp?
*same here no text*
im great
so in reality its going to look like
hello world!
whasapp?
im great```
@lyric minnow
that realy the best way explain it in my opinion
oh
so like
hello_world = Label(root,text='Hello world')
hello_world.pack()
another way to do it is using the .pack() right after
hello_world = Label(root,text='Hello world').pack()
its .pack()
i know it but i dont know args of it exmpale pack(expand = 1, fill = BOTH, ipadx = 209
@hazy cosmos
padx is in the label or button or else, not in pack
ipadx?
what is for ipadx ?
pack() also has padding options:
padx, which pads externally along the x axis.
pady, which pads externally along the y axis.
ipadx, which pads internally along the x axis.
ipady, which pads internally along the y axis.
no its also for pack
but realy learn place most useful
pack not useful at all
and im telling u this as a person who learnd the trio like 2 days ago
and now im not using pack
place is amazing in my opinion
grid can be useful
but as example for this gui
that i made place is a life changer
i looked for remove widets, there is person say to pack_forget, grid_forget bu he didnt say place_forget ๐
i looked for remove widets, there is person say to pack_forget, grid_forget bu he didnt say place_forget ๐
@lyric minnow I use forget indeed
waowsss its so nice
@lyric minnow tnx
this is the mine
@lyric minnow nice what's the use for it
Nice good luck
What language is it
Turkish
Nice
where are you from
Rather not to say
o- ok

Maybe try and make the button more of ellipse
Like the square on middle screen doesn't look realy good
Ellipse should look great
TCL/tkinter RegExp issues:
I would like 1 regexp that can do all of the following:
- ("[ \t][ \t]+") Delete consecutive spaces/tabs
- ("^[ \t]+") Leading spaces/tabs
- ("[ \t]+$") Trailing spaces/tabs
- ("#.*$") Delete the contents of lines that start with the
'#'symbol - ("^$") Delete blank lines
Here are the current search strings I'm using:
Here is my current code:
cur_index = "1.0"
cur_end = tk.END
match_length = IntVar()
search_string = r"REGEXP" # Regexp search string (one of the above)
while Decimal(cur_index) <= Decimal(cur_end):
try:
cur_index = editor_text.search(search_text, cur_index,
count=match_length, regexp=True,
nocase=1, stopindex=cur_end)
except Exception as exp0:
cur_index = ""
print(f"search_text: {search_text};{exp0}")
break
if not cur_index or match_length.get() == 0: break
next_index = "%s+%sc" % (cur_index, match_length.get())
editor_text.delete(cur_index, next_index)```
hello!
Hi
Can some one help me to postion a frame
I want to have to frames, one next to the other
But, one of them gets lost
The right one is supposed to have a button under it
You can use a Label() as a layout tool and then nest the other elements in 2 labels side by side
This is how I can use .pack with labels, then .grid on the elements contained in the label
I've already heard of it
Okeey, I will try it out!
Thx a lot
Hey, I had a mistake, where I can't use grid on a topLevel where I have already used .pack()
I will share this portion of the code, I will really appreciate any help ๐
Sounds like another nested Label situation
splitSomeE = Frame(splitWindow, bg = "#CACECF", width = "150")
splitSomeE.pack(anchor = 'w')
Label(splitSomeE, text = "Separar un grupo de paginas\nen especifico", bg = "#CACECF").pack()
Label(splitSomeE, text = "De:", bg = "#CACECF").pack()
Entry(splitSomeE, font = ("Helvetica", 10), width = 15, textvariable = num1).pack()
Label(splitSomeE, text = "Hasta:", bg = "#CACECF").pack()
Entry(splitSomeE, font = ("Helvetica", 10), width = 15, textvariable = num2).pack()
Label(splitSomeE, text = "", bg = "#CACECF").pack()
splitSomeBtn = Button(splitSomeE, text = "Separar", relief = RAISED, bg = "#000000",
fg = "#FAFAFA", font = ("Helvetica", 15), activebackground = "#11B0D8", command = lambda: splitSome_click())
splitSomeBtn.pack()
# Splitall
splitAll = Frame(splitWindow, bg = "#CACECF", width = "250")
splitAll.pack(anchor = 'e')
Label(splitAll, text = "Separar todos los elementos del archivo\nen paginas separadas", bg = "#CACECF").pack()
Label(splitAll, text = "", bg = "#CACECF").pack()
splitAllBtn = Button(splitAll, text = "Separar", relief = RAISED, bg = "#000000",
fg = "#FAFAFA", font = ("Helvetica", 15), activebackground = "#11B0D8", command = lambda: splitAll_click())```
It is still the same situation tho ๐ฆ
Thanks for the help, it is my first time using Tkinter
If you want an example of how to lay out elements check out https://github.com/ayourk/HostsManager/blob/main/hostsman.py
I will check it out!
Thanks once again
I ran into weird issues where resizing the window changes depending on "when" certain things are added to the layout.
Hey @lyric minnow!
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:
amazinggggggggggggggg sirr
Hey, I made a management system and I want to implement it on GUI, can someone tell me where can I look for guidance on how to implement my system on GUI?
Any link or material that might be helpful?
GUI tkinter to be specific
https://www.youtube.com/c/Codemycom/videos is where I gained most of my info on making my project above
thankss I'll look into it
@dusty scarab Thanks for sharing
@dusty scarab Sorry for direct pinging, wanted to thank you, you did help me a lot!
Order of adding widgets does matter.
Is anyone here good with Tkinter? I have a problem.
Read back a bit.
I haven't found anything to do with what I'm experiencing...
Did any of those videos on that channel help any?
not really
What's the problem?
When I open a new window in Tkinter, I want a variable to appear. That I can do, but whenever I go to try and update the label, it comes up with an error. I'm trying to update it with an entry. I'm going to try something that I haven't thought of yet and see if that works.
.config() is typically what you want to do after something has been added to the layout.
Also, an "Entry()" can be decorated to simulate a Label()
One of the videos in that channel does illustrate that.
That problem is that it saying a variable doesn't exist when it does...
tkinter uses Intvar(), StringVar() and DoubleVar IIRC when using vars with widgets.
And they have to be declared before they are used.
If using them in a function, you may have to use global to indicate that it outside of the function scope.
I've tried everything I know. I'm going to sleep on it. I need a break. I appreciate the advice though
anyone here knows kivy ?
hi, I have a problem, using Text widget I want to configure the blue hughlighting lines when Ctrl + A (I send 2 screenhots before and after Ctrl + A)
I want to keep those blue lines, but let them select ONLY the text
instead of the whole lines
from:
from tkinter import *
root = Tk()
You can change the color of the select hughlighting and the text and the border and the background but you can't make select area at the text only in tkinter. sorry
also you can change the font
F :(
yes
:(
@digital rose Why do i need that extra library?
Iโm using tinker. When I click on a button, how do I change a value when a button is clicked? Does it have to be global if I want to use it outside the function?
Th buttons command is to go to a function. I want to set a new value for a variable inside this function
Could use Vars
@digital rose i am really confused
Does anyone know why PyQt5 doesn't raise errors? I know it runs in C++ but isn't that the same thing that OpenCV-Python does it? Like it raises non-python errors, so why not for PyQt5, it's like the same thing??
This makes it really really really hard to debug in PyQt5, so does anyone have any tips on debugging in it?
PyQt5 has error messages too. Not sure what you're talking about?
There are some runtime things that you probably aren't going to see an error for, but trust me.. it has plenty.
what are you doing that triggers a crash?
Just basic Python errors or Qt Errors
like hanging the event loop or mistyping a variable name
anything
the only way for me to get the error for Python errors is by putting a try/except statement in every function
but that only shows Python errors
not problems in Qt
you can install a message handler if you want to but the messages you see probably aren't going to be very easy to make sense of.
Okay and something else
how do I do this? I already got an answer for it but I didn't understand it well but they said to use a Queue
What am I looking at?
Alright, let me explain, so:
first, the main GUI (the bigger one in the middle)
it has a button called "Edit Image"
now if the lower combo box is set to Image Polishing, it should prompt the GUI on the right
the GUI on the right has a spinbox that asks for a number between 0 and 5
after they choose their number and press OK, it should return that value of the spin box back to function that the "Edit Image" button is connect to
if they press cancel on the right GUI, the value of the spinbox will just be 0 by default
if it's 0, then set it to 1
So ```
- Press "Edit Image" this button is connected to function1
- function1 waits for value from function 2 (function2 is connected to "OK" button in second GUI)
- After "OK" button is pressed, function2 sends value of QSpinBox from GUI 2 to GUI1, function1, the first button
- That function handles the rest```
Okay, so what is the problem you're trying to solve?
waiting on the OK button in GUI2 to be pressed in function1 (GUI1)
and sending the value
In your code, is the dialog on the right created by subclassing QDialog? If so, use pyqtSignal() to emit a signal when the button is pushed.
It is a bit difficult to discern what is causing your issue without having an idea what your code looks like. What you are trying to accomplish should bea simple task.
how can I place 2 (or more) widgets next to each other using pack()?
Use .grid() in a Label() that you then .pack into the rest of your layout.
.pack(side=tk.LEFT) and .pack(side=tk.RIGHT)
i guess
pack() and grid() dont work together
if that is what you are saying
@digital rose place is realy the key in my opinion
like first widget is 20 width so do .place=(x=20,y=100) and then for the second one .place(x=50,y=100)
and it will be next to eachother
Anyone know how to style the scrollbar of a QTableView in QT Designer via stylesheets? Styling "QScrollBar" doesn't seem to work for me.
Check my project at https://github.com/ayourk/HostsManager/blob/main/hostsman.py
I'm using .pack() for my main layout, but I'm using .grid() for the statusBar. I'm using a Label() to contain the .grid() elements to be .pack()ed in the main layout.
interesting, are they in the same window or different ones?
how do I remove QSizeGrip from my PyQt5 app?
https://github.com/cdhigh/tkinter-designer
Anyone ever used this? Ping me if anyone has
How do I remove the border around a tkinter slider? I've been looking through the docs and I can't find anything
@weak rivet sorry for the ping, but r u making a game or something?
@weak rivet oh ok cool, btw I would love to try out yr game
Oh ok
If that designer worked with VSCode, I'd be interested.
Which?
The one you posted a link to just a few minutes ago?
Well I just found it on GitHub, and I have also never tried it, so I was asking it anyone has tried it
how do I remove QSizeGrip from my PyQt5 app?
?
cant you just hide it
or style the window so its frameless
doesnt work
the window is frameless
thats why I want to remove it
hmm
its a frameless window with a sizegrip floating
can i c a screenshot
tf
and u said the window hints include frameless
maybe its something with your stylesheet
did u set a widget for the QSizeGrip
if you did, remove it
nope
is the ui made with designer or through code
designer
its possible the designer automatically adds it
nope
nothing
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setWindowFlag(QtCore.Qt.MSWindowsFixedSizeDialogHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
``` this is the code to make it frameless
maybe try turning off translucentbackground?
Looks like some sort of gradient is enabled.
im just trying to remove the QSizeGrip
i still think its something to do with making it in designer
when i open it and create a mainwindow layout
the QSizeGrip is there
any idea what to do
You have to make the window NOT resizeable
setFixedSize?
setFixedSize?
hello?
@ivory ember does setFixedSize make it not resizable?
o
mb
ummm
i think
i mean just try it
i always make my apps in code
never see the qsizegrip
something with designer
In tkinter, the option is WindowObject.resizable(False, False)
One param is for the X/horizontal direction and the other is for the Y/vertical direction
The designer puts a menubar at the top, and a message bar at the bottom for the mainwindow template. I believe those lines (and the entire bottom margin) are because of that.
Look into the message bar, those lines must be part of it.
Yeah, those lines are the indicator for it.
Does anyone have experience using Dash to create data tables and geolocations.
i have a bit of an issue with Curses so far.
so i have this window here, and it is about to be filled.
once i attempt to draw more than 63 characters inside of it, addstr will error.
is there a way to have things stored in the window, but only render a bit of?
actually you know what, i could store the text in a list, and only render segments of it in the window.
Does anybody know what this means?
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Micha\AppData\Local\Programs\Python\Python38\lib\tkinter_init_.py", line 1895, in call
return self.func(*args)
File "C:/Users/Micha/PycharmProjects/restartebaybot/main.py", line 55, in startbot
timeing = int(input(self.box2.get()))
ValueError: invalid literal for int() with base 10: ''
@dusty scarab
Peel back that onion a bit by separating out that line into different variables:
boxget = self.box2.get()
boxinput = input(boxget)
boxint = int(boxinput)
timeing = boxint```
And then see where the error falls.
But I also have this self.box2 = Entry(root, width=50, bg="white", fg="black")
@dusty scarab
With errors like that, get rid of the nesting first and troubleshoot from there.
What is nesting? Putting everything into one line?
Example of nesting from your code:
timeing = int(input(self.box2.get()))
hi!
i was wondering if anyone knew how to implement something where after you print a selection e.g:
selection = input(f'{Fore.MAGENTA}Enter Choice {Fore.WHITE}-> ')
if selection == '1':
clear()
jokes()
elif selection == '2':
clear()
rules()
elif selection == '3':
clear()
upbcredits()
time.sleep(1000)
and u enter 1,2,3. it will print the desired text, but will add an option to go back to mainMenu()
e.g: it will print Press Enter To Return To The Main Menu and it will do that. i dont know how to implement it though
Could someone know whether a pyqt5 project can be started with systemd? (Ideally using after=graphical.target)
How to set the background image of the root window in Tkinter?
class UserInfoWidget(BoxLayout): def browse_file(self): subprocess.run(['powershell.exe', '"%s"' % os.path.join(os.getcwd(), "filebrowser.ps1")]) I am trying to open a file select dialoog on windows. When I run that file by opening powershell I get the file select but I don't get a select popup window with subprocess
I m using kivy
all I get is that string in shell
try adding shell=True perhap?
how to implement something where after you print a selection e.g:
selection = input(f'{Fore.MAGENTA}Enter Choice {Fore.WHITE}-> ')
if selection == '1':
clear()
jokes()
elif selection == '2':
clear()
rules()
elif selection == '3':
clear()
upbcredits()
time.sleep(1000)
and u enter 1,2,3. it will print the desired text, but will add an option to go back to mainMenu()
e.g: it will print Press Enter To Return To The Main Menu and it will do that. i dont know how to implement it though
Guys i need something EASY but POWERFUL:
ALOT of customization
Easy to understand GRID
Modern Design possibilities
Try using the keyboard module
!pypi keyboard
i love Keyboard and all, but it unfortunately requires superuser privileges on Linux.
which is quite a drawback in my opinion since it makes your application look really suspicious.
i would use the pyautogui module though the keyboard one is good too
!pypi pyautogui
!pypi mouse
ok so i have a large confusion. this is my first time using pyqt5 and i want to change a value upon the press of a button.
from PyQt5.QtWidgets import QPushButton
progv = 0
#there are the other things needed for making the window here
def changeval(current, moreless):
if moreless == "up":
current = current + 1
return current + 1
elif moreless == "down":
current = current + 1
return current - 1
else:
print("ERROR")
#then i have my buttons... this is where i start getting confused.
upbutton.clicked.connect(changeval(progv,"up"))
downbutton.clicked.connect(changeval(progv, "down"))
#this returns "TypeError: argument 1 has unexpected type 'int'"
#so to my understanding, it can only use a callable function, so how would I make it change the value of [progv]???
anyone have any idea?
the current = current [operator] 1 section is also confusing
hold on, ill write an app for u
oh, ok
i was more wondering how
but
ok
i can problobly just read over it to see how
I think i figured out the designer.exe
I think it should be easy enough from here
ill add comments so u learn not just copy the code
alright
hey anyone, I'm looking for a module to print to terminal "the value of X is " + x
In this print I want to loop through a few functions which will continuously change the value of X.
I dont want to reprint the entire string at the end of the loop. I want a terminal entry that prints "the value of X is " once, but continuously updates x
Hello, I'm using Tkinter, and I'm working on a virtual keyboard.
Is there a way to always keep the focus on the keyboard and the user application
And can I make a virtual keyboard event (like a keyboard press but virtual)
Short answer yes. Long answer: Look at how I handle Dialogs in my project: https://github.com/ayourk/HostsManager/blob/main/hostsman.py
The common code between all of my dialogs are what you are looking for. The TODO dialogs may be easier to understand.
binds and focus_force() i guess
here (read the comments to make sure you understand, dm me for questions): https://pastebin.com/EjM8Mjxq
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'll take a look when I get home. Thanks.
np amigo
umm, does anyone where to find UI programming paradigms
like MVC (model-view controller)
found something: https://stackoverflow.com/questions/24496/what-alternatives-are-there-to-model-view-controller
I think there is also an MVVM model too. I still don't understand that one.
ill look into it, thanks for your input ๐
Hello so, I am trying to launch my discord bot using a tkinter button but whenever I press the button my app crashes
The bot does launch but my GUI crashes
does it produce an error message?
no it just doesn't respond
import tkinter as tk
import os
from main import TOKEN
from main import client
root = tk.Tk()
root.title("Discord bot")
root.resizable(False, False)
canvas = tk.Canvas(root, height=700, width=700, bg="white", highlightthickness=0)
canvas.pack()
frame = tk.Frame(root, bg="black")
frame.place(relwidth=0.8, relheight=0.05, relx=0.1, rely=0.03)
def launch_bot():
client.run(TOKEN)
launch_button = tk.Button(root, text="Run", command=launch_bot)
launch_button.pack()
root.mainloop()
this is the code
How to change focus to next widget when user press enter instead tab in PySide 6?
Hey guys, I'm about to finish my uni Python course and I'm looking for a fun way to test my skills with a project. Decided to make a text-based RPG game. I've got all the necessary skills down but one thing I'm concerned about is having everything in a console window (rudimentary, ugly, problems across operating systems).
If I want to make a simple GUI for displaying text in a somewhat richer way than a console window, do you guys have any recommendations for where to start?
I suppose this might be an extremely basic question for this channel!
@red sapphire I would recommend using Tkinter
PyQt5
with Qt Designer
I'll look into both, thanks!
Ahhh boy, this is taking me back to the Flash days
Looks like I'll be diving into event listeners and whatnot again
the Qt licensing makes me a little bit uneasy
๐ฎ
Looks fantastic!
Seems the consensus is that the only downside of PySide is that it is not as actively developed as PyQt, but for something super simple like what I'm doing, it shouldn't matter at all
I figure there's always a chance that I'll develop something cool and want to distribute it, without wanting to spill the code guts, so the LGPL license makes up for anything
For an unbiased review of all the Python GUI tools: https://www.youtube.com/watch?v=nBkU6TEZ_BI
Choosing the best Python GUI Library: Kivy, PyQt, PyGui, WxPython, Tkinter. 5 Things to consider, pros, and cons of each library.
In this video, you will be able to choose between the most popular Python GUI libraries. You will:
-Learn about Kivy
-Learn about PyQt and PyQt5
-Learn about WxPython
-Learn about Tkinter
-Learn about PyGU...
Are you good with Tkinter?
What I learned about tkinter I learned from https://www.youtube.com/c/Codemycom/videos
Learn to code with our quick and easy to follow videos! Python, Django, Tkinter, Kivy, Node, Ruby on Rails, Ruby, HTML and CSS, Javascript, SQL, Ubuntu and More!
Check out my website Codemy.com for more videos!
Well there is this problem, I am trying to launch my discord bot from a tkinter button but everytime I press the button my GUI crashes
The bot does go on
Go through his videos about buttons and commands. See what happens.
I think it has something to do with threading tho I dont understand that one
He covers that too.