#user-interfaces
1 messages · Page 51 of 1
Yes there are. Just ask your question.
So I have a Text Editor I am creating, and I simply just need to get the character count inside the text editor. Same thing as Word. As I type a counter adds or subtracts to a number. I just don't really know how to implement it
With a QTextEdit widget
It very likely has some attribute or function you can use to get the contents of it
Can you be more specific on what you have trouble implementing then?
wordCount = len(self.toPlainText().split(" "))
Is it updating the counter that is problematic?
Do you already have a label for the counter?
def getWordCount(self):
wordCount = len(self.toPlainText().split(" "))
print(wordCount)
this is the exact def I am using
There's a textChanged signal for which you can hook up a slot. And in the slot you can edit the label's text with the newly calculated word count
Where do you see that?
I have been looking for something like that for so long. Also when printing wordcount I get a 1
in the console and that is it.
Are you familiar with the event system in Qt?
Events you can subscribe to are called signals. And you implement slot functions which are like event handlers. In other words, slots are the functions that get called when a signal (event) is triggered.
does it return a boolean?
So if you know you're looking for some kind of event, you'd want to check the "signals" section of the documentation
oh voids
And there you can see textChanged. That was my methodology for finding that
This is the C++ documentation by the way. void is None in Python.
I just use these docs because they're more readable and complete than the Python ones
You define a function you want to act as the "event handler" for it. This function will be considered a "slot"
Then you need to hook up the slot to the signal, and qt will take care of the rest
Okay can I use my old function as the "slot"
For example my_text_edit_widget.textChanged.connect(self.my_text_changed_slot)
A reasonable spot to make that connection would be in the __init__ of your parent widget/main window
Okay I will give that a shot. Thanks a lot. Still a bit confused but I'll get there eventually.
It is simply just getting used to how Python works
@sudden coral So would my_text_edit_widget be QTextEdit
ignore that blue mark
You need to hook up the slot outside the subclass
So in whatever is using your textbox
My Document class, that is exactly where we use the TextBox class
You're misusing inheritance
There's no need to subclass the text box here
Instantiate the object and store it in your class
Are you talking about Document(TextBox)
Yes
Well then how would I go about using TextBox
Goodness I am a mess
does super(TextBox, self).__init__() suffice?
Do you have a main window widget?
I guess that would be our main
I imagined it something like this
self.central_widget = QtWidgets.QWidget(self)
self.layout = QtWidgets.QGridLayout(self.central_widget)
self.text_box = TextBox(self.central_widget)
self.layout.addWidget(self.text_box)
If you want to have keep the Document class separate, then that's fine, but it should subclass QWidget and have its own layout. Then you can add the text box and the counter label to that layout.
And the main window can be reserved for "top-level" stuff like a status bar, the file menu, etc.
It's more a matter of design. Either way works.
okay, im a little bit confused but thanks for your help ill try some things out
I'm playing with the idea of figuring out how to diy an additional input device for my PC. One idea is to buy some cheap tablet and write a simple app that would allow me to send keyboard/mouse inputs via USB. That said, my inexperience far exceeds my ambition atm.
After some brief googling, I think I just need to learn and use one of a couple libraries I found, for the tablet GUI side of it. It's the rest I'm clueless on. Anyone have any insight or guidance on how to go about this?
That sounds like something that should have a (better) app available already, unless you want to write it for practice
nah, not quite that level of masochist. and kinda? i found a couple janky looking ones that connect via wifi, and that seem to limit you a bit
Hey guys! I have been writing a code using kivy. Here i am trying to take the input from the user in the "EighthWindow" and trying to get that variable in the "SecondWindow" as a label. My approach was to define UN as a class variable and then update when the username is entered. Then i get the updated value of UN in the second class and plug it in. But UN does not get updated. I am new to kivy and the overall concept of classes and objects as well. Any kind of constructive criticism and help is appreciated. Here are the shortened codes:
Python File
class EighthWindow(Screen):
username= ObjectProperty(None)
password= ObjectProperty(None)
UN=""
def change_var(self):
EighthWindow.UN=self.username.text
print(EighthWindow.UN)
class SecondWindow(Screen):
n=EighthWindow.UN
Name=StringProperty(n)```
Kivy file
```<EighthWindow>:
name:"Eighth"
username:username
password:password
FloatLayout:
TextInput:
id: username
hint_text:"Username"
size_hint:0.6,9/40-0.1
pos_hint:{"top":4/5-0.1,"x":0.2}
multiline:False
Button:
size_hint:0.6,9/40-0.1
pos_hint:{"top":2/5-0.06,"x":0.2}
text:"Login"
on_press:
root.change_var()
app.root.current="second"
<SecondWindow>:
name:"second"
FloatLayout:
Label:
text:root.Name
pos_hint:{"x":0,"y":0.75}
size_hint:0.3,0.25```
Hey, quick question, what's the difference between pyqt and qtquick? And which one fit the best for a desktop app with complex effects such as frosted glass themed window, etc
I need to help with getting a bunch of files (GUI and socket system) working together.
I have 4 files: server.py, client.py, gui.py and main.py.
server.py and client.py are have the code for a console chat system using sockets.
The problem is that the client only receives messages when he submits an input, since input() blocks all the other code from running. Now I'm trying to combine this system with the GUI I created in gui.py. I was told to use multithreading and was provided with the code below, which I put in main.py. (See Image)
gui.py
https://paste.pythondiscord.com/kanuxubeja.rb
server.py
https://paste.pythondiscord.com/igogorohoh.py
client.py
https://paste.pythondiscord.com/yefevinijo.py
main.py
(Image)
Feel free to @ me!
nix: there are programs that let you take multiple mouse/keyboard and set them to do different things. what are you looking to do with an extra input device?
@trim ibex oh. that could actually help. how should i phrase my search for those programs?
my hands suck, so a lot of shortcuts and macros are difficult, and certain mouse actions are difficult to do quickly/accurately. so, the idea was to have quick access mapped buttons and maybe a touch mousepad for certain tasks.
im looking for good guide book or course anything which you recommend about pyqt5
well for difficulty with a mouse, try a nice large trackball. you can get a nice touchpad with big buttons pretty cheap too. there are also bluetooth buttons you can get that people use for quiz programs
i guess if you have a lot of macros you'll need some good cheap way to have a lot of actions but also comfortable
@trim ibex hmm...i might just end up going for a touchpad with mappable buttons if i don't decide on something by black friday. thanks for the response
if you're thinking around black friday there will probably be cheap low power tablets
especially near cyber monday
yep. thats what i'm aiming for. i'm pretty cheap, so 2 months is no problem for a good deal
I have some beginners downloading a package I've developed, and they run into common errors when setting stuff like their Python environment, paths, etc. I've made a list of steps for them to go through if they run into some of these common problems.
Where's a good place to put something like a 'Common Configuration Problems' section containing this information on the README.md of our repository?
Is pyinstaller the best bet for compiling tkinter programs?
@inland notch yes, it works great with my app
it doesn't work well for me
or at all
it just doesn't work
@plush stream you familiar with Errno 22?
Can you screenshot me the error inside the console?
Seligmann you can put it under "installation" or "setup". it's still part of that and it will help bring it front and center.
@inland notch is this also happened before you compiled the script?
No, it happens during the compiling
That's weird, errno 22 is usually connected with directories errors, can you recheck a line of code that tell python to open some file? e.g: File = Open('C:\User\Somefiles')
Oh it might actually be that
if I had another folder in the dist folder, would that mess it up?
I'm not sure
would having a period in a file name do it?
Have you tried to recursive? Like File = open (r'C:\User\Somefiles')
try opening a more simple named file to narrow it down. i see you have a ' in it, maybe that i dunno
Can you send the line of code that supposed to open a file?
Jeez that's long
I couldn't find the dadgum line that open the file
You should really consider adding comments on your codes, jayzus i couldn't find which is which
Also, i doubt that errno 22 caused by defender
If it is blocked by win defender, it should have a different error message
I'm using pycharm, if that helps
Could you tell me on which line is the code that have the Problem? Im having a hard time finding it
It's not the code, it's when I try to compile the program
Okay well, what configuration did you use in pyinstaller? e.g = pyinstaller -noconsole myscript.py
Yeah
the program runs fine but doesn't work when you freeze it using pyinstaller?
hard to say but maybe all your assets aren't being included
Did you leave any folder that contains maybe textures?
Yeah
oh it says Icon.ico not found
that was before, I made a typo
If you have separate texture folder then pyinstaller not gonna include it so you have to copy it manually
Or generally any separate folder
Yeah I know
I take the exe and the assets folder and put them in their own folder, zip em, the put it on gamejolt
for what i did it helped when i put a init.py in my icons folder. pyinstaller could find them then
discord ate the underscores but you know the filename
a blank file, just indicates that it should be looked at
oh and i did import icons
No I don't
I've never use the import icon function in pyinstaller, so after it compiled i'd just have to slap the icon with resource hacker
__init__.py
ok that worked
lemmie see what else i have in code, i dunno if it'll help you or not
at the top:
# All that python imports here is an empty init file.
try: import icons
except: pass
later to load the icon
try:
# the frozen version will still try to load it manually first
ctrl.setIcon(imageFilename)
except:
folder, file = os.path.split(imageFilename)
ctrl.setIcon(BytesIO(pkgutil.get_data(folder, file)))
in the .bat file in pyinstaller's flags
--add-binary "icons\clock32.png;icons" ^
oh nice
It was windows defender
Ah, thank God
rubycon, doing it this way you can change the program's icon without hacking resources
Haha, thanks, it's already a habit, but i might try that one in my next project
I feel so smart
i dont think you need all those 'global' do you? if they're already defined outside a function
not if they're defined outside the function
so like when you started it and only had "score" inside functions it probably didn't work but now it would
i dunno, try it
Try what?
removing some
oh actually i guess if you do a "score=0" in the function it'd make a local version
what i usually do for something like that is make a dict, like cfg = dict(score=0, something=1)
some of this stuff you could trim down though, i think this might work for your audiorefresh function ```python
def audiorefresh():
map(lambda x:x.set_volume(volumeslider.get()), [Jumpsfx, Pewsfx, Hitsfx, Pickupsfx, Megalazersfx, Jumpsfx, Walksfx, EnemyLandsfx, Newwavesfx ])
Game.after(1, audiorefresh)
you could use a regular loop if you think it's not so readable like that
How can I fix error:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
I’m using PyQt5 and I keep finding c++ fixes, but I’m using PyQt.
My code is: https://paste.pythondiscord.com/okekivamib.py
My main file’s code (the above one’s to make stuff easier) is just:
import selflibC as c, which shouldn’t do anything, but regardless, I get that error.
e
:incoming_envelope: :ok_hand: applied mute to @digital rose until 2020-09-11 09:47 (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).
hey guys how to change window background colour in tkinter
@lyric nebula Do you mean of a frame or of the root window?
root
You should be able to do root.configure(bg="blue") or whatever color you'd like.
ok thanks
You can also use hex values, I find that's nicer than the primary colors tkinter provides
Like #856ff8
Not quite. It's just a different way to break down rgb (iirc) that's a bit more used in the design space
ok
We won't provide help with things such as a Youtube Video Downloader, that would be against the rules.
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.
There might be a module that allows you to create custom Windows notifications, otherwise, you could create one yourself using a borderless windows.
a youtube downloader doesn't break any laws or terms of service
you're allowed to download youtube videos if you get express permission from youtube or the content owner
dont try and do legal work for them
programs like that dont break laws, PEOPLE DO
you're fighting for opressive copyright laws if you slap down every piece of software, it isn't python discord's job to be the police
not to mention people are here for learning; if they just wanted to steal content they could use the thousands of tools out there to do it
But people in this server do have to abide by the rules of this server, which includes not breaking other site's TOS. A youtube downloader (without the express permission youtube, which good luck obtaining) is against youtube's ToS.
Therefore, we don't help with that here.
!ytdl
Per PyDis' Rule 5, we are unable to assist with questions related to youtube-dl, commonly used by Discord bots to stream audio, as its use violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2019-07-22:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
where's the clause where it says people aren't allowed to create python programs
using any automated means a python program would fall under automated
so you're ignoring the exceptions
and you jsut want to declare all video downloaders illegal cause you're gonna be a good copyright cop
... no? I'm saying that on this server we can't help with anything that would break youtube's ToS. Which downloading youtube videos does.
Violating ToS != illegal
you're talking in circles
it does not break tos
the user may or may not break the tos, depending on how he uses it
it's like saying ban all skateboards because they're illegal to ride in the street
what? you make skateboards? go to jail!
people like you who blindly rules-lawyer everything are the reason everything is such a mess
Hi, we have it pretty explicitly in our rules that we won't help with any ToS-breaking code.
If you want to use YouTube in a programmatic way, you can use their API and we'll be glad to assist you with it, otherwise that's not something that we'll provide help with.
That's a meaningless statement. You'll breaking that ToS by running that code
he's allowed to legally and ethically and without breaking tos to create a video downloader, or to ask for help on one
look if you dont want it on the server fine, but there's zero wrong with it
I beg to differ, but either way I am telling you that we don't want it on the server.
they gonna sue you for downloading this? https://www.youtube.com/watch?v=PiuTMnSVRwA
i beg to differ
there isn't anything wrong with it
how about taking out your phone and recording it?
Let's cut to the chase - please don't ask about automated means to use YT if it doesn't use their API.
I won't continue this argument
ok, then dont say 'i beg to differ' about there not being anything wrong with it
if you dont want to continue dont add in the tanget that i objected to that isn't relevant to what you do here
Are you done?
this is what i said: look if you dont want it on the server fine, but there's zero wrong with it
and you continued, so yeah i'm just makign sure we're clear that you dragged it out
so yeah now i'm done
are you?
Sure, now let's move on
@lyric nebula are you looking for something like the windows "toast" notifications?
Someone in this channel like... maybe 3 months ago? made a pretty neat application with windows toast notifications
I wonder if I can find it again
do you remember something specific said? might be able to search and find the old conversation
hey, so this is super trivial but im trying to get AppJar to have a right click open a menu, and i think ive got everything figured out except giving a button a seperate function to a left click. How do I bind a function to the rightclick specifically (app.bindKey("<Button-2... returns Button-2 is already bound. Thanks in advance and pls ping me i gtg go eat now 🙂
i haven't used appjar but it looks like it's a wrapper around tkinter. took me a while to figure out that in tkinter when you do a .bind() you can add a parameter add="+" to add another binding. maybe appjar has something similar
looks like you can use tkinter's bind directly with appjar
any1 know any colored terminal text packages that work on all versions of windows so like7,8,10 and mac besides colorama
how is appjar, looks neat
i like the design philosophy of making things simple on the surface and powerful under the hood
its not as manipulative as tkinter in terms of precision, but in terms of easy to use i'd compare it to html tbh, its pretty much 'make a button, put it here, make it do this', so still kinda complex but much nicer than tkinter, especially for grids
could do with some nicer documentation imo, but then again its made for pretty GUIs and i dont use it for pretty GUIs XD
how can I make a lineEdit in pyqt5 trigger an action without pressing a button
what do you want to trigger it? hovering over with the mouse, typing with a key?
@trim ibex like paste a link and it shows me information about it
so when you paste a link to the lineedit you want it to trigger an event?
yes
hmm maybe there's an event handler thing for when the content changes
there probably is
try mylineedit.textChanged.connect(somefunction)
np, looks like there's a textEdited too, which doesn't fire from programmatic changes like using setText()
seems like a useful widget, i never used it. i might use that for an input-style calculator
yea
Hey I'm trying to catch an event in PySide2 when you click away from an open QComboBox popup and it closes. I've tried .closePopup(), but no luck.
The focus Out event is what you want
i want to trigger an action when a specific thing in the combobox is selected
pyqt5
IndexChanged
how do i define the specific thing?
the item
i want each item to trigger a unique event
yea but what do i do for the others?
other items
like something should change for python to know which item it is
ok thanks
then if idx == 2:
you don't need to create other functions
do another thing
idx being self right?
or, you could use textChanged and in self.fn change idx to text and ask if text == "this"
no, it needs self and idx or text
the signal emits the text or current index of the box
okay i'll test it
@ruby pawn you may want to set your box to have the focusPolicy of Qt.ClickFocus if you don't want the function to trigger if a user tabs to focus the box
rather tabs away
let me see the code
Process finished with exit code 1073741845
I'll give it a shot Chris_
its alot
just what you've changed since it wasnt crashing
k
self.comboBox.clear()
self.comboBox.addItem("both mp4 256x144")
self.ComboBox.indexChanged.connect(self.quality144)
video_link = self.lineEdit.text()
try:
v = pafy.new(video_link)
print(v.title)
print(v.duration)
print(v.thumb)
st = v.allstreams
print(st)
for s in st :
filesize = humanize.naturalsize(s.get_filesize())
data = "{} {} {} {}".format(s.mediatype, s.extension, s.quality, filesize)
self.comboBox.addItem(data)
except Exception:
pass
def quality144(idx):
if idx == 1:
QMessageBox.information(idx, "144", "Tas sadloading")```
top bit and bottom bit
ok
What argument does focusOutEvent() take?
just call it event
crashed
Expected type 'QWidget', got 'str' instead
@ruby pawn focusOutEvent(self,event) should work
I'm very new to this, is event an event object?
Unresolved reference 'title'
its a QFocusEvent
idk how you are managing to help two people at the same time lol
well, your title was str(idx), so use that
I'm so lost 😂
get rid of =None
🙏
👍
class ComboBox(QComboBox):
def __init__(self,parent=None):
super(ComboBox, self).__init__(parent)
def focusOutEvent(self, e: QtGui.QFocusEvent) -> None:
# you don't need to emit anything here
return super(ComboBox, self).focusOutEvent(e)
does this work?
you shouldn't be triggering a focusOut unless you've lost focus somehow
what does showPopup actually do when it emits?
I can't .connect to the function now
I have no idea, I was trying to follow some dude on stack overflow
I think it loses focus on the QComboBox because focus goes to the QComboBox QAbstractItemView
But I want it to activate when the QComboBox QAbstractItemView window closes
But the closePopup or hidePopup has not been working for me
hang on let me try this
sorry, I was afk for a few minutes but I have no idea whats grabbing the focus away
Alright, guess it'll forever stay a mystery then
even when you set specific focus policies it messes up
Thank you for trying man
Nah, I've gotta go play with my kid but I'm officially curious now
I'll send you a message if I figure it out
If you have child widgets, a child widget may have the focus and be consuming the focus out event.
Make sure only the "main" widget you want has a focus policy, and the children have no focus policy
Instantiate the window object (QWidget or some subclass of it) and then use the my_window_instance.show() function
Uh wot? Sorry i'm still new in pyqt, i 've just started learning 2 days ago, could you tell me how to do that?
I could send my code if that'll help
I found a tutorial that should help. https://www.learnpyqt.com/courses/adanced-ui-features/creating-multiple-windows/
It's likely more clearly explained than me trying to do it over Discord chat
Oh golly, it works! Thanks!
But i can't seems to "connect" the main window class with the second window class
In what sense?
You see i use my second window to modify the variables inside the main window
Inverse the relationship
Store the new value in the second window, and have the main window read that value
This makes more sense because the main window is the once that has a reference to its child already, so it's much simpler
Ahh, okay i'll try that, thanks!
If it's something time sensitive, then you will want to use Qt's event system
And they have a tutorial on that here https://www.learnpyqt.com/courses/adanced-ui-features/transmitting-extra-data-qt-signals/
Thank you
Ah dang, it's still didn't work
I couldn't access the variable
from PyQt5.QtWinExtras import QtWin
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget
import sys
# secondary window class
class Secondary_Window(QWidget):
def __init__(self):
super(Secondary_Window, self).__init__()
self.initSecondUI()
def initSecondUI(self):
self.dial = QtWidgets.QDial(self) # this is the dial i want to access in the main window
# main window class
class Main_window(QMainWindow):
def __init__(self):
super(Main_window, self).__init__()
self.setGeometry(250, 100, 500, 500)
self.initUI()
def initUI(self):
self.btn = QtWidgets.QPushButton(self)
self.btn.setText("Open New Window")
self.btn.clicked.connect(self.open_new_window)
self.lbl = QtWidgets.QLabel(self)
self.lbl.setText(str(self.dial.value())) # i'm trying to access the dial value in secondary window
def open_new_window(self):
self.second_win = Secondary_Window()
self.second_win.show()
def window():
app = QApplication(sys.argv)
win = Main_window()
win.show()
sys.exit(app.exec_())
window()
I'm trying to get the value of the dial in secondary window to the main window
You can't set the text to the dial's value before its parent window even exists.
Keep in mind that the dial has a signal you can use
Okay, so i have to set the parent window to main_window?
No.
Let me rephrase that in a more generic way
You cannot access the attribute of an object that has not yet been created.
First, dial is an attribute of self.second_win, not of self. Second, self.second_win is only created once open_new_window is called. Hence the problem you have.
Aah, balls, so i have to create an attribute of dial in main window class then?
That is one way to solve it, but not very good since you're cluttering your main class with widgets that don't actually belong to it.
With some more info now, I see that using the dial's valueChanged signal is the best approach
Well, not necessarily the best, but it's good. There's another approach that's good but it depends on what you want
Example ```py
def open_new_window(self):
self.second_win = Secondary_Window()
self.second_win.dial.valueChanged.connect(self.set_label_value)
self.second_win.show()
def set_label_value(self, value):
self.lbl.setText(str(value))
Alternatively, you can move the following lines to __init__ instead, which will have the effect of preserving the second windows state rather than creating a new one every time
def __init__(self):
# other stuff ...
self.second_win = Secondary_Window()
self.second_win.dial.valueChanged.connect(self.set_label_value)
Oh my goodness, it makes so much sense now, i legit confused out of my head like a dumbass for full 5 minutes
That has helped me a lot
Thanks once again Mark! It's working :D
You're welcome
could You guys recommend some kind of courses (free), books anything worthy about pyqt5 except official documentation that i could learn about each object and options?
I would recommend this for a starting point
https://www.youtube.com/playlist?list=PLzMcBGfZo4-lB8MZfHPLTEHO9zJDDLpYj
Is tkinter a great starting point if I want to develop some very basic applications with good gui?
If you're new to gui programming, yes imo, i started with tkinter for about 6 month and then soowly switching to more complex ui e.g: pyqt
tkinter is easy but its not made to look nice , it will look like old programs
Unless if you use the themed tkinter/ttk
well i want to make it look modern... tkinter has old gui styling... and has limited objects.
the link that You paste above is kinda chaotic... its about qt but truly someone who wants to use qt wont get much from that.
codemy's channel has tutorial about tkinter and its great because he shows each object and possibilities that can be used for.
i would really like to find something similar about pyqt5, but what i found is low quality..
@placid nebula i know what you mean, i wish John Elder from codemy made a pyqt series, but this one is i think the best that i could find :)
is good
teaches u about the main stuff
and u can research on your own and expland
You still could search for the individual widgets from learnpyqt.com though
Yeah, like ThunderX said
np
wonder why its not positioning when you put pyqt5 in first page, its not even on 5 first pages
@orchid yoke it depends, if youre looking for control over each element individually then yes, but if you want to be a bit more lax and get something that looks nice but with a little less control use appjar
its basically tkinter but the frontend is nice
if I have a QcomboBox that has three items in it how do I assign each item with an action
Hi, I had a question. Would one recommend building an IOS app in python using a library like Kivy(mb), i am unsure whether i want to go into that without knowing whether i’d get decent results. My goal is to make visual pleasing interfaces, you may Ping me.
hi, i needed a help with the formation of a program, i got this idea, well due to exams/test where a program takes(one paste all the questions from google docs) and it automatically finds and gives us answers (links related to the questions), is it possible?
@frosty mango check beautifulsoup4 out
this might be it
check this out too https://www.geeksforgeeks.org/performing-google-search-using-python-code/
Any great arguments for PyQt over PySide2?
They're mostly the same. The big difference is licensing.
Hello there guys, Is it a bad practice in Tkinter to not to assign widgets to variables, if not needed? 
Pls ping me if anybody have some suggestion 
depends , sometimes it doesnt change to much but when u need to for example .config soemthing it will be much easier with variable or maybe impossible without var
so i suggest using it anyways
Thanks, without assigning them I often feel messy, anyways Im gonna use it 
how do I connect each item in a QcomboBox to an action in pyqt5
can someone recommend a good framework/module for creating a page where one can select between two gamemodes
as i need it for the startup page for my game
i prefer a much easier to learn framework compared to a heavy one
@static cove What are the licensing differences?
@frosty mango check beautifulsoup4 out
@frozen schooner how can i enable it to take multiple values , that is multiple questions and provide link for each one
one min i'll have to try it out
i got the way to take values from user, but only one liners are possible, one question in other words
posible for the program to suspect full stop as the end of one query
?
from googlesearch import search
except ImportError:
print("No module named 'google' found")
# to search
query1 = "Geeksforgeeks"
query2 = "youtube"
for j in search(query1, tld="co.in", num=10, stop=10, pause=2):
print(j)
for j in search(query2, tld="co.in", num=10, stop=10, pause=2):
print(j)```
@frosty mango
add more query as the other search
you can let it print something that can separate the searches from each other like a line of underscores
there is a 2-3 second delay for me between each query
wait i will show u
if you want to get the questions from the google docs
check this https://docs.python-guide.org/scenarios/scrape/
i am not able to separate the questions and find links for each one
i made a script that fetches the question from google docs and searches for it
can you provide it?
yea 100%
oh tanks
should i dm
Okay so when the program is ran, GUI 1 (the main window) is opened
when everyone is done with that window, GUI 1 will open GUI 2 and destroy itself, making GUI 2 the only window open
that works perfectly fine until when it's time for GUI 2 to open GUI 3
When GUI 2 is done with everything, it should open GUI 3 and close itself, just like GUI 1
but it doesn't work, it just doesn't do anything
the code is the same
This is where GUI 1 opens GUI 2 and destroys itself
self.window = QtWidgets.QMainWindow()
self.ui = UiMw()
self.ui.setupUi(self.window)
self.window.show() # OPENS GUI 2
MainWindow.close() # CLOSES GUI 1```
this is where GUI 2 opens GUI 3 and tries to destroy itself
from JSuite_Bank import Ui_MainWindow as Ui_MainWindow2
self.window = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow2()
self.ui.setupUi(self.window)
self.window.show()
MainWindow_2.close()```
The problem is that the code looks identical so I think it should work
but what happens instead is that GUI 1 opens GUI 2 and closes itself perfectly fine but GUI 2 doesn't close after opening GUI 3
the code is the same so I'm stuck
What error does it show?
No error mb
it just doesn't do what the code says
the first time, it works, the second, it acts as if the code wasn't there
so it does nothing
GUI 3 opens and GUI 2 remains alive
have you tried overriding the close event to force accept the event?
if that doesn't work maybe you could try destroy instead of close
can someone recommend a good framework/module for creating a page where one can select between two gamemodes
as i need it for the startup page for my game
i prefer a much easier to learn framework compared to a heavy one
you might try https://github.com/hoffstadt/DearPyGui
in kivy, how can I animate the thickness of a line inside a boxlayout which is inside another boxlayout?
How do I make a fixed position for the buttons so it doesn't follow the large buttons?
Like this
When the text inside the buttons goes more than 4 characters it messes up the grid
What is your favorite choice for a GUI framework, wxPython, PyQt or Tkinter? I need to make a choice and a good advice from people who know more than me would be great
i personally use PyQt and as of now its my favourite choice for gui with python. It is also not hard that hard to learn and has a wide community so if you have any questions you can just research and get your answer
use kivy for simple programs or mobile apps if u want but PyQt is better for more powerful and heavy applications as it is designed to be more than just a gui toolkit and is able to build entire applications.
I’m using PyQt5, and I’m building a program as a practice so I can learn how it works. The program just has some buttons which pop up a message box, which shows an example of a Hello World program dependent on the button pressed.
After I run my file, the label goes to the left side, instead of the top, and my goal’s to get it to the top, in this structure:
LABEL
BUTTONS```
I tried using `setAlignment` on the layout, and the label, and both at the same time but it didn’t work.
Code: https://hasteb.in/oxabifet.py
Can I ask something guys?
Ofc.
Someone know if Pyglet do support "minimize to systemtray" function? I'm writting an app that needs it, I tried Tkinter but I appearently don't now I'm trying Pyglet but I can't find anything on docs about it...
How to convert TKINTER with many IMAGES, to an --onefile EXECUTABLE
/pyinstaller -w --onefile
Use pyinstaller @fiery pier
Make sure the images are in the same directory as the script.
Oh?
hmm have you put the path to directory in the python script?
Good. Still not working?
I didnt try, because I don't know how to add images
Ohh. Just make sure the relative path is in the script. Put the .exe outside same place as your image directory and hit run.
Will it simply work if I convert my script to exe without typing anything except pyinstaller-w--onefile
Lemme try.
Should do. When you're debugging leave out the "-w" so you can see the error code in cmd
Yeah?
Error -failed to execute script main
Actually the issue is, when I keep it in my working directory (where my script is) it runs perfectly. But if I move it , to say desktop, it does not work
Yes
Cause it can't find the images
That's the problem you're having.
use a shortcut to your desktop. To where the script is. Like how Games launchers work. Oin your desktop is a shortcut,. Not the actaul .exe.
But, its my first time. Can you please tell mye how can make it work if I want to circulate it
What can be the process, to make my programm executable in other systems.
Ohhh. 🤔 Well it should just work.
Bascially all they gotta do is keep that .exe in the same place as your images and click on it to run.
Ty ty..
Ty
Np
how to make each item in a QcomboBox do an action
why not use addItem ?
that adds an item but doesn't make it do something
i want an item to do an action
addItem(const QString &text, const QVariant &userData = QVariant())
it can take a QVariant as the userdata
so how can i make it lets say print something
create an action and pass to QVariant.fromValue
set your action triggered to do something
can i have an example?
i have this to make an item
self.comboBox.addItem("item_name")
sorry went afk
did you try it?
Im looking at QComboBox addItem doc string and it doesnt list the QVarient that C++ hhas
so just pass the action in after the text
like pass a func?
or better yet create the action with the text you want and set that as the text
addItem('text',action)
but the action would need more lines
then when the currentIndex is changed connect to something
get the currentData(Qt.UserRole)
it should be the action
What do you mean
action
like the action is wont fit there
its more than one line
self.comboBox.addItem("item_name", print("hello world"))
would that work?
so define it above and pass the variable name in?
yea
well, the docstring* does say Any, so i dont see why a function wouldnt
why don't you just pass the action?
because the action needs alot of lines
like that would merge two files and downloads a file
action = QAction('My super long\
action .....\
.....')
additem(text,action)
I have no idea what you mean
ok one min lemme try
it activates the action when the item is created not when it is selected @eager beacon
i want item1 to print("this is item1")
and item2 to print("this is item2")
do you get me now?
yep
i want the combobox to function like a combobox
bruh
from PyQt5 import QtWidgets
class Combo(QtWidgets.QComboBox):
def __init__(self, parent=None):
super(Combo, self).__init__(parent)
self.a = QAction('Action 1')
self.b = QAction('Action 2')
self.addItem(self.a.text(), self.a)
self.a.triggered.connect(self.handle_a)
self.addItem(self.b.text(), self.b)
self.b.triggered.connect(self.handle_b)
self.currentIndexChanged.connect(self.method)
def handle_a(self):
print('A Triggered')
def handle_b(self):
print('B Triggered')
def method(self, i):
self.currentData(Qt.UserRole).trigger()
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = Combo()
w.show()
sys.exit(app.exec())
it just prints the words without me selecting them
oh now that makes sense
that's not what i had
I figured
works thanks
Can you move half of buttons so It can be where I want it to be?
this is tkinter
something like this
don't mind the weirdly shaped buttons but the position of it
Probably with empty widgets to use as spacers or something, may depend on how theyre managed
I think you should take a look at your physical keyboard
and pay attention to the first column of keys
then do the same with the last column
Anyone here familiar with tkinter and can help me with some basic stuff? Thanks
I've written quite a few terminal based scripts for various tasks, but I'm looking to start incorporating a GUI.
At the moment, the only two languages I'm familiar with are Python and basic ECMAScript. However, since I plan to learn more, I'm looking for a gui framework that I can grow with and eventually scale to much larger projects (Like Django).
I think that makes sense... Any recommendations?
PyQt/Pyside, both are pretty much the same and have a lot of gotchas with a somewhat steep learning curve but they also have the largest number of tutorials and stackoverflow questions available out of all the options.
Looks like what I'm looking for, and I think I found a good book on it too. Thanks Chris!
Hey everyone, not sure if I can ask here in this channel. So I've been looking on how bpytop developed, I'm trying to figure out what library it has been using to create the TUI, I thought it used curses but its not. Anyone have any ideas how it build? Seems like it build from scratch
Yes, it's from scratch
im using tkinter for my project and connecting it to mysql database..but what is this error?
is this the best place to ask about pyinstaller or would a help thread be better
maybe #tools-and-devops @maiden dragon
hi! is there a way to convert 1s1m1h into a datetime delta?
if not right place pls tell where 😄
Could someone help me with the QtWin.enableBlurBehindWindow() function to achieve something like this?
ooh that looks awesome
Yeah that's what im trying to achieve with pyqt
What is the difference between padx and pady to ipadx and ipady in tkinter?
@orchid yoke ipad basically adds wiggle room in the widget that is being packed, which is notable if it's made up of smaller sub-widgets which then have some more room to expand; pad adds the space on the outside (so kindof like ipad on the widget's parent), having the sub-widgets clump together as usual but adding a margin on the outside (left is ipadx=4, right padx=4)
Could someone help me with the
QtWin.enableBlurBehindWindow()function to achieve something like this?
@plush stream i m trying the same for quite some time !!
Did you figured it out?
@plush stream u can make window transparent [by changing alpha ] and then apply blur maybe
it is the only thing we can do in pyqt and even there is no option to do this in tkinter'
@plush stream u can make window transparent [by changing alpha ] and then apply blur maybe
@cursive parcel that's the problem, that last part is the biggest concern, how do i apply blur?
btw there are two methods i found when trying to do the same in tkinter , and methods i found were to use gaussian blur method [check it out , i think its method in numpy module as i remember]
or u can try something like
setGraphicsEffect(QtWidgets.QGraphicsBlurEffect())
that wont work
the thing u r trying to achieve is called "VIBRANCY"
the QgraphicsBlurrEffect is literally there for Qtwidgets
so u cant apply that to a mainwindow
ya ik
thats what the main prob i m facing too
other method was gaussian blur method only i could find out
I couldn't find anything related to Gaussian blur in pyqt
enableBlurBehindWindow()?
doesnt work
?
just try your window name.enableBlurBehindWindow()
and make u sure u set opacity as well
@plush stream try this once what thunder x says , if it works then tell me too xD
Already did that
Didn't work
Do i have to set the opacity with .setWindowOpacity() or something else?
ok lemme try once again , this thing is just insane , i heard that python company was facing somekind of issues with microsoft standards for this vibrancy feature
@plush stream turns out the QtWin.enableBlurBehindWindow()
doesnt even exist
atleast from what i know
its there for C++
only i think
Ok
i cant call it
from PyQT5.QWinExtras.QtWin
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
lol imported all
hey what if we choose bg as white image which is blurred / translucent will it work??
yes that will work
but that wont dynamically change
to the users background
@plush stream that doesnt even exist for me
wheree
https://html.developreference.com/article/27521203/Qt%3A+Erase+background+(Windows+Aero+Glass)
hey pls check this out if it works!
Qt: Erase background (Windows Aero Glass) - pyqt
hey checkout my VS CODE
@bronze basin it's from PyQt5 import QtWinExtras
Then you can call it by
QtWinExtras.QtWin.enableBlurBehindWindow()
@cursive parcel how did you do that?
@plush stream type object 'QtWin' has no attribute 'enableBehindWindow'
nah
it doesnt work
actually there is extensionn called "vibrancy" in VS Code , Hyper Terminal software which provides vibrancy
@plush stream type object 'QtWin' has no attribute 'enableBehindWindow'
@bronze basin enableBlurBehindWindow
Not enableBehindWindow
it says window has no feature likek qtwinextra , maybe bcuz root cant be blurred
If I'm not wrong, the qtwinextras is an exclusive on windows since i think it depends on windows's dwm (desktop windoe manager)
@plush stream yeah it works now but it still doesnt get blurred
That's what im facing rn Thunder
dang :(
if u want to make your thing look blurred
just use a blurred background image
only alternative
ya , but does it work?
just use a QLabel or smth??
It won't dynamically change ain't it?
i thought of this idea though havent tried
nah
i think we should post this vibrancy thing on pyqt discird server
Found this
Idk if it works tho
i use pyqt alot
OK
but there is a school projetc
yeah schools always be like that
forcing you to use bad tools when theres better tools available
not that tkinter is neccesarily bad
its just that pyqt is way way better
now i m having trouble in making page change on clicking those sidebar tabs
its just that pyqt is better
@bronze basin yeah totally
i can help with pyqt
making this ui [above] , i was thinking of making best ui ever made with tkinter
but i aint good with tkinter
hey can u help me convert this to pyqt
i was thinking if i could convert this to pyqt , i could add alot of features
but i m still not that PRO with pyqt so would ya like to help me convert
did u even add any features? or logic?
like i mean have u only designed the ui or
done the logic as well
lol i just made btn functions , but gonna add database , server and many function later on
Oooh, pyqt is waaaaay better that tkinter
but the main prob is i cant convert to pyqt thats where i need help
Oooh, pyqt is waaaaay better that tkinter
@plush stream yep
ok so u didnt add any logic?
for now , NOPE
hmm i see
there r just buttons and basic ui which works
I just rewrote my app on pyqt
cool
ruby con would u help rewrite too
if you use a Qframe for your main window
since its qwidget
you can set the opacity low
and then do the Graphicsblur effect
yeah this will probably work
if this doesnt work
you cant do it
ill try right now
thnx
this is the project i did with pyqt ,
its server based
and in left side there is a canvas where we can draw
more like skribble.io
lmao didnt even show anything
@bronze basin that's a bad sign isn't it, ohno
hmm i might show a project i did later
hey anyone there!!
Ah, crap
thought i pulled off a move and a half lmaoo
Well atleast you tried haha
yes
hey guyz i made this with CSS, electron JavaScript;
so is there any way to create the same using PyQt5 HELP
yes
this is same program
having window buttons in above frame and main program interface in below frame
I think pyqt has a scripting language that are very similar to css, it's called qss if i'm not wrong
But it definitely didn't have all the features that css had
yes
@cursive parcel make a qframe in that place where u want the empty gap
either set the stylesheet r,g,b,a=0
or use the QGraphicsOpacityEffect for the Qframe
perhaps if u make a QFrame and use Qss for the borders and remove the window border generated by window
basically make your QFrame your mainwindow
like Main QFrame
Okay
@cursive parcel sweet designs
i like flat ui desighn
design*
its simple and cool
@proven oxide thnx man , i like to play alot with ui structures
perhaps if u make a QFrame and use Qss for the borders and remove the window border generated by window
@bronze basin
ya border rounding is super simple in qt
@cursive parcel make a qframe in that place where u want the empty gap
@bronze basin okey thnx
thnx to @plush stream too
can anyone tell me what is the best gui out there ik tkinter but thats not the best so can anyone telll me which one is the best according to u guys
@sand warren
hey
hey
but im not a gui guy
ohk
so.. when you want to make an interface you are left with some options
from great to excellent
so one is kivy
its a great gui framework
its user friendly
easy to learn. but it takes a lot of time
now qt5 is excellent
but
its hard to learn and takes a long time to learn
so its all about what you feel like doing
do you want to invest all the time to learn QT5
hmm ok well i dont need guis for large projects
or start with something like kivy
woah! ok
but i make my interfaces using web tech
wut?? i don't get it!?
so. lets look at how discord does it
hmm ok
it looks like an application for your desktop right
buts its actually made using web-tech
so it runs in a browser
are you on a desktop using discord now?
yeah
press F12
nothing happens
hmm.. well.. maybe its more you have to enable
so it would open the dev tools like it does in chrome
yeah the inspect one ig
hes basically using js,css and html to create interfaces @west briar
like with react
or something
yes, i agree.
ohk interesting
react would be part of using web-tech
react. vue.
ermm... something more maybe
there are many ways
now, i would recommend you to look into kivy as well
its a great library for gui development
well wait do i need to learn js,html,css for web-tech??
now, i would recommend you to look into kivy as well
@sand warren i'll definetly learn ti
it*
yes. the web is made out of js, html and css
you can make pretty apps with kivy and kivymd https://kivymd.readthedocs.io/en/latest/
but there are many many other ways of making an interface for the user
hmm yeah
this is just my two cents on the matter
well prnslly why i loved qt was coz of the designer like it makes the guis so more interactive and easy to use
ohk 😅
ill have to walk my dog now.
ohk go ahead
just find me later if you want to talk more
have a nice one 😄 nice talking to you again 😄
can anyone tell me what is the best gui out there ik tkinter but thats not the best so can anyone telll me which one is the best according to u guys
@west briar
depends on what u wanna make , but u can use pyqt
nah i'm talking about the daily uses
like making some small applications
i am fed up of using tkinter
so wanted to learn something new
bro see , many people say tkinter is bad and lot of stuff , but i will disagree , tkinter is awesome and can make insane apps , though pyqt5 is best
w8
see this , this is TKINTER
what u can expect
ohh
nice
well i'll see into it
but its really late here in india so gotta sleep now
ttyl in dms ig 😅
also if u wanna learn new go for pyqt , else other are bad if u ask me , coz they take too much code and give less result
me too indian lol
kk
aint even that late tho
see this , this is TKINTER
@cursive parcel BRUH IS THIS SRSLY TKINTER?!
is it made with ttk or pure tkinter?
I recently used a program that used the eel library.
https://github.com/samuelhwilliams/Eel
This program uses eel and the screenshots are very nice.
https://pypi.org/project/auto-py-to-exe/
It creates a offline web-based interface, designed using html/css and JS to interact with the backend. Since its css, you can use bootstrap and other themes. If you know some web dev it's basically a micro web dev framework. Haven't actually used it myself, but it looks like it'd be great for small programs.
I've used toga before and I like it
Trying to implement Qlabel in PyQt5 but I am getting error:
cannot import name 'Qlabel' from 'PyQt5.QtWidgets'
Anyone know why?
from PyQt5 import QtGui
from PyQt5.QtWidgets import QWidget,QHBoxLayout
from ColorWidget import Color
this is my current import
the L must be capitalised
ahh
yes
me dumb thank you
So if I am trying to add a label where the current color yellow is. Do I need to create a function for that?
Tkinter vs pyqt what do you guys recommend for light GUI for some projects regularly. Which one is easier to learn
Tkinter is easier to learn and pyqt is more powerful
I suggest you make the investment to learn pyqt, even if it has a steeper learning curve
@silk basin I think it'll get positioned there if you set the label's parent to the yellow colour widget. Of course, that means you need to assign that widget to a variable first rather than directly passing it to addWidget
The other way you could do this is add the label directly to the layout and then use a style sheet to change its background colour
Which is probably more idiomatic honestly
@sudden coral I ended up figuring it out! Program is coming along 🙂
is it made with ttk or pure tkinter?
@plucky wedge TRUE af , it is pure tkinter , it is not about language u use in making UI , it is about simple geometry and colors
I recently used a program that used the eel library.
https://github.com/samuelhwilliams/EelThis program uses eel and the screenshots are very nice.
https://pypi.org/project/auto-py-to-exe/It creates a offline web-based interface, designed using html/css and JS to interact with the backend. Since its css, you can use bootstrap and other themes. If you know some web dev it's basically a micro web dev framework. Haven't actually used it myself, but it looks like it'd be great for small programs.
@dense wind
yes u can use html css js, eel, electron js to make cool web based apps
anyone here knows about tkinter and can help me?
What problem are you having with tkinter?
Can someone teach me Tkinter
Like the basics of it
You can join the vc if u want to
Just the basics
Does anybody know how to create a button where all you can see is the text and the background is transparent in Tkinter?
hello i need a serious help#help-coconut
@last mantle Tkinter does not allow you to create a transparent button! You can try using a a transparet gif, and check if that works
Ok thanks
um
@nocturne kindle tkinter, not tkinder
oh
What are you having trouble with?
So, I have made a calculator, and it fits perfectly in my pc
But I gave it to my friend, but it does not work fine
His window was like this
mine is this
note--- he was on win 7 and i am on win 10
@static cove
why is this so big?
It's full screen
windowWidth = root.winfo_screenwidth() # Getting window width
windowHeight = root.winfo_screenheight() # Getting window height
root.geometry(f"{windowWidth}x{windowHeight}")
root.resizable(False,False)
root.state("zoomed")
It's hard to tell from the picture, what's wrong/different between the two?
The window size vary
My resolution is 1980x1080 and his is comparitvely lower
an my program does not fit there
hmmmm... My guess is there might be an issue in win7 with tkinter then for detecting screensizes.
mine is this
@fiery pier cool calc ui man , almost similar to windows calc
@fiery pier i think if the program has sizing problem find a good size which can fit on many systems
Could be due to their scaling. That likely wouldnt be accounted for with just winfo
@fiery pier i meant set FIxed geometry dont make it changable
Hey, just a quick question, I'm using this code
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
root.title("FNaF-Maker-Clone")
root.geometry("1280x720")
root.configure(background="black")
class Bg(Frame):
def __init__(self, master, *pargs):
Frame.__init__(self, master, *pargs)
self.image = Image.open("images/test.jpg")
self.img_copy = self.image.copy()
self.background_image = ImageTk.PhotoImage(self.image)
self.background = Label(self, image=self.background_image)
self.background.pack(fill=BOTH, expand=YES)
self.background.bind('<Configure>', self._resize_image)
def _resize_image(self,event):
new_width = event.width
new_height = event.height
self.image = self.img_copy.resize((new_width, new_height))
self.background_image = ImageTk.PhotoImage(self.image)
self.background.configure(image=self.background_image)
e = Bg(root)
e.pack(fill=BOTH, expand=YES)
menubutton = Button(bg="blue").pack()
root.mainloop()
```And I can't place a button, text, or any other GUI element on top of it. Does anybody know how to fix this?
Button(bg="blue")
Specifying e as the parent of the button would help
pretty much every tkinter widget takes its parent as first argument
should i learn qt or kivy?
This is my code
def __init__(self, num):
super().__init__()
self.sLayout = QVBoxLayout()
self.label = QLabel("Another Window")
self.sLayout.addWidget(self.label)
for x in range(num):
print(x)
self.progressBar = QProgressBar()
self.sLayout.addWidget(self.progressBar)
self.setLayout(self.sLayout)
print(num)```
This is my output
How would i stop at 10 progressbars and put the rest to the right
Use a grid layout instead of a vbox
This will allow you to specify both row and column when you add widgets to the layout
And you can calculate the column number easily using modulus x % 10
ok i will try that thanks
hey checkout my VS CODE
@cursive parcel how
@cursive parcel how
@orchid yoke add VIBRANCY extension
Oh i already have that
Is it the background of yours that make the cool color scheme @cursive parcel ?
true @orchid yoke
before i had cyan-green texture for my windows UI
then after an year , i changed it to blurple theme
wait what is VIBRANCY?? @cursive parcel
@west briar Vibrancy is u can say that
Blur-ness x translucency-ness