#user-interfaces
1 messages ยท Page 50 of 1
it starts out fine
and then this happens:
actually im going to put the full traceback in a codepen or pastebin because its huge
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.
You should check the pins in this channel for how to install kivy with python 3.8. It's a bit different than just pip install kivy
tkinter is part of the standard library, so you don't have to install anything else. As long as you have python you're good
and how to make my own custom look of gui?
or i should ask, how to use custom gui that i could design by myself?
@static cove ah okay thank you
I'm having some painting problems with the background of my GUI.
When I create my GUI I set the background for the main panel as a bitmap and I do some double buffering so I can scroll around the window.
The issue is I want to implement a darkmode by replacing the bitmap with a new one.
This works however whenever I scroll to a new part of the window it the new area reverts to the original background
The way I am changing the background right now is deleting the pannel and remaking it with the path changed to the new image
.topic
No topics found for this Python channel. You can suggest new ideas for topics here!
@subtle otter mostly discussion on GUI creation through Tkinter pyqt or wxpython
I was trying to run SeasonalBots topic command to see if this channel had topic starters @maiden dragon
.topic
No topics found for this Python channel. You can suggest new ideas for topics here!
whoops
Hey have a question maybe someone can help me? For example, if I have a project in Python and I want to do an API in Java or PHP, how would that work?
Hey, so. I made a dark theme for my eq, but the scale/slider has that weird white border around it, how do i get rid of it?
Tkinter, btw
just make padding 0 @plush stream
Aight, wait for a minute, i have to copy the code cuz im on mobile rn
yes sir
Okay then, guess i'll revert to light theme for the eq
Just for the eq, the player stays dark
hmm i like the current theme ;-;
Mmkay, i'll try the width
sure g
M-maybe not... Lmao
interesting it got skinny
I've tried borderwidth=0 too, but it stays the same
its def padding issue
isnt their like inspector for it
or u can just leave the shit like that and make ur bg a bit dark too..... bahhaha
@plush stream issue I am having is also related to trying to implement a darkmode. does your stuff at all involve changing from one bitmap to a different one
I don't know what do you mean by bitmap, are you talking about the app's icon?
i was wondering if it involved loading a bitmap into the app and switching to a new one when you enable dark mode
like in my case its for a background image
Ah got it, and no, that's doesn't seems to be the case for this one
damn I'm having a bunch of issues switching to a new background image
Hey anyone that can help me, i cannot figure out why my variable is empty. i want to get the contents of a tkinter Entry
class Register:
def __init__(self):
self.registerWindow = Tk()
self.registerWindow.title("Register with python")
self.registerWindow.geometry("300x250")
self.label = Label(self.registerWindow, text="Register")
self.label.place(x=95, y=40)
self.usernameS = StringVar()
self.passwordS = StringVar()
self.usernameE = Entry(self.registerWindow, relief=FLAT, textvariable=self.usernameS)
self.usernameE.place(x=70, y=80)
self.passwordE = Entry(self.registerWindow, relief=FLAT, show="*", textvariable=self.passwordS)
self.passwordE.place(x=70, y=120)
self.submit = Button(self.registerWindow, text="Submit", pady=5, padx=20, command=self.add)
self.submit.place(x=100, y=150)
def run(self):
self.registerWindow.mainloop()
def add(self):
self.username = self.usernameS.get()
self.password = self.passwordS.get()
# THIS RETURNS EMPTY SO THE DATABASE DOESNT PUT ANY DATA IN ASWELL!
print("Entered username is: " + self.username)
print("Entered password is: " + self.password)
self.salt = bcrypt.gensalt()
self.hashed = bcrypt.hashpw(self.password.encode(), self.salt)
print("from add: " + self.username)
data = (self.username,)
result = db.searchData(data)
print("From add method result is: " + str(result))
if result != 0:
data = (self.username, self.hashed)
db.insertData(data)
messagebox.showinfo("Successful", "Username was added")
else:
messagebox.showinfo("Warning", "Username aldready Exists")```
the print statement returns an empty line
i cannot figure out why its not getting the contents i typed in
which print?
oh sorry removed it 1 sec
so its not getting the contents from the Entry
its blank
has todo something with self.username = self.usernameS.get()
because the contents of that is empty and is not the username i typed in
so any help on this would be appreciated
Try .get(0, END)
self.username = self.usernameS.get(0, END) TypeError: get() takes 1 positional argument but 3 were given
Oh dangit, sorry. That wouldn't work with .get function
no problem the help is appreciated
Oh, i remember something
I've faced this issue before, i removed the variable,
Instead of
Print(self.username)```
It'll be like this ``` Print(self.usernameS.get())```
That would work in my case so, you should try it
okay ill try it ๐
uno momento
:p
Still empty
py .\main.py Successfully Opened Database Entered username is: Entered password is:
Damn
@hard trail How is the add function being called?
Is it just the submit button or is anything else calling it?
Also, the code you have there works for me (up until the bcrypt because I don't quite feel like getting that running). The self.username and self.password don't return empty for me.
Just to double check, how are you setting up the instance of the Register and calling it?
from login import Login, Register
class MainWindow:
def __init__(self):
self.app = Tk()
self.app.title("Login with python")
self.app.geometry("300x250")
self.label = Label(self.app, text="Welcome to app")
self.label.place(x=95, y=40)
self.login = Button(self.app, text="Login", pady=5, padx=30, command=login)
self.login.place(x=100, y=100)
self.register = Button(self.app, text="Register", pady=5, padx=30, command=register)
self.register.place(x=100, y=150)
def run(self):
self.app.mainloop()
def login():
loginTk = Login()
loginTk.run()
def register():
registerTk = Register()
registerTk.run()
app = MainWindow()
app.run()```
Thaaaat would probably do it. Give me a second to confirm why I think it's not working and I can do a small write up
Thanks alot ๐
@hard trail Yup! It has to do with the fact that you have a Tk() in the MainWindow class and and Tk() in the Register class. Those are separate instances of the Tcl interpreter and it is very, very, very highly recommended to only have one of them per app. If you have more than one things get a bit screwy and data doesn't get passed properly
A super easy fix, is to change the self.registerWindow = Tk() in the Register class to self.registerWindow = Toplevel()
That'll still create it's own standalone window, but it'll still be in the same Tcl interpreter
in TopLevel(i need to pass something here right)
Just self.registerWindow = Toplevel() should work
okay fingerscrossed
kat if you are available could i post some code for painting for you to look at?
@maiden dragon yes! Is it the darkmode wxPython thing? If so, I'm currently loading up my venv for wxPython troubleshooting
yeah yeah TYVM
ill try and get to relevant code copied
so when i set it to dakrmode i do this
def ontoggledark( self, event ):
self.darkmode = True
del self.panel_left
self.Refresh()
self.__do_layout()
#event.Skip()
essentially delete the panel and remake it calling the new bitmap
class col_panel(wx.ScrolledWindow):
def __init__(self, parent, darkmode):
"""Constructor"""
wx.ScrolledWindow.__init__(self, parent= parent)
self.maxWidth = 1410
self.maxHeight = 995
self.SetVirtualSize((self.maxWidth, self.maxHeight))
self.SetScrollRate(15, 15)
self.run = False
if darkmode == False:
self.SetBackgroundColour((254, 254, 242))
column = (resource_path(r"Imagefiles\col.png"))
#break
else:
self.SetBackgroundColour((4,5,35))
column = (resource_path(r"ImagefilesDark\col.jpg"))
self.bmp = wx.Bitmap(column)
self.columnbutt = wx.Button( self, wx.ID_ANY, u"Column Internals", pos = (340, 906))
self.Bind(wx.EVT_BUTTON, self.oncolbut, self.columnbutt)
if BUFFERED:
# Initialize the buffer bitmap. No real DC is needed at this point.
self.buffer = wx.Bitmap(self.maxWidth, self.maxHeight)
dc = wx.BufferedDC(None, self.buffer)
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
dc.Clear()
self.DoDrawing(dc)
self.Bind(wx.EVT_PAINT, self.OnPaint)
col_panel is created in __do_layout and should be created with the new bitmap
for somereason im unable to find the right import for TopLevel
@hard trail what do your import statements look like?
from tkinter import *
from tkinter import messagebox
import bcrypt
from database import Database
i tried from tkinter import TopLevel
but didnt work
i don't think deleting the panel is really a good solution tbh but I'm sure the best way to repaint the background plus i am using a scrolledwindow so everything is in damn virtual window lol
@hard trail ah, it needs to be Toplevel not TopLevel. Only the T is capital
@maiden dragon why delete the panel? Can you not just change the panel's background without deleting it? (I'm still getting caught up wxPython stuff, so sorry if that's a dumb clarification)
mostly cause this was assigned to someone else and that was their idea, i dont think thats a good way to do it im just not sure how to do it properly
it actually works fine if you keep the window maximized and never create any scroll bars but for people with smaller displays thats not an option
@static cove I want to thank you very much
its finally working
You are awesome
even my passwords are properly hashed so thats nice
Well, I wouldn't necessarily go with deleting the object and recreating it. That seems like unnecessary overhead and very micro-manage-y.
I'd have to read up again on python gc, but I think calling del just schedules the object for collection, it doesn't necessarily do it automatically.
yeah what i would prefer is a way to just delete the background and repaint it with the new bitmap
in tkinter i'm using filedialog.askopenfilename from a secondary window, and it's bringing the main window to the front. anyone else experience this?
you can do Tk().withdraw @trim ibex at least i used that and then you get just 1 dialog screen
I don't think you necessarily need to delete the background, but just set a new one with the new bitmap.
well when i scroll to a new portion of the window i see the old background so thats what made me think that
Do you have a function to handle the re-painting when you scroll?
yeah but i want more than one window
Curious if something wonky is going on there
yeah let me paste it for ya
my main window has a menu item that opens an informational window. on that informational window i click a button to open a file
when i do that the main window jumps to the front
!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.
atm i have it doing a raise on the informational window afterwards, but it looks crude
https://paste.pythondiscord.com/ugutifexug.py @static cove
that should be the class and how i have it handling painting for the scrolled window
you can ignore OnMove
So, is darkmode only able to set itself on initialization?
the its done now yeah but not sure thats a great idea
ideally you can change it at any point
i tried making the window topmost before opening the dialog, but then it just says in front of the dialog ๐ฆ
there's no reason an open dialog should even change the window order
do you need the PrepareDC function in the else in OnPaint? My guess is something odd is happening inside the PrepareDC and DoDrawing
I "think" i do because i think that allows it to handle the virtual area but i don't entirely know, I'm thinking maybe i can just recall DoDrawing from outside the class
and feed in the new bitmap
although I'm not actually certain how often it goes to that part of the conditional... so it could be an oddity inside BufferedPaintDC
ill try commenting out the else stuff and see
even a simple count for if it's in that part or not could help
tbh i don't think the else ever runs bacuse Buffered is just set to 1 at the begining of the file
yeah commenting it out did nothing so i dont think i even use it
Okay, so let's look at the BufferedPaintDC
It's only when you scroll that you get the non-darkmode background?
yeah, though that was when i was reinitializing the entire panel which seems unnecessary
just reverted some changes bacj to how i showed them to you gonan test that
yeah all of the same issues, but i think reinitializing the whole class seems liek a bad way to do things anyways
ok i think i mostly fixed it
or rather the issue now seems better so progress XD?
def ontoggledark( self, event ):
bmp = wx.Bitmap((resource_path(r"ImagefilesDark\col.jpg")))
dc = wx.BufferedDC(None, self.panel_left.buffer)
self.panel_left.DoDrawing( dc, bmp)
self.panel_left.SetBackgroundColour((4,5,35))
self.panel_left.Refresh()
now using this instead of re initializing the panel i just added the refresh so im about to see if that fixes the problem
basically it doesnt update untill i make the window reall small and then make it big again
yay! that is a lot better but one tiny issue lol
top left still stays the old color and idk why
dont worry about the PV,SP and mode being wrong color i just havent added that in yet
mmmmmm, getting hella flashbacks to my distillation and labs undergrad class.
you a chemical engineer?
That's my undergrad degree, yeah
WOW ahaha fellow ChemE
really curious then what do you do now?
if you don't mind me asking
Work full time for an org doing R&D type thing. Lots of modeling and simulation (mostly due to my comp sci minor). I'm also attending grad school part time for an MS in mechanical engineering
im trying to get into advanced process controls so simulations are a large part of what i wanna do, this project is actually meant to model a DCS system for students to use in our distillation lab class
lol well then youd love the program thats basically the engine of this GUI
spoiler its ASPEN HYSYS
But it's curious. It seems the border on the left is bounded by the size of your actual interface window
ok i figured out my issue. apparently the file dialog wants a "parent" parameter of what window to put the open dialog in front of. i then found a function to get tkinter's topmost window and fed it that
if i don't set the background i get this
as expected
but cant figure out why it won't set the whole thing
I wonder if when you set the background it's only starting from the top left of the image/graphic area and continuing from there. Or there's some sort of border that's overriding near the top
well when i initialize the window it sets the whole thing
Honestly, seems like a small glitch with wxPython and buffering
yeah mostly fixed though i can maybe show it to the grad student im working under
have him play around with it
thank you for the HUGE help, really helps alot especially to have someone who understands what is even going on here what with Aspen and what not
no worries! Feel free to ping me anytime about this stuff. I don't do a lot of systems processing or controls at my current job, but I did enjoy it in undergrad
TYVM, im graduating undergrad this December so i may even try to apply at aspen lol not really sure where all the process controls jobs are
Companies that still do a lot of processing in the states will have their own process control items. So anywhere that does a lot of manufacturing. Even some of the more complicated beer distilleries and stuff like that.
and of course the companies that make that software
hmm thats nice, i worked for a company that makes medical garements with viral barriers they are making bank right now so i may hit them up
won't spam this chat too much with off topic chat tho lol
Please can someone try and run this calculator app: https://github.com/driscollis/applications_with_wxpython/tree/master/chapter6_calculator - I cannot get any of them files to run, I get an error from wxPython
what is the error @balmy ferry
@maiden dragon - wx._core.wxAssertionError: C++ assertion "!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL))" failed at ....\src\common\sizer.cpp(2114) in wxBoxSizer::DoInsert(): Vertical alignment flags are ignored with wxEXPAND
I got around it by removing the flags from the BoxSizer and now it runs
but odd as this code would have been tested before going up on github by the author
Thanks for responding though @maiden dragon , its appreciated
๐
sure thing, for some reason i dont think wxpython is as popular here as tkinter
or pyqt
@maiden dragon ur pipes look cool
@ashen swan thank you ๐
you familiar with distillation systems or just like how it looks
oxidize or reduce i cant remember to alchol from acid
if you say so ๐
i have no clue tbh
lol oil rig
๐
is ur pipes for gas pipeline?
yeah, essentially a bunch of petro chemicals come into it go into that middle thing that seperates them
and the python project is to control the program that does all the calculations
of which there are a lot
damn thats cool
glad you appreciate it. its been really fun when I'm not trying to slam my head into a ton of bricks
ive only worked with very very basic python before this so its been such a learning experience
this discord has been a massive help since we aren't taught to code as engineers
got my darkmode working \o/
How do I set up a window so you have to press ok and can't click out of the window?
Hey guys,
I dont know if this fits here well as I assume to use Matplotlib or OpenCVs cv2.imshow but I need some advice about the user interaction with an image displayed.
The software I am planing will be open source to help a medical study about diabetes and overweight.
The user has to define multiple (two) regions of interest on an Image defined by exactly 3 points (triangles).
Existing triangles have to be changeable, so the user should be able to drag and drop an existing point of a trinangle to a new location.
In OpenCV there are prebuild rectangular bounding boxes to use.
In Matplotlib there are a bunch of events and stuff I could build this on.
But as I have not so much time to build this app I would like to here if you could give me a hint for a smart and user friendly solution I am not aware of.
anyone know how to add a new custom option when subclassing a tkinter widget? something that would be used in the normal way with the config method
Alpi needs to read item #1 in the thing he linked.
Pretty funny stuff going on here. Does anyone know of a good JS data grid that supports filters that will allow cascading as well as show sub totals for the results? Datatables with searchpanel does an okay job but it is limited on include/exclude options and more advance features.
Material ui for react js
hello all
is anyone familiar with Gtk library?
im trying to make a listbox scrollable. im loading content from a web api and the list is pretty big. not sure how to go about adding scrolling to it.
class Window(Gtk.Window):
def __init__(self):
...
self.menu = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
self.button_products = Gtk.Button(label="Products")
self.button_products.connect("clicked", self.list_products)
self.menu.pack_start(self.button_products, False, False, 5)
self.button_accounts = Gtk.Button(label="Accounts")
self.button_accounts.connect("clicked", self.list_accounts)
self.menu.pack_start(self.button_accounts, False, False, 5)
self.display = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.listbox = Gtk.ListBox()
self.scrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL)
self.display.pack_start(self.listbox, True, True, 5)
self.display.pack_end(self.scrollbar, False, False, 5)
self.main_box.pack_start(self.menu, False, False, 5)
self.main_box.pack_start(self.display, True, True, 5)
so, about Python GUIs..
Iโve seen people recommend against Python for GUIs and suggest .NET or Java. Iโve kind of forgotten those languages for now, and Iโm kind of in a rush... what do you guys think about this?
Related question... are installer GUIs possible (or should I stick to command line based installer interfaces)?
.net and Java will be more suitable for their main platforms (win, mobile) but python can handle desktop apps perfectly fine thorough libraries like pyqt/pyside (Qt bindings), kivy, tkinter or any of the other GUI libraries. Mobile is a bit harder but it's possible to build kivy apps for it (or Qt but that strays away from python in the frontend code)
I have been using wxGlade to generate decent UIs so far. I was wondering if there was any similar -yet better- option out there. Also, what would be the best practise to develop portable apps with a python background ?
hey guys i need some help with pyqt5 why when i change the colour of the vertical scroll bar in textedit in qt designer it shows properly on like the designing screen but on the preview it reverts back to the default scroll bar? Tried everything like applying colour,gradients and stuff also for some reason when i customize the scrollbar none of my changes take effect in real-time how do i fix this?
What language does flutter use ?
I want to make an app and ive been wondering what tools to use
I know the basics of python so maybe kivy idk which one is better guys ?
Flutter uses dart. Both kivy and flutter is cross platform. Personally I prefer Flutter since it just looks better and dart is very easy to learn, similar to Java. Kivy is also nice and might be easier if you only know python. Your best bet is just to try both and see which one you like the most.
Okay thx I appreciate it
anyone good with tkinter?
There's a fair amount of people with tkinter experience, what's your question?
Yeah, I'll also need help with starting tkinter, please for the love of God dont cringe I am so damn new to tkinter.
I'm trying to make an application where I can reverse image search using SauceNAO. I already have the searching stuff set up, its mostly just the tkinter stuff that I'm struggling with
Yes. Again, it's more helpful if you post your question vs asking who is experienced with something.
What do you think is the best GUI framework for smallish apps (id like to make a personal info display using a raspberry pi)
I built a small app in tkinter but I didnโt like how patchwork it felt sometimes. Are there better alternative?
Hey @sturdy pine!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
any idea why txt3 and txt4 isnt being centered?
QMainWindow.__init__(self)
self.setMinimumSize(QSize(1280, 720))
self.setWindowTitle("AIRPORT LOL")
central_widget = QWidget()
self.setCentralWidget(central_widget)
# Create textbox
self.textbox = QLineEdit()
self.textbox2 = QLineEdit()
txt1 = QLabel("UK Airport Code",self)
txt1.setAlignment(Qt.AlignCenter)
txt2 = QLabel("Overseas Airport Code",self)
txt2.setAlignment(Qt.AlignCenter)
txt3 = QLabel("Airport Name: ",self)
txt3.setAlignment(Qt.AlignCenter)
txt4 = QLabel("JFK",self)
txt4.setAlignment(Qt.AlignLeft)
tkinter is a real pain and can be super clumsy but use your skills to abstract and subclass everything
if a widget is missing something that it should have (like clear() on a Text widget), add it!
i made a draggable class so i can just subclass everything and now all my widgets are draggable with the middle mouse button. i think i'll work in a design mode for this. here's what i got my project looking like (doesn't look like tkinter and that's a good thing): https://i.imgur.com/3dnnHRL.gif
added a hover color to buttons, and i have labels using the background of their parent (either a tk or ttk container) to fake transparent background
one thing to note about tkinter-- if it's important to you that everything looks the same on every platform you probably want to go with something different. tends to have quirks for different os. if you can test everything well then it's not such an issue
qt is heavy but better all around. sometimes it gives you hard to track down complications though
@trim ibex can u share code?
I figured out how to make a widget scrollable in Gtk.
class gTrader(Gtk.Window):
def __init__(self, client):
Gtk.Window.__init__(self, title="gTrader")
self.set_border_width(5)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_default_size(640, 480)
self.client = client
self.main_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
self.add(self.main_box)
self.menu = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
self.button_products = Gtk.Button(label="Products")
self.button_products.connect("clicked", self.list_products)
self.menu.pack_start(self.button_products, False, False, 5)
self.button_accounts = Gtk.Button(label="Accounts")
self.button_accounts.connect("clicked", self.list_accounts)
self.menu.pack_start(self.button_accounts, False, False, 5)
self.display = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self.display_scroll = Gtk.ScrolledWindow()
self.listbox = Gtk.ListBox()
self.display_scroll.add(self.listbox)
self.display.pack_start(self.display_scroll, True, True, 5)
self.main_box.pack_start(self.menu, False, False, 5)
self.main_box.pack_start(self.display, True, True, 5)
Hey @trim ibex!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
oh bleh
getTopWindow is handy to pass to dialogs so it doesn't mess with the window order
the setHoverColor thing is kind of clumsy because i dont know how to add more stuff to the config
it'll be more elegant when i figure that out
I want to make a photo archive organization tool in python, and I'm learning tkinter so I can use it to create the user interface, eventually I want to make the UI look clean and modern, would tkinter be capable of something like that?
is it simpler to use?
oh wow i just discovered qt design studio
damn'
just discovered the price! damn
what makes PyQT better for GUIs than tkinter? is it just QT designer is easier to use than line-by-line programming
honestly at the moment i just need it to find a path of images and display them
like at the bare minimum
and i'd love to use PyQt but i cant find a single resource that teaches that
i've found a lot more comprehensive tutorials for tkinter though, unless i've been looking in the wrong places
like that Codemy tkinter tutorial series seems more appealing than sugar to me but if there was something of equal calibre for pyqt then i would love for somebody to point me in that direction
should i use qtdesigner? or would it be better to actually program it
i'm very new to programming and i dont want to get lost in the simplicity of dragging check boxes around
it can be awkward just working with the code for a ui. if you come from web design you might prefer it. i would go with whatever gives you the best results for your needs
Using tkinter to try and add a thumbnail image
But it comes up empty
This is the code
def add_thumbnail():
thumb_url = 'https://tr.rbxcdn.com/7ca5fe69628208a51c068250c727c68f/48/48/AvatarHeadshot/Png/isCircular'
data = base64.encodebytes(urllib.request.urlopen(thumb_url).read())
img = tkinter.PhotoImage(name="Profile Image",data=data)
w = 520
h = 320
x = 80
y = 100
window.geometry("%dx%d+%d+%d" % (w, h, x, y))
cnvs = tkinter.Canvas(bg='white')
cnvs.create_image(50, 50, anchor='nw', image=img)
Please someone help me on how to use Tabs on Kivy i have tried the same code that is showing in their documentation but still not working i have no idea how to make it working
@main bloom show the code
from kivy.uix.floatlayout import FloatLayout
from kivymd.app import MDApp
from kivymd.uix.tab import MDTabsBase
from kivymd.icon_definitions import md_icons
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_tab_switch: app.on_tab_switch(*args)
<Tab>:
MDIconButton:
id: icon
icon: app.icons[0]
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Tab(FloatLayout, MDTabsBase):
'''Class implementing content for a tab.'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
return Builder.load_string(KV)
def on_start(self):
for name_tab in self.icons:
self.root.ids.tabs.add_widget(Tab(text=name_tab))
def on_tab_switch(
self, instance_tabs, instance_tab, instance_tab_label, tab_text
):
'''Called when switching tabs.
:type instance_tabs: <kivymd.uix.tab.MDTabs object>;
:param instance_tab: <__main__.Tab object>;
:param instance_tab_label: <kivymd.uix.tab.MDTabsLabel object>;
:param tab_text: text or name icon of tab;
'''
count_icon = [k for k, v in md_icons.items() if v == tab_text]
instance_tab.ids.icon.icon = count_icon[0]
Example().run()
@dire fern here you go
this is the error i am getting and i don't even understand it
P.s this is the basic first example you can find in kivy documentation but doesn't work for me ( https://kivymd.readthedocs.io/en/latest/components/tabs/index.html )
i need help..
pyautogui not working properly. absolutely no idea why.
working on linux ubuntu 16.04 LTS, trying to use it in repl.it and/or jupyter notebook.
I am totally new would appreaciate some help ty
can someone tell me how to use Tabs on Kivy please ?
hey guys, question: how to make python to click on windows notification that appears in bottom right corner when it appears ? is there any library for that? just to add here: never know when notification appears from opera
thats completly random
can someone explain why does this error occure on Kivy ?
Hey simple question. After I callback a command from a button which destroys visible widgets, more widgets are supposed to pack but nothing shows. (tkinter)
probably need to see the code
help
Is it just me or is layouting in pyqt5 (designer) hard, I just can't get things to be where I want. I want a button to have a fixed height but be expandable in terms of width so I created a frame and put the button in it, placed it in the bottom. Similar to pack(side="bottom") in tkinter. Then I chose gridlayout for the window and everything gets screwed. Can someone link me to a tutorial for layouting? I wish it could be similar to tkinter.
@trail wasp you need to hold a reference to the image outside that function. Otherwise it's getting gc'd as soon as the function finishes
@sturdy pine I'm gonna take a look at this today, but my guess is you need to do a specific layout with QForm, otherwise it'll default to the 2 columns
Haven't run into many problem with layouts, but spacers help a lot
Glad you got it working!
Haven't run into many problem with layouts, but spacers help a lot
manually adjusting coords helped me with it too
also the designer is technically a lite version of the software
Where do we go
๐ผ
๐

how u do that if u dont hve nitro
You new to discord??
no
๐
bruhhhhhh
The server emojis
๐ค
Yes, but you can use it here

Another :
:::::::::::::::::::::::::::::::::;
At the end
developer?
oof
Ye
suggest u mix it with sololearn
How did you startt 
Starting??
So, you've never done it beforee??
:DD
im starting in 3 month
@jolly quail Why not nowww
urm busy with school
Ye
Python tutorial - Python for beginners
๐Learn Python programming for a career in machine learning, data science & web development.
๐ฅGet my Complete Python Programming Course with a BIG discount (LIMITED TIME): http://bit.ly/35BLHHP
๐Get My FREE Python Cheat Sheet:
http://bit...
It's a 6hr video 
oof
IM USING THAT ONE RN
he got banned LUL
Hey Guys, im trying to learn tkinter rn and I dont know how to expand the 0 button only to the right, if I double its size it looks like this
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.
like this?
button_0.grid(row=4, column=0, columnspan=3)
because now its just in the middle
@plucky wedge
button_0.grid(row=4, columnspan=3) @steel lodge
its also just in the middle
ohh wait , u want it to be streched across all 3 buttons?
no across only the 2 left ones ๐
width=10
where?
button_0 = Button(root, text="0", padx=40, pady=20, command=button_add, width=10)
experiment with width
its expanding to the left and right ๐ฆ not only to the right
Ikr? It's kinda frustrating to see for the first time watching codemy's tutorial
๐ฏ
does tkinter have more features than PyQT or does PyQT just have horrible documentation
also if i write my whole program with tkinter would it be an absolute nightmare to then manually convert it to work with PyQT
I've Qt has waaay better documentation than tkinter
i havent checked out the official documentation- i'll give it a look
@static cove is it bad I'm using QT to do my GCSE NEA lmfao
_> I don't know what GCSE NEA is...
uhhh are u American?
it's basically an important exam for grade 10 in UK, however you have a program you need to code in 20 hours
99% of people use CLI ๐
im doing GUI ๐
Well good luck!
https://github.com/micho44/EmbedGenerator - i made this embed generator for discord , it uses webhook to send embeds (you choose name of webhook user , his pfp and channel where its send in webhook settings) and later just type what to send and yes its fully operational with gui made using tkinter
@sturdy pine for our year the CSNEA didnโt count towards our grade so I just did a CLI based program. Up to you though. For my A level coursework Iโm doing something way more difficult.
what are the advantages of using tkinter over pywebview? I know html/css/js already so it would be the easiest for me to use but if theres a performance benefit or something for using tkinter i will
hey! is there a way to convert something like 1s 1m 1h into seconds?
ping me if u answer
Where can I find a list of all the events in pyqt5 such as mousePressEvent and such. If someone could send a link it would be great
i think you can just find it by searching up the officals docs for pyqt5
and searching up events there
hey! is there a way to convert something like
1s 1m 1hinto seconds?
@hollow torrent nvm
what are the advantages of using tkinter over pywebview? I know html/css/js already so it would be the easiest for me to use but if theres a performance benefit or something for using tkinter i will
in addition to this,webview.start(debug=True)should forward console.log messages to the python console right?
How can I add a new window in qt designer that is separate from main window?
Anyone use tkinter
I want to know how to detect mouse button down
if yes, plz go to #help-cake and help me
Pleaseeee
How can I add a new window in qt designer that is separate from main window?
@serene oriole same question
but i guess there must be two separated project and one shows up on event like click on button
but not really sure so i would like to know how to as well
@placid nebula yeah I found you gotta create a separate window and on click make it show up
my first time using pyqt5..
or any gui library tbh
idk but i feel code created form qt is messy
pyqt5 designer is a useful application in my opinion
sure it, but im beginner so all the code which you convert from ui to py looks horrible
is*
everything is in the class and organized. I wonder if I do not understand the clean code. I made an application with a user interface, but I'm a beginner out of most people here
(everybody says I'm not able to write clean code)
Creating a new window in pyqt5 should be relatively clean. You either create a new instance of the existing class or create a new class for the specific window
@wise hearth you should be able to bind to <Button-1> to call a function when the left mouse button is pressed
Take a look at this page to see all the different bindings for tkinter https://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
I have actionUsername button in the menu bar, but it doesn't support .clicked.connect() method py MainWindow.setStatusBar(self.statusbar) self.actionUsername = QtWidgets.QAction(MainWindow) self.actionUsername.setCheckable(False) self.actionUsername.setObjectName("actionUsername")
self.actionUsername.setCheckable(True)
?
I could not fully understand the problem
@serene oriole
@serene oriole actions don't have a .clicked signal, it should be .triggered
Buttons have the clicked signal, Actions have triggered. It's a bit annoying *shrug emoji here*
I mean in my head both are buttons, just on different places..
Yeah. They behave slightly differently, but again, *shrug emoji*
But if you're talking about a menu, you can place Buttons there. Actions just fit better stylistically
https://doc.qt.io/qt-5/qaction.html#public-slots Here are the available slots for a QAction. Looks like you can do hover and toggle as well
oh whoops, should've linked a section below. You want signals, not slots
but still, you have hovered(), changed(), and toggled()
Triggered would be the replacement for the clicked
I think it's specifically triggered and not clicked because they're trying to design it so that keyboard shortcuts can also activate the menu buttons, not just clicks
how would I make the triggered action open another window that is inside another class?
Well, assuming that the new window is already instanced and just needs to be shown. It would just call the .show() function on it
I basically made MyApp class just to add event methods to it, but don't know how to connect another window to it
It's not instanced yet
While instantiating your MyApp class, I would make all children windows initialized too, but just not shown yet. Then the button functions would show them
Or you can have the button initialize it too, depends what you want to do
@static cove I wrote this method, but on click it shows the window briefly and isntantly closes it without any errors
Probably because you're losing reference to it. As soon as the function ends it gets gc'd. You probably want to have some sort of variable in the MyApp class to hold the reference to that @serene oriole
will try adding it as an attribute, thx
I've got a QLineEdit set up, but my cursor goes behind it? is there a way to stop this or have I done something wrong
also @serene oriole I set up my __init__'s like this and it seemed to do the trick:
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)```
@echo ruin I did it like this but it feels to janky to add it for every possible window/form
ya idk all the examples I've gone through set up the window with super().__init__()
I am pretty new on oop, super().__init__() basically allows me to inherit from multiple other classes is that right?
could you show some more code @echo ruin ?
super() will inherit from its parent class. With Qt it's necessary to make sure all functionality is behaving as expected
but I don't understand how that is useful for what I am trying to do =/, seems like I should incorporate it in my code, but it doesn't solve the jankiness of having windows as attributes of main window
every time you want a new window, you have to create a new instance of the window
class MainWindow(QMainWindow) by passing QMainWindow into your class + using super().__init__(), you're allowing your class to initialize QMainWindow and therefor create a new instance/window
I've got no clue what having parent in there does, but it fixed the issue where the window wouldn't stay open
also ya if you need to create a new window for every thing/form then you'll have to create a new instance every time @serene oriole
the parent makes the object keep the parent object alive by keeping a reference to it, if you don't do that it gets garbage collected by python which in turn does all the cleanup and possibly some invalid references by qt
So if 2 calls to the qt window are made, without the parent, gc only allows the first instance of the class to stay?
to be honest I am completely lost but I managed to fix it
what procedure would you follow if pyinstaller generates a .exe file but when you run it nothing seems to happen and theres no error messages?
@echo ruin 10/10 name
i had same problem with pyinstaller , still didnt fix it
it created all files but doesnt run
what procedure would you follow if pyinstaller generates a .exe file but when you run it nothing seems to happen and theres no error messages?
@maiden dragon did you make it generate onefile
does PyAutoGUI run on jupyter notebook on linux?
if yes then how do install it
looks like it
download it into your env: conda install -c conda-forge pyautogui
@digital rose
Hi guys, I am using dearpygui to graph a few functions and then with a button trigger another script to draw the functions in 3d with matplotlib. For some reason the plot works the first time but then when I close it and try to open another it opens nothing. If anybody could help I would be very appreciative.
code is here https://github.com/wilcockj/ZoomBergTerminal/
stockgraph3d.py is the 3d plot script
What is the simplest way to deal with tkinte
@junior needle Wdym
To do what exactly
what is best option? use the same main window and after "clicking" button kill all visible things and show new ones - like new window or making new window and connect it to popup after clicking and kill the past one?
how to deal with showing new window in same spot like previous one?
(qt)
Guys how do i get the name of the widget in Qt like i am making a searchable dashboard and i want the line edit's text value to like search for the widget and pull it up and show that widget if the name matches for the widgets name and hide the unrelated widgets) but how do i like get the widgets name and compare the values??
Hi, I am trying to use Spotify API to mimic this site http://sixdegreesofkanyewest.com/.
I figured out how to query related artists with the help of API but I can't figure out how to build a relationship graph
Ideas?
not me ๐
PyAutoGUI not working on jupyter notebook ๐ข machine is ubuntu 16.04. how do u do it
@carmine scroll I mean how to know all the methods and how to update the window every frame?
@carmine scroll I mean how to know all the methods and how to update the window every frame?
@junior needle Follow a tutorial. I sometimes think text tutorials are better than video. There's a nice one on Realpython. Check it out
I need help, i am using tkinter and i want to make it so it shows an image when you run a function, but the image doesnt show up when the function is called altho it works fine when it isnt in a function
You need to safe the reference of the image outside of the function. Otherwise the reference to the image gets garbage collected once the function ends and tkinter has nothing to display
on tkinter
i would like the make it so that when someone presses enter the code will continue
like the same way i would just type input() in the middle of a normal program
any1 know how?
Working on a UI, I have no idea what to do with the tool options other than make icons. What would be a good size?
The icons icons would be black/transparent like the ones that pop up when the mouse hovers over one of the layers or frames in the treeview
like the same way i would just type input() in the middle of a normal program
@kind marsh import keyboard
import keyboard
if keyboard.is_pressed('x'):
*rest of code*
I'm pretty sure tkinter has functions for that
Look at https://effbot.org/tkinterbook/tkinter-events-and-bindings.htm, specifically, the .bind() function
thanks
@kind marsh import keyboard
import keyboard if keyboard.is_pressed('x'): *rest of code*
@plucky wedge it doesnt work
1 sec ima send a ss
Iโm having
QStandardPaths: xdg_runtime_dir not set
error and I canโt find much about it, my codeโs currently just notes but they are all either in multiline string or commented out, so they shouldnโt affect this, but the application does not run and outputs that error, which I canโt find any info about for some reason.
hmm
on an unrelated note, I'm having trouble getting an image to display in the qt designer, I've tried importing it (png) as both a pixmap/icon but neither seems to display it/do anything
aly, I'd suggest trying out tkinter's method rather than an different library
what method is that?
im pretty sure tkinter have that method
lemme check some other codes , i might have used other way soemwhere
ok thanks
not really what you're looking for
idk look it up
thanks, im sure i can chage it abit atleast i have smth to start from
on an unrelated note, I'm having trouble getting an image to display in the qt designer, I've tried importing it (png) as both a pixmap/icon but neither seems to display it/do anything
just gonna shimmy this down here
'pyuic5' is not recognized as an internal or external command,
operable program or batch file.
anyone know how to deal with this?
Why isn't this giving the border radius to my tab?
why so many ppl use self , lke what does it change
@plucky wedge I'm working inside of a class, so for creating a class method we need to pass the self argument
can anyone tell me how to get return value of a function called by button(tkinter button)???
@twilit helm I think you should implement that into your command function
@twilit helm I think you should implement that into your command function
@vague gale how?
how to implement in command function
@plucky wedge classes/oop allow you to do something like this:
class Window(something):
def __init__(self):
self.x = 50
self.pos_x = 50
message = self.setupThingy(pos_x)
print(message,self.x)
def setupThingy(self, pos):
self.x += self.pos_x
return "some string"```
so in the example, even if you don't return x, self.x allows you to modify x within the class
wait so if u have class and self will work like global for whole class?
but in something like pyqt5, it allows you to do smth more along the lines of:
class StartWindow(QMainWindow):
def __init__(self, parent=None):
super(StartWindow ,self).__init__(parent)
self.windowWidth = 200
self.windowHeight = 200
self.setGeometry(100, 100, self.windowWidth, self.windowHeight)
self.initUI()
self.show()
def initUI(self):
self.setStyleSheet("background-color: rgb(0,0,0);")
self.setWindowTitle("Speeed")
...
within the scope of the class ya
it's basically another data structure that allows you to access values/functions without the added complexity
np, I actually avoided learning it up until like a month ago, but it's super useful in a lot of senarios
yea i tried to avoid it as much as possible as i didnt get it and couldnt find easy but efficient meaning for taht
2.5 months of coding while avoiding it
What 2 add up here? It's an audio player
bruh i dunno what u need but i already love that gui look
i would use that space for these buttons
I would recommend using pyqt5 for whatever you want to do, tkinter wont make it look pretty
im on a deadline and i have never worked with tkinter or pyqt5 before
how hard would it be to do this in pyqt5?
how similar is pyqt5 to tkinter?
Here I am useing tkinter to make a basic text editor
I want my buttons organized in a toolbar for obvious reasons.
So I wrote the code shown and there dont seem to be any buttons in the program. No errors show up.
Sorry that these arenโt screenshots btw I am having other issues
Feel free to tag me if you have any ideas
@subtle otter I used mockplus
But I donโt know how to program it
Bc idt it has a program feature
@exotic dirge pyqt5 has a ui designer if you use qt creator on windows
on linux systems, there's a lighter tool called qt designer which is only for building the ui, whereas creator is for both the c++/python code, and the UI
on windows you will need qt creator since qt designer is not available on it
qt designer is there on windows?
with the pyside 2 installation you get it
or you can just download from the website
oh
didn't know that
well all I can say is that qt5 boosted my workflow. I finished an app in about 2 days using it
The fact that I could use qt designer made it even better, cause I could just convert from a .ui file to a .py file and use that code as the interface
@digital rose hehe, I remember when I used to make mockups without even adding functionality, check out qt designer/creator
yup its very helpful and good
Does anyone know why my qt designer's ui looks so old like tkinter?
I saw other people's qt designer and it looks far more modern
I'm on the newest version too, so idk what's happening here
that's just what it looks like on windows I think
nah
for me it looks a bit different
@plush stream try the pyside 2 version maybe?
if that doesnt do anything you got the latest one then
and it looks like its supposed to
I followed a tutorial from a YouTuber by by the name of Tech with Tim
Mine looks like this but it's because of my system theme
yes
And he doesn't use anything related to pyside
things can change due to your system theme
for me also it changes according to your system theme
I might try to restart
I use the window default theme btw
Nah, restarting doesn't work
then it looks like its supposed to i guess
Yeah, it seems to be just the editor, the output window looks just like Windows 10 window
Though it's annoying that the preview in designer doesn't match up with the output window
I mean, it does use the win32 api tho soo yeah
root = Tk()
checkedBox = IntVar()
for i in range(4):
checkbox = Checkbutton(root, text=i, variable=checkedBox)
checkbox.grid(row=i, column=0)
root.mainloop()```
why does checking one of these boxes tick all of them
:/
if i remove the variable=checkedBox it works fine but then i can't see if the boxes are checked or not
@plush stream also the designer you're using isn't the full designer studio
Oh? I don't know it was different
Okay, thanks, i'll check it out
but you can always get away with only using the qt designer too
Got it
actually you might have to buy it, I haven't looked into it too much
I don't think so, it's open source
Also, since i'm new to pyqt, is it able to animate menus? So they'll have some sort of transition animation?
yes
you can use qt designer itself for this
but you need to know css to do this(i think)
or use the QpropertyAnimate
not sure
Cool! I've been wanting to do that, couldn't do it with tkinter ๐
Hello, is there someone who programs on PyQt5 with vscode ?
i'm getting troubles with these errors idk why
@cinder grove i am pretty sure you have to do from PyQt5.QtCore import Qt
@bronze basin not working :/
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent
from PySide2.QtGui import QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient
from PySide2.QtWidgets import *
import sys
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
@cinder grove this is how i would usually do mine
you can just replace the PySide2 with PyQt5
i am not exactly sure how you have done what you did maybe you didnt define smth properly?
you usually have to do this
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__()
your code here or whatever
or what i did
i have never seen someone do it by just calling a function without defining the MainWindow Class
@bronze basin yes i know for the mainwindow class i just wanted to do a "fast test"
I will try to do it with PySide2 since i have both installed
what's the difference between pyqt and pyside ?
Nothing much actually
main difference is the licensing
between both of them
everything you do with pyqt5 can be done just as well in pyside2 (to my knowledge)
ok @bronze basin are you using vscode or pycharm ?
vscode
ok i've tried your code but still not working
maybe i've to install extension from vscode market ?
@cinder grove
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent
from PySide2.QtGui import QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient
from PySide2.QtWidgets import *
import sys
from yourdesignfile import Ui_Mainwindow or whatever main class you have
class MainWindow(QMainWindow):
def init(self):
QMainWindow.init(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
i forgot to add that part
or if you dont want to make another file and stuff
import sys
import platform
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent
from PySide2.QtGui import QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient
from PySide2.QtWidgets import *
# You need one (and only one) QApplication instance per application.
# Pass in sys.argv to allow command line arguments for your app.
# If you know you won't use command line arguments QApplication([]) is fine.
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
`code here`
app = QApplication(sys.argv)
window = MainWindow() # or QWidget() will also work
window.show()
# Start the event loop.
app.exec_()
you place all your qlabel and stuff
where i say code here
still not working for me
why the labels and entrys are stuck like that when they are on a new roww
fixed ty
@bronze basin finally, i go back to qt creator(compiler) and editing code with vscode (better theme ^^, and autocompletion)
i am using tkinter and i want to update a label while other code is still executing. how do i do that? if i just put aproxTimeVar.set("some value") it won't get updated until the rest finished executing.
label.configure(text="new text") should work
i'm using ui.update_idletasks() now. it works..... idk if i should use it for that, but it works.
hmm, I might migrate all my code to pyside
depends on the freedom I get from using the bindings
can anyone tell me which lib should I use so that I can have my widgets floating meaning that it can be placed anywhere in the window
@west briar pyqt5 or pyside2
Hey guys, I'm trying to make an app where user's can drag different Circuit items (resistors, wires, etc) from a menu onto a circuit board to construct their own circuits. What GUI frameworks do you suggest for such a project. Is Python even a good language for such an app?
Hey i want a GUI for chat bot.
Can u guyz share some websites where i can get the code for some simple GUI
!say
hey guys, I am willing to return 3 labels (using kivy), but it returns only one, can someone help me please ?
have you name them differently?
yes I did
I'm super sorry I answered late
Guys ^^' I had another issue, I tried packaging my app for android, but I had a big error, If someone can help me out :
Hey @clear cipher!
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:
oh aight
here is the pastebin of the error
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.
Hello boys
Im looking for a more advanced python library to create interfaces with other than tkinter, though easy to use, but I believe it is lacking visual power...
Anyone got any tips?
@digital rose Commonly recommended ones are PyQt/Pyside2, Kivy, and WxPython. There are a few ones not used as often like the GTK bindings and a couple of others.
Yh i already checked a few
Though I am looking for like, โthe next stepโ when it comes to interfaces
As background code aint the problem
Isnโt it a game engine rather?
Also pyqt is premium?
Also any downsides on using pyqt, Looks the most promising
The biggest thing with pyqt is the licensing. PySide2 is an alternative binding of the Qt library and it's a LGPL license.
Is pyqt thhe only drag and drop interface builder? I like the concept? Also Ping gtg
Just to mention, there is a realy easy GUI module called DearPyGui itโs open source on github
Pyqt has a drag and drop program, Qt Designer. But I code all my UIs from scratch/dynamically
I wouldn't think pyqt is that easy, but I also wouldn't know
kivy is easy enough once you learn kv lang
I think that no matter what you will find a drag and drop for, it just won't be sufficient for anything more complex; but can be useful for prototyping
Anyone looking for a different type of GUI library may like, DearPyGui. We are currently looking for more feedback/users. We are preparing to move out of beta soon:
How do i edit pyqt ui that i made inside qt designer? You see, i converted the format from .ui to .py and i already wrote my code inside that .py file, so how do i edit that ui like adding a button without rewriting the code that i wrote earlier?
You can't. That's one of the downfalls of ui designers that produce the code
Usually what you'd do is separate the generated UI code through subclassing or something like that
Ah, well. I guess i'll use it for prototyping then, thanks for the answers!
hey @static cove any chance you have come across the wxmplot module before?
if not no worries, its quite amazing but some things seems a little odd
Does anyone know if theres a way to yield to the PyQt5 event loop? I know there is the Timer capability in Qt, but its also seems to require a callback function. It's obviously livable but I was curious if I could just yield and wait for the event loop to cycle back to one of my loops.
if I wanna make a GUI for a RPi that shows data I read from the GPIO pins, which library should I do it with?
please ping on reply
Can I please get some help?
@maiden dragon I haven't yet, but I'll probably check it out soon
making progress with it, really powerful stuff. should work well for my dynamic plotting
@reef remnant Do you have code to read from the GPIO pins already? It shouldn't really matter which GUI framework you use unless you have very niche/odd data you need to visualize
I don't have anything yet I'm waiting for my pi to arrive
but I've never done anything in python that is GUI related
Well, I'd focus first and figuring out how to get data, looking at what the data looks like, and then seeing what's a good fit for visualizing it. tkinter + matplotlib is a common pairing. I personally prefer pyqt5/pyside2 + pyqtgraphs. mrpolymath above has mentioned wxpython + wxmplot. There are definitely options, it just depends on what kind of data you want to plot
Also, when you say "GUI for your rpi" are you going to have an external monitor connected to it or do you have like a touchscreen interface you plan to connect via GPIO?
But once you get it, feel free to ask here if you have specific questions for dealing with a GUI framework~
I just need to read a data and print it out on a GUI I don't think I really need matplotlib tbh
Also, when you say "GUI for your rpi" are you going to have an external monitor connected to it or do you have like a touchscreen interface you plan to connect via GPIO?
@static cove I'm going to connect it to a PC monitor
Well, it depends on the type of data. If you want to graph it you'll need a library that can graph. Matplotlib is the somewhat of the defacto standard for that (although I don't like it for dynamic and liveplotting data, it can be a pain to set it up correctly)
Then yeah, an rpi is just a microcomputer, so nothing special for getting it to display stuff necessarily.
Also feel free to ask questions with rpi in #microcontrollers
Well, it depends on the type of data. If you want to graph it you'll need a library that can graph. Matplotlib is the somewhat of the defacto standard for that (although I don't like it for dynamic and liveplotting data, it can be a pain to set it up correctly)
@static cove no need in a graph tbh, just the value which is probably a float and maybe a string I'm not sure yet
Well, if you don't need it looking nice tkinter is probably the fastest since it's in the standard library.
I'd recommend tkinter then. There's a few oddities but there are plenty of tkinter tutorials and people that have used tkinter.
aight thanks
tkinter is realyl easy and i suggest it for start
is it just me or is tkinters grid system unusable at times, for example i set it to row 7 and it wont move from row 0 no matter what
i dont really understand
im putting the thing i want with grid so its not empty
oh i think i understand
rows before it?
Is there anything solely in rows 1-7? If there isn't anything in those rows, tkinter won't display those rows
no there isnt
so like i can put empty labels there and it will work as i want it to right
what ultimately are you trying to accomplish?
just want to place a button in a specific place
why in row 7? Do you plan to have stuff before it? Do you just want it further down on the screen?
yeah i do plan to have stuff before it
well, I wouldn't worry about it too much until you put the other stuff there.
oh so when i put stuff before it itll fix itself?
mhm
havent tried that, thank you
is there a way to set the global color of links in qt? Modifying the app's palette or the stylesheet on my rich text browser doesn't affect it; using the style attribute on the a tag works but is the most tedious way of doing it and introduces a lot of clutter
what can i do in this situation?https://prnt.sc/ucbbc1
How do i make the text in qtextbrowser widget centered?
is there anyone who can help me out with my code :(?
can you actually post what problem you have and your code so you don't waste time and get faster help?
๐
sorry ๐ฆ i have written my problem in help titanium please go on that , ive also added my code
Is there any button ID/ name that could be named in tkinter?
in pyqt how do you set the width or height only of a widget, not both at once?
What do you mean by both? Are trying to scale a widget only on one axis or?
please come to help magnesium to help me
i mean not both
change the height of a widget, do not change the width.
change the width of a widget, do not change the height.
@plush stream did you try with Qt.Alignment flags to center it?
@silent citrus it's not really clear what you need help with?
beginner to GUI here. My main loop tend to get long and messy trying to catch all kinds of input and events. I feel there must be some nicer, more elegant way.
For reference, here's what I wrote recently. https://paste.rs/2I7.py
This is just a simple applet with few buttons and input field still the loop is kinda long
what can i do in this situation?https://prnt.sc/ucbbc1
can you actually post what problem you have and your code so you don't waste time and get faster help?
the problem is that i want to put the 'BOTTOM' into the pack(side=), but cant
is BOTTOM defined? i see you imported tkinter as t so maybe you need to do t.BOTTOM
SpiderDave is correct. You imported tkinter as t. So it would have to be t.BOTTOM @silent citrus
@plush stream did you try with Qt.Alignment flags to center it?
@static cove thank you! But i was using the self.song_title.setHtml() function and fill it with html commands, i managed to make it centered :D
Also, does anyone know how to create a new window inside the same class? Problem is I can't declare my variable in my main window class from secondary window class
I hope that make sense :v
anyone know how to deal with checkbox in QT5 to set it True when other checkbox is true?
i tried if self.Checkbox_3.isChecked():
self.Checkbox_13.setChecked(True)
and it gives me error :
^
SyntaxError: invalid syntax
what im doing wrong?
can you show a bit more code from above that?
Hey @placid nebula!
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:
kinda long ganarated code from QT that i cannot paste here
spam filter blocks it
@placid nebula so, it runs first and only once. You probably want to use Pyqt's signal/slot method, so that when you check/uncheck checkBox_3 it'll adjust checkBox_13
ok i moved this 2 lines to class
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
it doesnt give error but does nothing when play with checkbox_3
I#d like to enter in the convoluted code contest if still possible https://paste.pythondiscord.com/lavuhonatu.rb
^^
(I use tkinter) still a student
@placid nebula are you familiar with how pyqt's signals and slots work?
@pure canyon just sharing your code or need help with it?
You can also get help here (and other topical channels), since you might get more specific help for more niche/complex questions
oh thats something new for me sorry
self.connect?
I'm having the strangest issue with PyQt5:
I found a hello world example online that works
This code is at the end to run it:
if __name__ == "__main__":
app = QApplication(sys.argv)
mainWin = HelloWindow()
mainWin.show()
sys.exit( app.exec_() )
However, if I change that code to:```py
if name == "main":
app = QApplication(sys.argv)
HelloWindow().show()
sys.exit( app.exec_() )
the app fails to show up
Is this a garbage collection thing?
You need to keep a reference to the object you create or it gets deleted
I literally realized "oh prolly garbage collection" as I was typing that question up lmao
oop
never realized python's garbage collector is so aggressive
Without assigning, it's only needed until show ends and gets deleted by the time executing gets to the next line
Anything with its refcount at 0 should be collected immediately
Unrelated question, but why don't we need to explicitly pass app to mainWin or vice versa?
how does mainWin know what event loop to attach to?
or does PyQt5 only allow you to have one event loop?
@rocky dragon
They're bound to threads I believe
@placid nebula are you familiar with how pyqt's signals and slots work?
@static cove thanks, it helped
btw anyone know if in tkinter is possibility to add timeedit widget like in QT?
You would have to try to build that functionality yourself in tkinter unfortunately
thats crap, wonder why they not extend functionality of tkinter
im trying to build same desktop app like i did in qt
but looking at tkinter it has its own limits
tkinter is in the standard library so it's tied to the python release schedule, but I also don't think it's received any sort of update in a long while. It makes it stable, but tkinter does have fairly limited functionality compared to other frameworks
im beginner at python but looking on structure i like more tkinter's than qts
maybe because qt code generated from designer looks so messy
in your opinion i should stick to the tkinter or work on qt?
You don't have to use designer, you can code it yourself. But with Qt styling it can certainly add some line lengths. Same with tkinter though. I have a preference for pyqt/pyside2, but it depends on your ultimate goal. If it's just learning then tkinter isn't bad.
well im on the beginning and would like to know most used frameworks that may help to get job in a year...
The main loop is a bit different since it's bound to the gui thread, but otherwise you can have events loops for every QThread you make
Well, honestly for getting a job, desktop apps (especially in python) are a bit niche. Web apps and web development is far more common.
django right?
would You be so kind to let me know few frameworks that i could study hard for next year?
django is a backend that is commonly used, yeah.
You might find better advice for that in #career-advice. I don't think I'm the right person to give you that info
I'm getting to rewriting the gui of my older project. For example here https://github.com/Numerlor/Auto_Neutron/blob/dev/auto_neutron/popups.py#L340, what would be the usual way of separating the logic from the UI code? Just subclass the UI code and implement logic on top of it?
How should I split up a PyQt5 app into python modules?
I'm thinking:
__main__.py:```py
import sys
from gui import App
if name == "main":
sys.exit(App(sys.argv).exec())```
gui.py: ```py
imports
class MainWindow(QMainWindow):
def init(self):
QMainWindow.init(self)
# UI code
class App(QApplication):
def init(self, argv):
QApplication.init(self, argv)
self.window = MainWindow()
self.window.show()
Should I split gui into multiple python files in a gui module, one for each component?
is there something else I should change?
Generally, I like to keep different windows/widget implementation in separate modules. An exception is when they're short and closely related to each other.
@shy nova
Having the app next to the main window is fine I suppose, since they are indeed related and the app seems to not have much code. In fact, you don't really need to subclass the app. It could just be implemented as a function to create an app, create a main window, and show the window.
put as many bells and whistles in your subclass as you can to make things easier; there's a lot of dumb stuff and things that could be greatly improved
btw a good way to think of it is keep all of this stuff out of your main https://i.imgur.com/0KhjZJB.png
right you can make it less clear and smaller, but it's still gonna be a bunch of ugly imports in your main
@trim ibex what kind of "dumb stuff"?
Hello, I wanted to create a WebApp using Python CGI, using which i can open a graphical applications inside the browser itself by just writing the application name. Can someone help me in that.
@rancid tusk so you want to create a launcher in a browser? Difficult but doable. Likely not connected to CGI unless you're not explaining something though.
on windows, you can js window.location = "calculator://" and it will either offer to launch calculator or open it anyway depending on the browser
with linux, I believe you need a mime type instead of a url scheme, but idrk
and I have zero clue about macos
@shy nova i am explaining my use case a bit .
I have a linux system where my webserver is working, and in that i have created my webApp usignPython cgi.
I have a created the webApp in such a way so that if i enter any linux command like date, cal it shows the output in the browser. Similarly if i give gedit, or firefox command it should open the specific application in the browser itself as if a client is using the webapp and wants Firefox to be opened.
I have a created the webApp in such a way so that if i enter any linux command like date, cal it shows the output in the browser
Ok, this makes sense. I remember doing something similar 5 years ago in JSP back in middle school ๐
Similarly if i give gedit, or firefox command it should open the specific application in the browser itself as if a client is using the webapp and wants Firefox to be opened.
Explain this a bit better
so let's call the two machines Server and Desktop for now
When you type gedit, do you want the gedit window to show up on Server or Desktop's gui? @rancid tusk
if the former, set the environment variable DISPLAY to :0 (or some other digit if you run your x11 server on a nonstandard display number)
if the latter, you'll want to set up ssh forwarding or NoVNC
To me, it sounds like they want the requested application to run on the server but render and be interactable through the client's browser.
If that's correct, I don't think that's impossible, but I'm not sure how to accomplish that.
In any case, it doesn't sound very secure if clients can execute arbitrary apps on the server.
i need help making my GUI look nicer , please go on the link and change the code as much as u want , you can change the color font and everything have a go ๐ https://paste.pythondiscord.com/gabuwodagu.http
Anyone help me plz (Tkinter problems)?
https://discordapp.com/channels/267624335836053506/696353510488539206/752514350706589837
Anyone used pybullet?
anyone know how to write a function that can clear frames in tkinter?
i think a good way to do it is to subclass all your widgets and add functionality where the containers keep track of what's placed on them, and make a method to remove it where it automatically gets rid of the child widgets
so like when you add a widget to a frame you'd use a method on the frame itself, and another to remove the frame (or just clear it if you want it blank)
Anyone using tkinter
the canvas is too slow so i'm redoing my project with pyqt5. it's pretty slick. seems a lot more stable then when i used it long ago
this is what the tkinter version looks like https://i.imgur.com/uIpXybn.png
thats still nice tkinter.
mine was horrible, literally belongs in 2001
has anybody used pyimgui?
tkinter is a trashheap but I love it
hello, i want to create a small transparent overlay
transparent overlay ???
So im using PyGame for a 2d Game Engine, and Im trying to make a UI where I have a scene view/game view in the center with my actual pygame game there and then around it my buttons, and other UI. Ive tried using a package called pygame_gui but my results were quite bad due to the low FPS
If you would like to see the code, here are the two files
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.
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 dont know if i can help yopu because of my limited amount of knowledge in pygame but great work
GRYAN styled visual studio code
BLURPLE styled visual studio code
so how these seem like !! 
where do i get pyqt5 designer?
do i need to isntall it via cmd or via installer
nvm found it
anyone recomends easy to use gui lib?
not tkinter as i know it already
I remember the author used to talk about PySimpleGUI here
You could check that out
It is basically a wrapper for many different GUI libraries with the goal of making the API easier to use
I've not used it myself, but it sounds like it's designed to be easier
imma check out tht PySimpleGui and kviy
I've not used it myself, but it sounds like it's designed to be easier
I quickly ran into some issues with it, although I was pretty much starting python then it's probably not that suited for more complex apps
with PSG or kivy @rocky dragon ?
pysimplegui, kivy is neat but I haven't used it much as it needs a lot of work for a normal desktop app that qt offers out of the box
i dont like qt as with designer (which ngl helps a lot) it creates some classes etc , i dont work with classes yet i do one
and i dont understand the code in generates
which isnt what i need
Any real GUI will most probably go with classes, so I'd recommend getting familiar with them if you're planning anything more serious
im not planning ,i just want to learn some more
so, for a very new person, whats the easiest way to make a gui with buttons that trigger functions?
something like this:
and then it passes the text to a string
and the buttons pass specific text to a string
is pyqt free for non-commercial use? Qt licenses scare me
Without open sourcing my stuff that is
PyQt is licensed under the GPL so you need a GPL compatible license to avoid paying for a commercial license.
I believe any license that doesn't open source the code is incompatible with GPL
PySide2 is licensed under LGPL I believe, which is more lenient. I don't know the specifics unfortunately.
I believe LGPL should be fine with almost everything as long as you don't change any source of pyside itself
Without open sourcing my stuff that is
@willow garnet No
Did someone try PySimpleGUI. if yes, how is it?
so, for a very new person, whats the easiest way to make a gui with buttons that trigger functions?
@digital rose i would say tkinter
ok
Does anyone know QT QSS well?
I'm trying to make a background image but it's not showing
background-image: url(C:/Users/PC/Downloads/image.jpg);
#help-broccoli I described my situation in depth here with code snippets, screenshots, etc
if anybody can help that would be very much appreciated
Is this the appropriate place to discuss CLIs?
I created a gui that changes jpeg to png
How do i put a test that if no file is selected,it disables the convert button and print a message that file is not selected?
In tkinter
So uh, it might sounds stupid, but pyqt5 supports css right? Is there any way to use css in pyqt5 to achieve frosted glass effect?
The style sheets are Qt's own CSS inspired thing, you'll have to look at the docs to see if it supports the things you need
Ah, i see. So there's no way at all to have frosted glass effect?
I'm just stunned at this ui modification and i just wonder if it possible to do that in qt
I don't think qss has something for it, but you'd have to check yourself to be sure. It sounds like something Qt Quick would have but using that includes a completely different way of structuring an app
I've heard someone has done it with QtWidgets.QGraphicsBlurEffect() but i'm not sure if that'll work because i didn't bring my laptop with me rn
How do i blur the window instead of the widgets?
i just need some basic help with tkinter
can someone help me with this im making a pyqt UI to download youtube videos with pytube3. I have gotten everything working but the download percent bar goes from %100 to %0 instead of %0 to %100
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 am trying to use Kivy with Pycharm but I can't get a preview of my app no matter what I do. I have kivy and the dependencies installed but all I get is console output. No image or label. Am I missing a simple fix?
Doggo I didn't run it but try flipping around the parameters in python p = self.percent(bytes_remaining, size)
in pyqt5 i have a button that creates a new tab. it doesn't appear until i move the mouse. what exactly should i do to make sure it's visible right away?
ah nevermind i found it, a window.repaint() did the trick



