#user-interfaces

1 messages · Page 43 of 1

lofty elbow
#

Hmm, do you have any documentation where I could read up on that? Sounds like something I should definitely use

fathom crypt
#

(I'm not an expert on this at all, I've just made a few API clients before)

lofty elbow
#

Oh okay, thanks a lot for your suggestions!

#

I'll be sure to see how I can implement something like oauth

fathom canopy
#

Here is the part of a code i am using

def shoot():
    global player, c
    bullet = c.create_rectangle(c.coords(player)[0], c.coords(player)[1], c.coords(player)[0] \
        + 10, c.coords(player)[1] + 3, fill='black')
    for i in range(75):
        c.move(bullet, 10, 0)
        c.update()
        time.sleep(i * 0.001)
    c.delete(bullet)
    del bullet
def movep(event):
    global playeravatar, playerwalk1, playerwalk2, walking
    global shoot
    if event.keysym == "Up" and c.coords(player)[1] > 40:
        c.move(player, 0, -10)
        walking = not walking
        if walking:
            c.itemconfig(player, image = playerwalk1)
        else:
            c.itemconfig(player, image = playerwalk2)
    elif event.keysym == "Down" and c.coords(player)[1] < 660:
        c.move(player, 0, 10)
        walking = not walking
        if walking:
            c.itemconfig(player, image = playerwalk1)
        else:
            c.itemconfig(player, image = playerwalk2)
    elif event.keysym == "Right" and c.coords(player)[1] < 660:
        c.itemconfig(player, image = playeravatar)
        shoot()```
hollow forge
#

okay guys, i'm in the need of a gui module in python.
Altho i have a few requirements:

  • non web based, can be compiled/executed offline, etc
  • modern. By that i mean something which isn't based on old code but implement new modern concepts like object oriented, implement concurrency natively or make it easy to implement
    For example, I consider tkinter as really ugly and old, especially when it comes to implement parallelism it's a big mess, and not mentioning how the .pack() are annoying to put after each action, and how illogical the module is when it comes to documentation and architecture in general...
  • Works cross platform. At least for windows, mac
  • Easily convertible to .exe or application file according to the platform
#
  • native to python, and not stuff like Processing which have to be converted to another high level language and disable the user from using installed python libs or disable the user from using python completely and limitating in some ways, like making global variables act weirdly or some shit
alpine blaze
#

Kivy or pyside, i would say

maiden panther
#

Does anyone use electron here?

#

I just heard about it I wanna know from experienced people

fathom crypt
#

Just about everyone reading this is using electron (Discord app) 😛 but since it's a JS thing maybe this isn't the right place to ask

maiden panther
#

@fathom crypt you know about it?

fathom crypt
#

Know as in know it exists, sure, but I haven't programmed with it (or js for that matter)

maiden panther
#

So you don’t

#

I know it exist too

#

I know you exist too but do i know you? Lol

fathom crypt
#

Ok...? Anyway, this channel is only for Python UI libraries

maiden panther
#

Maybe you should add this to the channel name

#

I find this server helpful when i wanna ask something about python but when i ask about something that is not python everyone gets cocky and feels offended for some reason

#

I mean this server is supposed to create an good environment to learn coding or just to learn python?

rocky dragon
#

it is called Python

fathom crypt
#

Please refer to the channel info: For help relating to Python User Interface libraries (e.g. PyGame, Tkinter, Kivy, Curses)

rocky dragon
#

not coding

fathom crypt
#

If you want to discuss non Python libraries etc. there are 3 offtopic channels.

maiden panther
#

Its a shame big server like this doesn’t embrace or tolerate other languages

rocky dragon
#

Anyways, anyone using Qt5.14 ? After updating from 5.13 my app crashes on closing, just wondering if that's something related to it or to the version

maiden panther
#

You’d think it should since theres so many programmers each knows a variety of languages

alpine blaze
#

well, this server is about the python language and community, that's its purpose, that's what interests the people who manage it the most, if you have questions about that, #community-meta is the place for that, not here

#

but don't expect the server to become about all Programming or all CS

maiden panther
#

right

wraith belfry
#

how do i access a class from the outside? :S

import GUI #put the QT class inside here

ClassMainWindow = GUI.Ui_MainWindow

when i write this

ClassMainWindow.Brightnessslider

i get this error

AttributeError: type object 'Ui_MainWindow' has no attribute 'Brightnessslider'

i know that Brightnessslider is inside the class and under the function

def retranslateUi(self, MainWindow):

but i dunno how to call it to get to the brightnessslider

sudden coral
#

It's likely an instance attribute so you'd need an instance of the class.

wraith belfry
#

i've never worked with classes how?

sudden coral
#

Then I suggest you find a resource on classes before you jump into this.

#

Here are some

wraith belfry
#

i have a Qtslider that goes from 0 to 255, how can i convert that range from 0 - 255 to 0-100 and display it on my QTlabel?

tidal island
#

If I wanted a good, async gui, what module would you reccomend?

alpine blaze
#

i haven't tried async with it yet, but kivy does support asyncio/trio now.

#

the dev version though, not latest release

viscid ginkgo
#

How do I force an update on a TKINTER frame. I am udating data in one frame (frame_a), but when I change frames to display the data (frame_b), the new data is not there. I have tried frame_b.update() but it is not reinizializing the frame. ```
PYTHON

Controller Function

def refresh_frame(self, page_name):
    frame = self.frames[page_name]
    frame.update()

Frame_A Call

def update_pages(self):
    self.controller.refresh_frame("UserManagementPage")
    self.controller.refresh_frame("VMManagementPage")
fathom crypt
#

I've made a small app with kivy & asyncio, easy and no problems at all (tested on Linux+Android)

digital rose
#

Hey Im using pyqt5 and using grid layout, but when I put a label on the grid layout it automatically puts it in the middle of the window!? How could I use girdlayout and that the first label is top left, second is bottom right, etc

digital rose
#

Ok sorry for the horrible picture, but here is what I kind of want

frank lily
#

When I click a rectangle, how do I add a glowing border to a rectangle?

alpine blaze
#

@frank lily which library?

frank lily
#

Pygame @alpine blaze

alpine blaze
#

ouch, i don't want to remember, good luck

jagged halo
#

@fathom canopy i know its been a while but it is becuase your calling shoot() again which breaks it out of for i in range(75): starting it over? As for whey they all continue again later is it becuase as soon as the loop finishes it goes back to what it was doing which is the previous bullet?

#

all a guess

#

but my best guess :P

thin lynx
#

is it possible to insert an image here? like a logo?

vast tiger
#

Anyone know how to have elements resize to the relative window size in PyQT5 Designer?

#

I want to have complete control over element locations, but have them shrink or grow depending on the window size.

digital rose
#

@vast tiger I don't know exactly about PyQt5 designer, but I have had the same problem as you. I was using grid layouts but things were not appearing exactly where I want them to appear

#

From hours of reading, I learned that you can create your own layouts, you can customize a LOT of things using code, so I completely ditched qt designer.

vast tiger
#

And I put the elements in a grid layout

#

But it doesn't resize

digital rose
#

How can I make them touch eachother ?

sudden coral
#

There should be a way to set the spacing between widgets in the layout

fathom canopy
#

@jagged halo yeah and how not to break the cycle?

jagged halo
#

no clue, make a new thread for each bullet? probably not the best idea lol

fathom canopy
#

oh i can move a list of bullets

jagged halo
#

smart

snow mirage
#

peekaboo

rocky dragon
#

I was thinking about UI files for qt to replace my longer inits and setup methods but haven't looked at them before because it didn't appeal much.
Is there something like a reference for how to use them with PyQt? Mainly if I should attempt to write them myself (and resources for that if yes) or just attempt to use the designer where possible.
And things like if there is some inheritance of basic layouts

sudden coral
#

I think QML was intended for that

rocky dragon
#

When I tried QML it was Just QtQuick and things like that instead of normal QtWidgets and didn't support them iirc

vast tiger
#

How can I still enable grid window in the PyQT5 Designer so the elements move relative to the window size but they don't snap to a position?

viscid ginkgo
#

Anyone a tkinter user?

dawn glacier
#

Do you need help ?@viscid ginkgo

eager vigil
#

Do any GUI libraries use html?

hollow mist
#

html? for the controls? No. but qt uses css

#

You can also use electron and flask if you want to use python

#

Can any display html? Many

rocky dragon
#

If going with python because the .ui seems more complicated than I'd want for manual work, would you separate the UI bases from logic with files (popups and popups_gui as an example) and inheriting the bases or just keep the methods separate

sudden coral
#

Yes, I would try to keep it separate

#

Maybe subclassing isn't the best way. There are various design patterns out there that you could look into and try to apply to Qt, if possible.

viscid ginkgo
#

@dawn glacier Yeah, I need a way to refresh a frame in the stack. I found a work around by reloading the data.

rocky dragon
#

I have this class as an example, I also have a Hub class that connects workers with various windows. https://paste.fuelrats.com/urexocixos.py
I can see how things like the populate_combo and load_journal methods could be moved there, but for the worker_signal which can't be moved outside of that class, how should it be handled? Connect it to an another signal in the Hub? Also feels like the Hub class could get too big if I move it all out from there becuase I have some (now messy) ui classes which have 4-5 methods for adding and handling their data

eager vigil
#

I'm moving to python from html/js. Which GUI library would you recommend?

alpine blaze
#

depends on what you want, pyqt/pyside are common for desktop applications, kivy is also a possibility, with the benefit of multitouch interactions, and availability on android/ios, and with a more pythonic api, but looks less native on desktop.

eager vigil
#

thanks

viscid ginkgo
#

@eager vigil If you still wan to develop online, flask is a good way to go.

digital rose
#

i need help with pyqt

wheat copper
#

hello, anyone here?

#

I just started learning GUI and I had this problem with importing the image!

#

can anyone help?

rocky dragon
#

icons probably aren't a valid format for normal images

wheat copper
#

weird that the first one (logo1.ico) worked, the 2nd didn't!

rocky dragon
#

the first one is for loading an icon specifically

wheat copper
#

so it's okay with importing a .jpg or .png in the 2nd?

rocky dragon
#

try making a png or something, ico is a more complex format that can contain multiple images

wheat copper
#

alright, just a sec

rocky dragon
#

Not sure if png is supported as pillow usually handles those

#

but a better bet than ico

wheat copper
#

it worked😄

#

thanks mate

dawn glacier
#

qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 939, resource id: 12146163, major code: 40 (TranslateCoords), minor code: 0

#

Using pyqt5

#

Oh is this because i run as root?

#

How can i change that

dawn glacier
#

Hello guys, how can i update the tab after i set its object name?

rocky dragon
#

Got some code?

dawn glacier
#

Hey everyone, i wanted to manage my Text editor with a Box Layout (So far its with a centralwidget) but i cannot seem to show the items after i add them into the layout

digital rose
#

Guys I need help... Can't find this online !

#

I have this, (labels with grid layout in a group)

#

I want to make it so when I hover over it, it does the exact same thing as a default list in qt designer

#

So like when I hover over it, it makes an animation or does this

sudden coral
#

Why not use a QTableWidget?

#

I think trying to implement what you're asking yourself would be a bit involved

digital rose
#

Alright so I kinda did it, really complicated but now I need to do second part,

#
    def eventFilter(self, object, event):
        clicked = True
        rowNum = object.objectName()[-1]
        connectedObj = self.dictLabelObj["Connected" + rowNum]
        onlineObj = self.dictLabelObj["Online" + rowNum]
        roomObj = self.dictLabelObj["Room" + rowNum]
        privateObj = self.dictLabelObj["Private" + rowNum]
        if event.type() == QtCore.QEvent.MouseButtonPress:
            if event.button() == QtCore.Qt.LeftButton:
                privateObj.setStyleSheet(self.clickSt)
                roomObj.setStyleSheet(self.clickSt)
                connectedObj.setStyleSheet(self.clickSt)
                onlineObj.setStyleSheet(self.clickSt)
                
                clicked = True
                pass
            elif event.button() == QtCore.Qt.RightButton:
                pass
        if event.type() == QEvent.Enter:
            privateObj.setStyleSheet(self.hoverSt)
            roomObj.setStyleSheet(self.hoverSt)
            connectedObj.setStyleSheet(self.hoverSt)
            onlineObj.setStyleSheet(self.hoverSt)
            #object.setStyleSheet(self.clickSt)
            pass
        elif event.type() == QEvent.Leave:
            if clicked:
                pass
            else:
                privateObj.setStyleSheet("")
                roomObj.setStyleSheet("")
                connectedObj.setStyleSheet("")
                onlineObj.setStyleSheet("")
               # self.stop = False
        return False
#

its kinda complicated, uh, is there a way to LOCK, like disable all changes to a label? Because when i click on it I want it to stay another color... But when i hover over another label the color of the clicked label changes back to white

tired sandal
#

since my pyqt code aint working properly for some reason and I have no idea why

#

Its probably some stupid typo or something

tired sandal
#

nvm I got it to work

past pivot
#

I'm using PySide2, and I have a for loop where I initalize buttons.

#

I attach callbacks to the buttons, but how do I figure out which button was clicked inside the callback?

#

this seems way too hard, even though it should be simple

rocky dragon
#

buttons should pass their objects on some events

#

Not sure if it's on the all that that fire when you click, but you can set an objectname or keep a dict/other container of them

bleak smelt
rocky dragon
#

That look sort of look?

bleak smelt
#

I'm trying to get the label section under the Header section, so that you can see the border radius on the label section

rocky dragon
#

Not sure about QDesigner, or the proper way to do it with Qt without searching for it... but 2 rects come to mind

bleak smelt
#

If I stack the two widgets ontop of each other. The sharp bottom can be seen.. I want it under the header section so it flows nicely.

#

Is it possible to overlay widgets?

#

Not finding anything via google searching :/

rocky dragon
#

Don't really know how I'd do it and don't want to lead you the wrong way

bleak smelt
#

Hmmmm.... Wonder if I can just use a Tab widget and change the border-radius for the tab and page.

tidal spruce
#

In kivy, I have got a Boxlayout with 2 further BoxLayouts inside

#
| BoxLayout | BoxLayout |
|-----------------------|
| BoxLayout | BoxLayout |
#

Would like to make the bottom one smaller than the top but can't figure out how to do it (using kv lang)

#

Was thinking something like this on the lower BoxLayout: yml <LowerSplit>: size: (Window.width, Window.height * .25)But it doesn't work at all, size does not seem to affect it

past pivot
#

@rocky dragon no, they don't seem to pass their objects

#

and how would I do this with a dictionary?

rocky dragon
#

there's also sender of QObjects that'll get you the thing that called the slot it's in if they don't pass themselves

past pivot
#

I don't think I understand what you mean...

rocky dragon
#

!d PySide2.QtCore.PySide2.QtCore.QObject.sender

proven basinBOT
#
PySide2.QtCore.QObject.sender()```
 Return type [`QObject`](#PySide2.QtCore.QObject "PySide2.QtCore.QObject")

Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns `None` . The pointer is valid only during the execution of the slot that calls this function from this object’s thread context.

The pointer returned by this function becomes invalid if the sender is destroyed, or if the slot is disconnected from the sender’s signal.

Warning

This function violates the object-oriented principle of modularity. However, getting access to the sender might be useful when many signals are connected to a single slot.

Warning

As mentioned above, the return value of this function is not valid when the slot is called via a `DirectConnection` from a thread different from this object’s thread. Do not use this function in this type of scenario.

See also... [read more](https://doc.qt.io/qtforpython/PySide2/QtCore/QObject.html#PySide2.QtCore.PySide2.QtCore.QObject.sender)
past pivot
#

How do I use that function?

#

There don't seem to be any examples

#

Where should I call it?

rocky dragon
#

in the slot that received your signal

past pivot
rocky dragon
#

Don't call it directly

#

I assume you have a QMainWindow or something where the button is, so call self.sender() or something like that

past pivot
#

ah

rocky dragon
#

Anyone used .qm files with QTranslator? Wondering how the same words should be handled around different contexts

tidal spruce
#

In kivy, I have got a Boxlayout with 2 further BoxLayouts inside| BoxLayout | BoxLayout | |-----------------------| | BoxLayout | BoxLayout |Would like to make the bottom one smaller than the top but can't figure out how to do it (using kv lang)
Was thinking something like this on the lower BoxLayout: yml <LowerSplit>: size: (Window.width, Window.height * .25)But it doesn't work at all, size does not seem to affect it

wheat copper
#

hello, I was trying to create a menu bar, no errors found but it did not work

#

can anyone help?

digital rose
#

So uhhh can make a label "Double Clickable"?

alpine blaze
#

@digital rose which framework/library?

digital rose
#

Anyone have a good resource to learn PyQt?

past pivot
#

@digital rose check out pyside2 - it's just like pyqt, but from qt

#

and I think it has better licensing

digital rose
#

Okay thanks @past pivot !

past pivot
#

Np

digital rose
#

Is tkinter widely used in the industry? Anyway i’m learning tkinter right now is it similiar to Pyside2?

#

I don't think so, it has outdated code and has elements looking like from Windows 98 alone, i'm not sure really. But I would say no if it was a serious application, however it is fairly easy to learn without mentioning illogical programming.

digital rose
#

Alright gonna learn pyside2 then! Anyway can Kivy support iOS pretty well? I want to build like a productivity app for myself, and i heard that Kivy supports crossplatform what kind of quality i can expect from it?

alpine blaze
#

kivy does support iOS as well @digital rose

#

kivy has the particularity that it uses its own widgets, so your app will look about the same on windows, osx, android, linux, ios, some people like that, some don't, i find this very freeing and desirable if you are ready to give a particular design to your app, as kivy allows for easy customization of your widgets (and even creating thom from scratch, it's really easy), you can really go where you want in matter of design. For this reason, quality depends a lot on you, the default look being quite modest.

digital rose
#

I will use kivy in my personal project then xD i don’t want to learn react native or swift atm so i think i’m just going to try them all, thx for the help guys!

alpine blaze
#

🙂

#

you do need a mac with osx and xcode to test on an iphone btw, it's now free to test on emulator and your own device i think, but to publish on store to share with anybody, you need to pay the apple tax, i think some $100 a year.

digital rose
#

god i hate iphone so much, the only reason i’m using iPhone is because it was a gift from my mother 😭

digital rose
#

@digital rose which framework/library?
@alpine blaze

#

It was pyqt5 but uh I figured it out, just made another class and modified and modified a bit the original btn class

#

With signals, but yeah if you know another, better, way to do it tell me obama

odd hamlet
#

so I've been reading through a bit of the kivy docs and im not quite sure wether im just missing out on something but is there a go to way to spread your widget definitions accross multiple files?

#

with widget definitions meaning both the kv files but also the logic implementations in python

odd hamlet
#

anyone?

alpine blaze
#

you can use the Builder class to load files/strings of kv definition

young timber
alpine blaze
#

the Factory class can also be used to register widgets in modules without loading them before, so they are loaded as needed.

#

but it's true that while the tools are here, the manual for how to use them is not really present.

odd hamlet
#

good so i didnt miss out on anything^^

young timber
#

@timber prism i'd recommend either kivy or pyqt

timber prism
#

So these help you rapidly develop GUIs with python.

#

What about the rest of the application. Common functions that many apps need?

young timber
#

could you elaborate on common functions?

#

what common functions are you looking for?

timber prism
#

Its a broad question. But you can think of features that many apps use. For example dialog boxes, importing CSV files, saving preferences, supporting fonts.

#

Then if your talking about types of apps you could think of all the features that every app of a certain kind always has.
Screen Scraping
Printing to PDF
Conditional Font manipulation (colors, size, style)
ETC

young timber
#

many of the GUI features itself are ready for you to use in kivy & pyqt including dialog boxes, different fonts, and many different wigets. dealing with csv files, you can use the csv module. for printing to pdf, pyqt has a way to do that

timber prism
#

Ok thanks, its good to know there is something out there for the GUI part.

#

Now I need to look for the app features part.

young timber
#

there's plenty of libraries out there; i'm sure there's one out there for your needs

timber prism
#

Thanks for your help

young timber
#

no problem!

alpine blaze
#

Kivy has plyer to put commonly needed mobile feature together

#

And the underlying libraries, pyjnius and pyobjus, allow calling java and objective c code on android and ios, to use other system functions.

digital rose
#

🤔

sand warren
#

@alpine blaze what is the benefits of using pil as the text renderer? sdl2 does work on my system, while pil needs pillow installed I think.

alpine blaze
#

it's an alternative, i rarely use it, i don't think there is any particular advantage, i think we had it before the switch to sdl2, and there is no particular downsides to it.

#

pillow is also an alternative image loader, that can load a couple things that our sdl2 provider can't, like gif, so it can be worth having for that.

sand warren
#

that is interesting, thanks.. ill keep that in mind if i need to use gifs

alpine blaze
#

yeah, it's been there since basically the dawn of times, in kivy history.

#

if you need animated things and have a choice, we support a weird thing that works well for us, just put pngs in a zip, and use that as source, functionally identical to gif, but with real transparency, and usually smaller in size.

sand warren
#

im writing a JSON editor with a graphical interface for a new game I just got into

#

png and drag and drop options is what i need atm.

alpine blaze
#

🙂

#

we have a DragBehavior now, i didn't use it because i had made custom things for my stuff before we had that, but it's worth looking at

sand warren
#

how nice 😄

#

i want to stack dragable elements on top of each other, ill be sure to look into it 😄

#

thanks

thorny spruce
#

We found using a .zip more performant than a .gif

digital rose
#

What text entry should I use for chat server?

thorny spruce
#

Depends really, do you want single line or an entry that supports mutiline?

subtle gust
#

hey

#

what do u recomend for GUI?

alpine blaze
#

i recommend kivy 😄

#

but it depends on what you want, it's more fit for some things than for others

#

and for others, pyqt/pyside2 is certainly a better option.

subtle gust
#

pyqt and pyside2 are the same thing?

rocky dragon
#

they wrap the same c++ framework

#

in some cases they are interchangeable, pyside2 is the official one but when I tested it I had some problems (that could be only relevant in the scope of my app)

#

qt also offers a lot more than ui so it's a bit more heavy to download

digital rose
#

Hello guys

#

I am new here

#

Is there any module to use other than tkinter(simpler) for making gui

rocky dragon
#

both of the mentioned above apply here

#

qt has a more similiar look and utility as tkinter, and kivy gets you more freedom in building it how you want it but doesn't have premade stuff for desktop etc.

fallen oxide
#

@digital rose Sorry, I wasn't here

#

But this is a better channel to ask about Qt

#

Anyway, I'm not convinced you quite have pyqt5 installed (or pyside2) - you may have installed it to your system python, but if you're using a tool like pycharm then you may also have a virtualenv it needs to be installed to

digital rose
#

Ah, I see

fallen oxide
#

so, are you using a tool like that?

digital rose
#

I have JetBrains dotPeek 2018.3.4 installed so maybe it's causing a conflict?

fallen oxide
#

No, that wouldn't do it

#

What OS are you on? How did you install PyQt5?

digital rose
#

Win10 and I used cmd.exe and installed via pip install PyQt5

fallen oxide
#

So if you did python in a terminal, can you import it?

fallen oxide
#

That doesn't mention PyQt at all

#

just open a cmd, python

#

then do import PyQt5

#

see what happens

digital rose
#

It's in the requirements text

#
umap-learn
visdom
webrtcvad
librosa>=0.5.1
matplotlib>=2.0.2
numpy>=1.14.0
scipy>=1.0.0
tqdm
sounddevice
Unidecode
inflect
PyQt5
multiprocess
numba
#

So when I do pip install -r requirements.txt it should have installed it anyways

#

alright I will try that

fallen oxide
#

Ok, but still do that

digital rose
fallen oxide
#

Yep, it's installed then

#

Sounds like an issue with the software you're trying to run

digital rose
#

Back to the drawing board. Thanks very much 🙏 It might be to do with nvidia from what I understand.

#

I'll do a thorough uninstallation and see how I get on

#

Thanks anyways 👍

digital rose
#

Does anyone know how to style PyQt5 to become more pretty? I use Qt designer to design my UI then convert it to .py with pyuic5, do you have to code or you can use some interface tool to style it?

#

and while learning i saw some CSS, does this mean PyQt5 uses CSS for it’s stylesheet?

sudden coral
#

You can write your own or find a style you like online

digital rose
#

Thx! i have been looking for this

vocal turret
#

I am currently trying to build a linux desktop environment on top of i3wm. To navigate through things like settings and applications, I plan on using something similar to dmenu. Could someone point me towards how to make such an application?

alpine blaze
#

demenu is pretty simple, you just need to draw a borderless window and to take keyboard inputs, filtering through a list of options.

#

basically any UI framework will allow you to do that

#

you might want to have a look at rofi though, it's a bit more advanced and also has the possibility to add providers and to display icons and such

#

switched from dmenu to it a year ago i think.

frigid hamlet
#

I have a tkinter code that displays an image of a custom made title with a blue background. then i want to display 3 modules. one entry, one button and one label. the play is to make it look like this:

#

how would i do so?

formal leaf
#

u might want to use place then

#

or grid

frigid hamlet
#

ok 1 sec

formal leaf
#

u can place(x=value,y=value)

#

so button.place(x=value,y=value)

frigid hamlet
#

OK I GOT IT

#

thank you

#

i tried grid before and it DID NOT LIKE IT

formal leaf
#

jaja

#

place is pretty straight forward

frigid hamlet
#

first time using tkinter

formal leaf
#

a lot of trial and error tho

frigid hamlet
#

yeah i realise now xD

#

also look. i use the white rectangle in PS to match with the top left corner so i know the EXACT pixels i need to go across and down

formal leaf
#

im not that intelligent i guess

frigid hamlet
#

thats just cool thing i realised

#

cause i made the title myself in photoshop and still had it open

formal leaf
#

thats cool

frigid hamlet
#

hopefully its a good grade for my coursework xD

formal leaf
#

lol

#

what are u tryin to do

frigid hamlet
#

we got told to make ANYTHING

#

and its 20% of our final grade

#

we then need to write like alot of analysis on our code and process

formal leaf
#

thats a lot of %

#

good luck

frigid hamlet
#

a fruit machine game was the first "proper" program i made when i was like 15, but that was just text. so while loops and if statements. adding an interface and other stuff should be good enough to show i 'know what im doing'

#

xD

#

thank you 🙂

timber gorge
#

Hello everyone. o/
I really glad to become a part of this great community. I hope i'm not going to bore you with my newbie questions. :)
As a newbie coder i'm looking a way to store my images. Right now i encode it to strings and store it in .py as dictionary, then i call from main file.
Is there any way to do that more efficient?
I already tried json, but have no luck to use it in tkinter. Maybe something else what i should read?

EDIT: Also, English is not my native language. So, sorry me, guys for any grammar mistakes.

topaz aurora
#

I'm not entirely sure what you are trying to make with Python. But there are libraries meant to work with images in an effcient way. Are you trying to display the images in a GUI program, like a picture viewer? Or are you trying to edit the images in some way?

timber gorge
#

I mean GUI elements, like buttons, windows, background. Or something else only for interface.

topaz aurora
#

I don't follow what you are trying to do. I don't really know GUI programming or Tkinter so it's hard for me to say. Maybe posting some of your code, or some of the json can help other people help you

sudden coral
#

What's wrong with storing them as regular image files?

timber gorge
#

Its almost 50 files. :)

#

Would be good if i can store it without ability to inspect.

sudden coral
#

What do you mean "without ability to inspect"?

timber gorge
#

look, copy/paste, use it without permission.

sudden coral
#

I can't help you with that. I'm not familiar with how to accomplish that, but my understanding is it's not really easy to prevent that with Python.

#

If someone tries hard enough and puts enough time in, they'll be able to get those images

topaz aurora
#

Yep. Python seems fairly easy to 'get into' with the REPL and all those other fun features

sudden coral
#

Anyway, since you dislike many files I get the sense that you want your application to be in a single file? If that's the case then you should look into packing it into a binary/executable (e.g. .exe file on Windows) rather than jamming everything into one .py file.

timber gorge
#

Hm, sounds good. Its possible to pack all .py files in 1 exe?

#

I have 3. Main, system, image data.

sudden coral
#

Yes

timber gorge
#

Oh, great.

#

Thank you so much!

sudden coral
#

You're welcome

digital rose
#

Hey guys! What library would you recommend for a simple card game if I have no experience with gui at all?

alpine blaze
#

if you are comfortable enough with OOP, i'd recommend kivy, (but i'm biased, as one of the devs)

digital rose
#

Thanks for the quick response. Is it easier to get started than tkinter?

#

the gallery apps are beautiful

alpine blaze
#

thanks :), i don't think tkinter is specialy easy to get started with, it has a lot of weirdness imho, and the doc is pretty spread out.

#

kivy is not perfect either, but i do believe it's easier to use than tkinter.

#

it's been a long time i didn't do any tkinter, but i don't think it changed much.

digital rose
#

great! Where do you recommend to get started with kivy?

alpine blaze
#

the getting started section of the doc and the programming guide

digital rose
#

Nice, thanks! I will give it a shot 🙂

alpine blaze
#

🙂

half vapor
#

are there any other GUI libraries in the standard library aside from tkinter?

proper glade
#

you can hook into native ui with ctypes :p

alpine blaze
#

why does it need to be in the standard library?

digital rose
#

Is there is a way to get the coords of an image with pyautogui regardless of it's rotation? locateCenterOnScreen needs to find the exact image to work.

timber gorge
#

Anyone knows if i can use .cur encoded with base64 in tkinter?

timber gorge
#

Hm. Still have no luck with pyinstaller.
In tkinter Label config i have ````cursor="@cursor-exit.cur"and for root i also useroot.iconbitmap("icon.ico")```
Then i pack all my scripts with pyinstaller with commands:
--add-data "icon.ico;icon.ico"
and
--add-data "cursor-exit.cur;cursor-exit.cur".
And anyway .ico and .cur still should be in one folder with .exe. Or i will get message Fatal error detected

Anyone could help me with that?

sudden coral
#

I'm about to head off but I just saw this and I suggest you clarify what the problem is. You've stated what you've tried but not what is wrong.

#

Is it the penultimate line? That despite including them with --add-data, if the files are not present beside the exe, you will get a fatal error?

timber gorge
#

Oh, really sorry. I will try to clarify.
I'm trying to pack all files to one .exe. I have files beside python scripts:
icon.ico and cursor-exit.cur. if i even pack it with --add-data i can't launch my .exe without this files. That's the problem.

burnt belfry
#

i think the flag is --onefile now i have not used pyinstaller in awhile so i may be wrong but thats the flag i used to use

timber gorge
#

Forget to say, i already using this flag. But nothing.

tribal path
#

onedir is usually advised first to see if that loads before onefile'ing

dense creek
#

Hi guys i need help

#

i want to change the Top bar of the Windows to set Tittle in the middle and change Minimize MAximize and close button

#

so i make a framelesshint window and i create another bar

#

and inside i create buttons + set tittle *

#

but i don't know which is the best class to do that ToolBar / MenuBar / StatusBAR

#

i'm working on PyQT5

#

thanks

digital rose
#

I need help to select my first library for user interface, i think Kivy is the best for her compatibility

wispy oar
#

I have an assignment which is to simulate a lift algorithm and optimise it to be time efficient for different numbers of people requesting the lift at various floors. I was wondering which Python library would be most recommended for this assignment.

#

It would be a desktop application, and I've done a bit of research beforehand; it seems like PyGame might be a good option, but I was also wondering about PyQt5?

#

I have some experience with PyQt5 so it would be quite easy for me to get into, but would it be appropriate?

#

I don't think it needs to be animated, but I've heard PyQt5 can have animations as well (although it seems harder than PyGame)

#

I was thinking I could simulate it with blocks representing floors, and the lift being a coloured block, with the floor changing colour when the lift is on that floor

real jolt
#

Id pick the simplest solution tbh, it seems simple enough and its representation doesnt really need to fancy unless you get marked down for it.

wispy oar
#

So do you think PyQt5 would be the simplest solution in my case? I already know how to design the interface through Qt Creator and get it linked up, I'm just wondering if it would have any limitations for my use case here

real jolt
#

If you are most comfortable and have experience then yes.

wispy oar
#

So I started my basic interface

#

And I wanted to have blocks on the right side of the grid to represent the floors, then I'd change the colours of them when the lift is on that floor

#

But I'm not sure how to create the blocks

#

Would I just change the colour of the coordinates of the grid in the driver code?

tawny terrace
#

Anyone knows how to make a GUI with a transparent hole in the middle? one that you can see other apps through?
doesn't matter tkinter or pyqt5 or other (in windows)

deep citrus
#

can i get pyqt5 for python 2.7?

candid eagle
#

can anyone help make some form of circle that i can change colour? only im only using QtCreator so cant find anywhere to make custom widgets etc so really need someone to walk through it with me if possible? i did find a premade example, the idea is a LED like icon to indicate the server status
the link for the widget i want to use is:
https://store.kde.org/p/1132197/ however i dont know how to use it, im using QtCreator and only editing a single form.ui file which non of the guides do

digital rose
#

Kivy is not working for the 3.8?

digital rose
#

How do I add interface input/button on turtle or tkinker

alpine blaze
#

@digital rose you need the pre release for 3.8 or use latest with 3.7

#

@tawny terrace kivy supports using a mask image to give your window an arbitrary shape, that would work for your case

upper knoll
#

Hello, I am creating a project using tkinter and I want to do this. I've written code but it is not working out

#

How do I make two frames in one window and have an image in next frame

digital rose
#

@upper knoll Try making two different scripts, one for each frame, then have buttons that will run one script from another, making it seem like they're the same program

upper knoll
#

I don't get it, could be elaborate more please

#

I've just started learning it and don't know much about it

low hemlock
#

Yo, do you recommend kivy or tkinter?

compact sparrow
#

I don't know kivy, but I sure as heck don't recommend tkinter

dusky narwhal
#

Was looking to make first project with a bit of GUI, pysimplegui looks fairly simple and good, is it a reasonable package to use ?

#

It's a very basic program, just want some menus, submenus, press a button program does the thing, go back to base screen, etc.

digital rose
#

Hi people, I want to make a very small software for myself to take screenshots, is PySimpleGUI a good place to start for the UI? I want something dead simple.

dim ore
#

Is simplegui the thing programmed by some guy from the Rice University ?

#

If it's this i played a bit with it during their online Course, it was okay to make simple games

#

Not sure how it lives outside of this

#

How it seems it's own thing despite names being really similar. Disregard my comment

fervent nebula
#

with tkinter, I'm trying to create a label inside a frame built inside of a class.. the window returns the children, but they're not labeled so I'm not sure how to access the right widgets..

ie, when I look at my_window it gives me: my_window['children'] and it shows me labels like !toplevel.!frame4 is there a way to name the widgets so I can tell which child I'm working with?

languid nexus
digital rose
#

What would be the best bet for making a modern style GUI?

rocky dragon
#

qt5 or kivy, kivy will be more ready to use with a flat modern design but needs more work for a normal desktop app if you're also aiming for that

#

qt is a bit harder to customize

digital rose
#

Are any of them easy to use?

rocky dragon
#

both are fairly easy with their own quirks if you have a fair understanding of OOP

digital rose
#

isnt kivy mainly for cross-platform?

rocky dragon
#

it's one of its aspects, qt can also do that but isn't as suited to mobile afaik

#

but for desktop both are fine (depending on the app)

digital rose
#

also, if I were to code in kivy, would there be much recoding to do if I were to port it to mac from windows for example?

rocky dragon
#

shouldn't have any unless you yourself use feature specific to that os

digital rose
#

true

#

thanks for that!

main hare
#

Hi there. I'm looking to create a text based MUD-like rpg. I've been fooling around with curses* but I'm not sure it's the best terminal module to use. Anyone have any suggestions or would I be better off trying to do something from scratch?

candid eagle
#

anyone here using QtCreator?

whole egret
#

hello friends, which python ui library/framework works and looks best for mac (if there is one)?

young timber
#

kivy or pyqt come to mind

#

@whole egret

rugged minnow
#

@whole egret PySide2

#

it is officially supported by QT Company

tropic patio
#

Hey snake lovers!
I've got a question. Been tasked with making a desktop app: digital controller for stage lights (midi signal). Can anyone recommend a UI framework for that kind of task? I've found PyQt and Kiwy appealing but would like to have a more experienced opinion.

young timber
#

both are great choices, but i'd personally go for kivy

main hare
#

Anyone have any help for the question I posed yesterday? ;_;

zenith anvil
#

Is there a UI Maker that could simplify the work it takes? I only recently started with Python and would like to make standalone Executables with Intricate UIs.

sudden coral
#

Yes, Qt has one.

#

You still have to write code to connect the pieces but at least you can design the ui with it.

thorn hull
#

hi all

#

im looking for advice on the matter of creating a gnome extension
ive heard pyhton is a good way to do this

#

but some features i want to incorporate are swipe gestures and an array of button, instead of just one indicator

#

is that possible at all? im trying to do this bcs of my touchscreen device

compact sparrow
#

I did say I have experience with gtk, but that kind of stuff is way different from anything I've done. Heck, I didn't even know gnome extensions used Gtk to create their icons

thorn hull
#

yeah i reckon my plan might be too much. but im not sure. the way python is presented by others, is that virtually anything can be made

whole egret
#

Thank you @young timber and @rugged minnow... I have heard of Kivy but will also have a look at PySide2

dawn glacier
#

Im having some problems installing kivy 1.11.1

#

What dependecies should i have installed before installing kivy?

#

Seems like im missing some

rocky dragon
#

is it complaining about something in the logs?

dawn glacier
#

Yeah, hold on

proven basinBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

dawn glacier
rocky dragon
#

not sure, does 1.11.1 support 3.8?

dawn glacier
#

Hmm

#

Let me check

rocky dragon
#

only used kivy in the recent codejam so don't remeber which version it was that had the version jump

deep citrus
#

Anyone who knows Tkinter can help me?

#

I'm trying to get it so when they have entered the IP range and they click the "click to scan" button it runs the code gets the information stored inside the ip variable and prints it out where it says scan_result = scan(ip)

#

at the moment it just prints out the print stuff i made without any Ips because i want it to get the IP the user gave in the input box and use it

#

I have a feeling im close to getting it right but maybe i need to rearrange my code or add something

#

Im new to python and tkinter so if anyone would give me a hand that would be great

alpine blaze
#

kivy 1.11.1 doesn't support 3.8 (at least, that's the tl&dr version), either use 3.7 or use the kivy pre release packages.

candid eagle
#

im using Qt anyone able to guide me through adding a cutom widget or making one? so far i only have a single form.ui file which i convert with pyuic5 then my program handles the ui from there

alpine blaze
#

@dawn glacier yes

#

or pip install --pre --extra-index-url https://kivy.org/downloads/simple kivy

dawn glacier
#

Ok, ill try

dawn glacier
#

@alpine blaze It worked, but when im running my app it says xsel - FileNotFoundError: [Errno 2] No such file or directory: 'xsel'

sudden coral
#

Looks like it relies on xclip or xsel for some clipboard functionality, and you don't have either of them installed (or not on your PATH)

#

If you install one of them it'll probably fix the error

worldly venture
#

I got a strange bug on tkinter. I am working on a text editor, and I want to remove the text field when there are no file tabs open

#

I want to first prompt the user if he/she wants to save the file before destroying it completely

#

Regardless of the results, the app will then wipe out the text field with .delete("1.0", tk.END)

#

and then text_field.pack_forget()

#

The problem here is that the .delete part never comes through

#

The text_field disappears, but the text itself is still there

#

It only works when I comment out the save_file() functionn

#

Is it because of the filedialog.asksaveasfile() function?

#

Any help or ideas will be greatly appreciated.

alpine blaze
#

@dawn glacier yes, xsel and xclip are optional dependencies for clipboard handling.

dawn glacier
#

Oh, how can I install them then?

#

@alpine blaze

rocky dragon
#

That sounds like an external os tool dependency

alpine blaze
#

apt if you are on a debian derivative, yum if it's an rpm based distro, etc

dawn glacier
#

Alright

dawn glacier
#

How can i make a button or a label you can hover on and click in kivy?

dawn glacier
#

I am trying to make a layout when every row is a hoverable and clickabe item with some data on it

tribal path
#

recycleview as a starting point maybe, hover is watching something like the cursor coords

dawn glacier
#

Hmm

alpine blaze
#

well, making a button is not a problem, i assume, making a list of them can be achieve in a number of ways, and recycleview is a very good one if you have a lot of them and want to be data driven (and if the layout options fits your usage, as it seems to be the case there).

#

so is your question about handling hovering events? or about using something like the recycleview for it?

olive slate
#

How can I make it so when a button is clicked, a new "window" is opened? Like for example how when you login somewhere youre taken to another display. For example, you login and then the display switches to gamemode options. Sorry if Its nit explained great

alpine blaze
#

(though there is one problem remaining, as it pos doesn't actually change when the scrolling happen, as it's relative, so one would need to bind to scroll_y of the recycleview as well, but passing that information around is not really convenient, so i stopped, there not knowing if that was a problem for you or not)

dawn glacier
#

Ok! ill take a look, thanks 🙂

#

That is fantastic, thank you 👍

alpine blaze
#

yw 🙂

dawn glacier
#

rgba: C('222222BB') if self.hovered else C('00000000') this is really cool, didn't know about this attr

#

Or on this button at all

#

I probably missed some docs

alpine blaze
#

i created the attribute for this class, it's not something that exists in kivy

#

but as you see, it's not really hard to implement

dawn glacier
#

Oh i see

#

What about adding or removing in runtime?

alpine blaze
#

just add or remove things from the data dict

dawn glacier
#

Cool

alpine blaze
#

i kept things simple there and managed the state directly in the widget, but in more complex recycleview usecases, you want to save the modified things into the data dict and let the dispatched state update the graphical things

dawn glacier
#

Alright, thanks again

olive slate
#

Sooo can somebody help me?

merry oak
#

what do you need help with?

olive slate
#

How can I make it so when a button is clicked, a new "window" is opened? Like for example how when you login somewhere youre taken to another display. For example, you login and then the display switches to gamemode options. Sorry if Its nit explained great

merry oak
#

Sorry, don't have great knowledge, and only did something like that for a very short while.

olive slate
#

Alright

#

Thanks anyway

young timber
#

if you're using kivy, take a look at kivy.uix.screenmanager.ScreenManager

olive slate
#

I am using tkinter

young timber
#

oh sorry, i have no idea then

olive slate
#

Thank you do much

merry oak
#

Thank you do much

  • @olive slate
olive slate
#

So*

digital rose
#

is there a way to show the running code inside tkinter?

#

the prints output

worn sedge
#

@digital rose if you're starting the app from the command line it should just print there. If you are bundling with something like cx_freeze then it's something you turn on and off in the options for the bundler

thorny spruce
#

You can redirect the print output to your text widget

deep citrus
#

Does anyone know if I can make like a save button that saves an output to a text file using PyQt5 ?

rocky dragon
#

Yes, you'll just need to link the button to a function that does that

clear kernel
#

so, I know this is a dumb question, but I'm not sure what I should google search to get more information about it. This is my first time making a UI for a desktop application, and I'm not sure which functions of my app would belong under the different File, Edit, and View menus in the top bar, and I was wondering if there was some kind of best practices document anyone could recommend?

lunar kernel
#

hey any idea about which optimizer is used in image classification model compilation?

#

using keras?

alpine blaze
#

@clear kernel well, usually file contains operations that are relative to the file/document as a global thing, so load/save of course, but also whatever touches its metadata, and edit would be more about what modifies content in the document, view is for whatever changes how you view and interact with the document. Of course, if your program is not an editor of any sort, the first two ones are probably totally irrelevant, and the 3rd one might be as well.

#

@lunar kernel i don't think that's the proper place for that.

gaunt portal
proven basinBOT
#

Hey @gaunt portal!

It looks like you tried to attach file type(s) that we do not allow (.flv). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .m4v, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .md.

Feel free to ask in #community-meta if you think this is a mistake.

#

Hey @gaunt portal!

It looks like you tried to attach file type(s) that we do not allow (.flv). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .m4v, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .md.

Feel free to ask in #community-meta if you think this is a mistake.

gaunt portal
digital rose
#

that white window at the beginning may be a widget you added

gaunt portal
#

For the one that may wonder, I managed to solve this by creating a QMainWindow using QT Designer and adding the Book class to that, instead of creating the window programatically

wispy oar
#

Is there some sort of panel object in PyQt5?

#

I want to just have some sort of blocks which I can change the colour of

#

I would be putting it inside a grid as part of a lift simulation

#

Also, how would I dynamically create these objects so that it changes depending on how many floors the user chooses to simulate?

#

Like, if there are 12, to create 12 floors etc

hollow fiber
#

hi anyone online?

wide stump
#

How can you customize the scroll bar of a QScrollArea in PyQt5?

sudden coral
#

What do you mean? It's clearly customising the bar not the area

wide stump
#

@sudden coral Nope.

#

It's the opposite.

#

It's customizing the area, not the bar.

#

The bar is left untouched.

sudden coral
#

But the selector is for the bar not the area 🤔

#

That doesn't make sense

wide stump
#

Yes that's my question.

#

How can I customize the bar INSIDE the scroll area?

#

Lol.

sudden coral
#

I can't reproduce

#

May I misunderstood you

#

I successfully customised the scroll bars

#

I just followed the examples in the docs

wide stump
#

@sudden coral Sorry my bad.

#

I've also tried using the same code from there but only worked in Qt designer.

#

Can you show me your code? Or did you use the designer?

sudden coral
#

Absolutely

#

I did not use the designer

#

I probably could, but it just seemed slower for testing purposes

wide stump
#

@sudden coral Are you there?

sudden coral
#

yes

devout dawn
#

What is the best user interface library?

rocky dragon
#

depends on what you want from it

devout dawn
#

I know there probably isn't but is there any async ones?

rocky dragon
#

Most come from other languages with an internal event loop

#

Think you can do some more native like integration with kivy but no idea there

devout dawn
#

You think in the future asyncio packages will be more popular?

rocky dragon
#

in general, probably; for GUI can't say because it's pretty hard work and like I said coming from other languages it's using its async or their own event loop

#

you can still hook into that but it'll be harder than just creating objects and getting nice coros directly

proven basinBOT
wide stump
sudden coral
#

Your style only affects the horizontal scroll bar, not the vertical

wide stump
#

Ohhhhhhhh

#

Fuck.

#

It's working, thank you.

mighty rock
#

Question about the Canvas element in tkinter, Python 3.8.0.
Problem: canvas.itemcget(ID, "fill") returns an empty string.
The ID is an ID of a square in a grid, which has been clicked on by a mouse.
I also checked the ID and it is indeed correct accordingly to the mouse position.
The squares from the canvas do not get deleted in any way.

mighty rock
#

Case closed, I found a solution that works.

hollow fiber
#

hi anyone online?

sudden coral
#

If you need help just ask your question directly

sleek raptor
#

Does anyone know how I can copy and paste the link of a canva profile picture I made? I want to add it to my embed bot

dusky moth
#

anyone else getting problems with tkinter widgets strobing when switching interfaces? Like, I'll have a menu interface, then I'll navigate to a login interface by destroying every widget on screen and then creating the login interface, but the buttons on that interface blink white for a split second which is really annoying

dim basin
#

can I ask here questions?

alpine blaze
#

yes

#

make sure to tell us what framework you use

dim basin
#

Thanks. I'm using tkinter. I tried to do it in many ways, but the there are always so many problems. I'm creating a simple text editor for a language I created. The basic things that I want to include in the root windows are:

#
  1. The width of the root window is the width of the screen and the height of the root window is the height of the screen (this part I already manged to do)
#
  1. The root window will have a menubar on top (this part I already managed to do)
#
  1. The bottom of the root window will have a status bar (could be a text widget) - this part I didn't try to create yet
#
  1. Most of the area of the root window will be divided into two parts (This is the part that I tried to work on for a long time but had many problems). The two parts will be to Frames, one on the left and one one the right. The one on the left will be wider than the one on the right - I would like it to be something like 0.6 of the screen width and the right frame to be 0.4 of the screen width, but that something that I would like to be able to easily change I would like to. Inside each of this frames I would like to put a Text widget that will take all of the frame area. In addition, I would like to add a scrollbar widget to the right of both of the Text widgets. In addition I would like to add line numbers to the left of the left Text widgets (I saw someone that that showed how to do it in a stack exchange post, I can send the link if it's needed, it may requaire another Frame).
#

So, if you have some suggetstions on how to go about it, it could help.

alpine blaze
#

well, i didn't do any tkinter in a literal decade, if it was with kivy i could certainly help, but maybe someone else will.

dim basin
#

Thank you anyway. I will wait and see if someone else could help.

covert glen
#

Hello every one, just a couple of questions.

#

What are the frameworks out there for creating UI on python and do you recommend some of them?

alpine blaze
#

pyqt/kivy/tkinter/wxpython/pygi (for gtk) and quite a few others

#

i'm biased towards kivy, as i find it more fun to use and allowing for more freedom, and portability to android/ios is a pretty strong point imho, but it's certainly less integrated on desktop, and does suffer from some limitations, so there are cases where that's not what you want to use.

#

and also, i'm a contributor to it

#

i would say pyqt is certainly the best alternative, when kivy is not what you want, pyqt certainly is

#

(pyqt or pyside, they are almost the same thing)

covert glen
#

Thanks for the response🤘

alpine blaze
#

yw

digital rose
#

i have to decide what ui is better

#

Kivy or Tkinter?

real jolt
#

anything is better than tkinter

#

depends what you need it for

digital rose
#

android things

real jolt
#

kivy

alpine blaze
#

well, not much choice if you want to do android things, i mean, toga/beeware is a thing, but as far as i know it's really far from production ready, so kivy is pretty much your only option.

#

but i hope you'll enjoy it as much as i do 🙂

stiff geyser
#

I'm working on a small program that will have sliders that interact with an images pixels in real time. Right now, I'm using pillow to alter the pixels as needed however, I'm kind of lost on how I would pair pillow with a UI library to display the changing pixels in real time. I've tried tkinter and it's extremely laggy when updating the image (my code wasn't that great either tbh). Would anyone have any suggestions on how to proceed?

tropic bridge
#

Tkinter is pretty basic afaic. If your program is simple and doesn't need to look flash I guess it does the job but if the GUI is substantive I'd look into other options

#

If you're building for Linux maybe look into GTK or Qt?

mighty rock
#
# Python 3.8.0
# tkinter
text.get("insert linestart", "insert lineend")

returns an empty string even though there is text in the current line of typing...

dim basin
#

Is there anyone here that knows tkinter and can help me with my question?

real jolt
#

!ask

proven basinBOT
#

Asking good questions will yield a much higher chance of a quick response:

• Don't ask to ask your question, just go ahead and tell us your problem.
• Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
• Try to solve the problem on your own first, we're not going to write code for you.
• Show us the code you've tried and any errors or unexpected results it's giving.
• Be patient while we're helping you.

You can find a much more detailed explanation on our website.

dim basin
#

Thanks. I'm using tkinter. I tried to do it in many ways, but the there are always so many problems. I'm creating a simple text editor for a language I created. The basic things that I want to include in the root windows are:
@dim basin

#
  1. The width of the root window is the width of the screen and the height of the root window is the height of the screen (this part I already manged to do)
  2. The root window will have a menubar on top (this part I already managed to do)
  3. The bottom of the root window will have a status bar (could be a text widget) - this part I didn't try to create yet
    Michael NovakYesterday at 2:56 PM
  4. Most of the area of the root window will be divided into two parts (This is the part that I tried to work on for a long time but had many problems). The two parts will be to Frames, one on the left and one one the right. The one on the left will be wider than the one on the right - I would like it to be something like 0.6 of the screen width and the right frame to be 0.4 of the screen width, but that something that I would like to be able to easily change I would like to. Inside each of this frames I would like to put a Text widget that will take all of the frame area. In addition, I would like to add a scrollbar widget to the right of both of the Text widgets. In addition I would like to add line numbers to the left of the left Text widgets (I saw someone that that showed how to do it in a stack exchange post, I can send the link if it's needed, it may requaire another Frame).
    So, if you have some suggetstions on how to go about it, it could help.
wide stump
#

How to return func value from a QThread?

#

Let's say I subclass QThread class like this ```python
class AThread(QtCore.QThread):

def __init__(self, func, *args, **kwargs):
    QtCore.QThread.__init__(self, *args, **kwargs)
    self.func = func
    self.args = args
    self.kwargs = kwargs

def run(self):

    return self.func(*self.args, **self.kwargs)
#

That won't work and it'll say TypeError: invalid result from AThread.run()

rocky dragon
#

What are you trying to do?

#

run should not return anything, use signals for communicating your results

wide stump
#

@rocky dragon I wanna run func() in a QThread by calling AThread, and then get the return value

#

suppose the func is like this

def func():
  return_value = 'return'
  return return_value```
digital rose
#

What are some basic user interfaces, I just want an all white text box

wide stump
#

Oh my god, I've come up with an idea, which is running the Start class (the one that starts multi threading) in another thread to avoid blocking the mainloop while waiting for return results from threads, and this is what I got

#

This is so fucking dumb

stiff geyser
#

tkinter is basic

#

and its already in python so

digital rose
#

Ok thank you

wispy oar
#

For example, if I enter the values of 10, 5, 5, 5, it will still use the defaults of 10, 0, 0, 0

#

I've returned these values from run_sim(), so I'm unsure why it doesn't work

proper glade
#

you use slots/signals to get return values out of QThreads

#

set up a variable, set its value to a result inside run, then attach a slot to the qthread's finished signal

#

finished will be emitted automatically once run is completed

#

you could also set up your own signal on the qthread and send the result out through the signal itself

wide stump
#

@proper glade

#

Give an example

#

I tried subclassing QThread as I said ```python
class AThread(QtCore.QThread):

def __init__(self, func, *args, **kwargs):
    QtCore.QThread.__init__(self, *args, **kwargs)
    self.func = func
    self.args = args
    self.kwargs = kwargs

def run(self):

    return self.func(*self.args, **self.kwargs))
#

That won't work TypeError: invalid result from AThread.run()

#

I tried connecting the finished signal python t = AThread(self.myfunc, self.myarg); t.start() t.finished.connect(lambda: return t) # That didn't work, How do I return here

wispy oar
#

Yeah sorry, I don't really understand how I would do that

#

I've never used QThreads

wide stump
#

Dealing with a mainloop is so stupid

wispy oar
#

Is there perhaps a simpler workaround, or would it be much better to do it this way?

#

Like, I was considering just saving the values to a list

#

And then perhaps the values can be loaded from the list

rocky dragon
#

you transfer the result through a signal

#
from time import sleep as do_stuff
from PyQt5 import QtCore

class Thread(QtCore.QThread):
    result_signal = QtCore.pyqtSignal(str)

    def run(self):
        do_stuff(0.1)
        ...
        self.result_signal.emit("payload")
        app.quit()

app = QtCore.QCoreApplication([])
a = Thread()
a.result_signal.connect(print)
a.start()
app.exec()
#

or if going through finished, you save it to an instance variable and connect finished to something that handles it with loading the value from that variable

#

no linking to returns

wide stump
#

@rocky dragon What will emitting do

#

I don't quite understand signals

rocky dragon
#

They're fundamental for working with qt

#

it calls the linked callable with what you emit

wide stump
#

I know about clicked.connect signals lol

#

Oh

#

So that emit will print payload?

rocky dragon
#

because they work within the c++ event loop you must have an app running and a signature with what you emit on creation

#

yes

wide stump
#

So this will work then right return self.result_signal.emit("payload")

rocky dragon
#

no return

#

just emit and connect that signal to a callable that handles it

#

run shouldn't return or only return None to stop execution

wide stump
#

So I just assign that emit method to a variable?

rocky dragon
#

Am I assigning anything up there to emit?

wide stump
#

But I wanna get the resultt

#

Not print it

rocky dragon
#

you connect it to something that handles what you emit

wide stump
#

A function?

#

How do I do that

#

example please

rocky dragon
#

yes, a callable. So a func, method or a class with call

wide stump
#

Ohh nvm

rocky dragon
#

you can call the func you wanted to return, and then emit its result to whatever you wanted to do with what you returned

proper glade
#

with regards to finished, you have to set up a separate variable somewhere else, set it to something inside run and then use that variable to access the result once finished is emitted

#

so e.g.

class WorkThread(QThread):
  def __init__(self):
    super.__init__()
    self.result = None

  def run(self):
    self.result = some_stuff

Then later on:

thread = WorkThread()
thread.finished.connect(lambda: print('Result of work:', thread.result))
wide stump
#

@proper glade Yeah dude I think I've tried that

#

if self.result = a_function and if I wait for thread.result() later on

#

It'll block the mainloop while waiting

proper glade
#

that's not what you showed in your snippet.

wide stump
#

I know I'm sorry I tried a lot of stuff that's why I'm asking here

#

So if I run it like this ```python
class AThread(QtCore.QThread):

def __init__(self, func, *args, **kwargs):
    QtCore.QThread.__init__(self, *args, **kwargs)
    self.func = func
    self.args = args
    self.kwargs = kwargs

def run(self):

    self.que = que
    self.result = self.func(*self.args, **self.kwargs))
And then call it ```python
thread = AThread()
result = thread.result # I think this'll block the mainloop
proper glade
#

this is not the same thing

#

and that assignment won't block anything

wide stump
#

But self.result will run that function

proper glade
#

look at my snippets again, you have to use thread.result inside a callback connected to the finished signal

#

But self.result will run that function
simply accessing self.result isnt going to run anything

wide stump
#

Oh okay

#

How do I get it after that

#

thread.finished.connect(lambda: print('Result of work:', thread.result))

proper glade
#

it's right there in thread.result

#

you can do whatever you want with it there

#

inside that callable

wide stump
#

How do I get it out of the callable

#

Cause if I add python result = thread.result print(result) after that it'll probably print None or something like that

proper glade
#

something like this, since you can't do assignments inside lambdas

some_value = None
def callback(value):
    some_value = value
thread.finished.connect(lambda: callback(thread.result))

not much point to this though

wide stump
#

Alright that makes sense I guess

proper glade
#

you might need a global some_value or nonlocal some_value at the top of the callback function

#

to fix scoping issues

wide stump
#

Yeah got it thank you

gaunt portal
#

Hi, how can I implement a cellDoubleClicked signal (like the one in QTableWidget), when using a QAbstractTableModel inside a QTableView?

proper glade
#

@gaunt portal QTableView, by virtue of being a child of QAbstractItemView, has a doubleClicked signal

gaunt portal
#

Ok, I'm not sure how to send the signal, I'll show some code

proper glade
#

the signal gets sent automatically

#

when you double click an item

#

it's built in

#

you just gotta connect stuff to it

gaunt portal
#

    def __init__(self, con, cur, students_ui, student_dialog, add_borrow_dialog):
        super(Students, self).__init__()

self.table = QTableView()
        self.verticalLayout.addWidget(self.table)

self.insert_data(data)
def insert_data(self, data):

        self.model = TableModel(data)
        self.table.setModel(self.model)```
#

This is the widget that holds the table view

#

    def __init__(self, data):
        super(TableModel, self).__init__()
        self._data = data
        
    def data(self, index, role):
        if role == Qt.DisplayRole:
            return self._data[index.row()][index.column()]

    def rowCount(self, index):
        return len(self._data)

    def columnCount(self, index):
        if self._data == []:
            return 0
        return len(self._data[0])```
The table model
#

You mean I should send the signal inside the TableModel class, but I want to connect it to a function in the Student class

proper glade
#

what i mean is you don't have to implement or emit it yourself

gaunt portal
#

Ok, I got your point, I read the docs

#

I'm asking now how I should use it

proper glade
#

same as you would any other signal

#

connect a callable to it

gaunt portal
#

but the callable lives in the Student class, and the signal is sent inside the TableModel class

proper glade
#

e.g.
self.table.doubleClicked.connect(lambda index: print(index))

gaunt portal
#

yes, but the scope wil not let me do this

proper glade
#

the signal is emitted by the treeview, not the model

#

tableview*

#

it belongs to the tableview

gaunt portal
#
class Students(QWidget):

    def __init__(self, con, cur, students_ui, student_dialog, add_borrow_dialog):
        super(Students, self).__init__()

self.table = QTableView()
        self.verticalLayout.addWidget(self.table)

self.insert_data(data)
def insert_data(self, data):

        self.model = TableModel(data)
        self.table.setModel(self.model)
def open_dialog(self, row, column):

        student_id = self.table.item(row, 0)
        dlg = StudentDialog(self.con, self.cur, student_id.text(), self.student_dialog, self.add_borrow_dialog)
        dlg.exec_()``` 
So I want to call the open_dialog func
#

And inside the TableModel

#

    def __init__(self, data):
        super(TableModel, self).__init__()
        self._data = data
        self.table.cellDoubleClicked.connect(self.open_dialog)
        
    def data(self, index, role):
        if role == Qt.DisplayRole:
            return self._data[index.row()][index.column()]

    def rowCount(self, index):
        return len(self._data)

    def columnCount(self, index):
        if self._data == []:
            return 0
        return len(self._data[0])```
#

I would need to do something like this

#

but the open_dialog func does not belong to the tablemodel

proper glade
#

why do you need to connect it inside the model

#

you already have the tableview there in the Students class

#

open_dialog belongs to the Students class

gaunt portal
#

Oooh, I got the inheritance wrong

#

Ok, let me try

#

Yep, works, I get the index of the cell that I click on

#

I can't find how to get the data from a given cell, when I know the coordinates, I'm searching the docs for 10 mins

proper glade
#

QModelIndex has a data method

gaunt portal
#

Ok, and I want to get the data of the first column, no matter where I click on the row, do I need to create another qmodelindex?

proper glade
#

qtablemodel probably has a method for getting the qmodelindex for a given coord

#

so yea same row, column 1

#

imo you should just store the data list in Students

#

so you can access it directly in the callback

gaunt portal
#

damn, right

#

and then I just call .data() for that index

#

Uh, stuck again

#
        student_id = self.table.indexAt(QPoint(index.row(), 0))
        print(student_id.row())
        dlg = StudentDialog(self.con, self.cur, student_id.row(), self.student_dialog, self.add_borrow_dialog)
        dlg.exec_()```
#

student_id.row() always returns 0

#

But index.row() will return the row that I clicked on

#

I'm not sure what's wrong

proper glade
#

oh right indexAt is asking for literal content coordinates

#

not grid cell coordinates

#

@gaunt portal

inland notch
#

can you change a bool with root.after in tkinter?

gaunt portal
#

@proper glade , I managed to solve this, by calling self.model.index(cell_index.row(), 0).data for the QTableModel, where cell_index is the cell that I click on

#

This returned the corect data that I needed

#

Thanks for the help

digital rose
#

I need suggestion should I use python for gui or something else like electron

I need best ui/ux like we have in js and css but should be fast not like vs code

proper glade
gaunt portal
#

I tried that, but it always returned an Invalid Index (-1,-1)

#

Maybe I implemented it wrong, idk

#

But I'm happy that it works with model.index()

gaunt portal
#

@digital rose If you're familiar with javascript, try electron (discord is built using electron)

#

Otherwise, there are python libraries like pyqt5, kivy or tkinter, each with advantages and disadvantages, just google about them and see what suits you

steel pendant
#

hi all, i am trying to build an interface similar to this one, where the user can drag-to-create line segments connecting points on a fixed grid, select the line segments afterwards and "color" them, etc...is this something that could be easily achievable in pyqt5? or should i look at a different library?

spare verge
#

Would anyone here happen to be very familiar with the inner machinations of qt

#

Why does cursor.insertBlock add a new li to my list, but calling cursor.createList (or cursor.insertList) creates the new ol outside the current list

spare verge
#

ok never mind

#

qt is just stupid

gaunt portal
#

@steel pendant If you know c/c++, you can achieve that by using the SFML library, pyqt is kinda for making GUIs, rather than animated apps

#

Or you could use pygame

steel pendant
#

interesting, yea i do know a bit of c++. was also considering doing this with svgs and javascript

#

thanks for the idea @gaunt portal

proper glade
#

this can be fairly easily done with a qgraphicsscene/view @steel pendant

#

there's even a built in selection mechanism for qgraphicsitem objects

steel pendant
#

oh cool, i will check that out for sure @proper glade !

#

thanks for the tip

candid eagle
#

can anyone help me with pyqtgraph?

#

im using Qt Creator to make a form.ui then use pyuic5 to make a form.py which i can then use in my program, ive tried following the pyqtgraph guides, my issue is i seem to have 2 graphs, the one im updating and using is really small and the one im not using is the right size, any ideas to only have one graph and fix the size?

#

so far in my def __init__(self): ```py
self.graphWidget = pg.PlotWidget(self.form.temperatureGraph)
#self.setCentralWidget(self.graphWidget)

    self.x = list(range(24))  # 24 time points
    self.y = [randint(0, 100) for _ in range(24)]  # 24 data points

    self.graphWidget.setBackground('w')

    pen = pg.mkPen(color=(255, 0, 0))
    self.data_line = self.graphWidget.plot(self.x, self.y, pen=pen)

    self.timer = QtCore.QTimer()
    self.timer.setInterval(2000)  # Update every 2 seconds
    self.timer.timeout.connect(self.update_plot_data)
    self.timer.start()```and then ```py
def update_plot_data(self):
    self.x = self.x[1:]  # Remove the first y element.
    self.x.append(self.x[-1] + 1)  # Add a new value 1 higher than the last.

    self.y = self.y[1:]  # Remove the first
    self.y.append(randint(0, 100))  # Add a new random value.

    self.data_line.setData(self.x, self.y)  # Update the data.```
dim basin
wide stump
rocky dragon
#

setPlaceholderText

wide stump
#

Thank youu

wide stump
#

How to get cells count from a QGridLayout

digital rose
#

is there any library to make more customizable/cool GUI like discord's or any other application

#

i usually use tkinter

#

but is there any other library that creates more modern GUIs?

alpine blaze
#

did you look at Kivy?

#

in matter of customizable, i think it's pretty much the best 🙂

digital rose
#

is it hard?

#

you know im kinda a beginner

alpine blaze
#

hm, it does help if you are decently familiar with python and classes in it.

#

you can start simple, but as it gives you a lot of flexibility, it does help to really understand the basic ideas, or it feels like dark magic and hard to reason about

digital rose
#

ty man

sullen thunder
#

Anyone experienced with PyQt5 and Matplotlib? I am working on incorporating some graphs into my program and I am having trouble in a few way

  1. I have two graphs inserted as Figures onto a canvas. I have had trouble resolving the desire to refresh the graphs on command via a Pysignal/Pyslot method. Any ideas?
  2. I am working on inserting a Line graph into a Frame. However, I am using plt instead of fig, ax. Do I need to rewrite my code as fig, ax or is there a different method for inserting a plt plot? I have had issues shifting the plot from one method to the other while maintaining all the features i want. Such as fill between.

also, i do have code to share but was waiting for a response before dumping code

gaunt portal
#

@digital rose Discord is made using Electron, which uses javascript, html and css

sullen thunder
#

@gaunt portal I will take a read over that. I don't think I have come across that tutorial yet.

gaunt portal
#

The site is rather useful, it really takes you over the basics and going through some advanced stuff, like mvc and packaging your script

digital rose
#

ty @gaunt portal

wide stump
#

Can a widget have a multiple layouts

alpine blaze
#

@wide stump which framework? and precise what you mean by "multiple layouts", can you give an example of what it would allow you to achieve?

wide stump
#

PyQt

#

Basically I've set up a grid layout already of my program

#

And added all widgets there

#

But when an error happens I wanna show an error label

#

and I can't add that to the mainllayout cause it'll get auto sorted

#

I want the error frame to always appear in the center

#

And I can't use screenGeomtry to get the screen center and use it because if the user moves the window it'll look weird and stupid

#

I think i'll just put it in the center of the central widget

wide stump
#

How can I get the object name of the connected QWidget
self.optionCheckbox.clicked.connect(self.uncheck)

#

And use it in self.uncheck

gaunt portal
#

@wide stump How I see it, you could either put an empty QLabel widget, and when the error happens, set the text of that QLabel to whatever you want to show

#

Either open an error dialog, which seems more common, but it depends on what you want the workflow to feel like

#

Dialogs pretty much interrupt the flow

wide stump
#

Lol I did it without QGroupButton

self.optionCheckbox.clicked.connect(partial(self.uncheck, self.optionCheckbox.objectName()))

def uncheck(self, objname):

      checked = []
      for i in range(self.VLayout.count()):
          if self.VLayout.itemAt(i).widget().isChecked():
              checked.append(self.VLayout.itemAt(i).widget())

      for e in checked:
          if e.objectName() != objname:
              e.setChecked(False)```
gaunt portal
#

In PyQt5, I want to make sure that a QLineEdit always returns a numerical value (aka the user can't type characters in the box)

#

How can I do that

rocky dragon
#

I'd just use a spinbox

mighty rock
#

real quick: python 3.8.0 tkinter
if i know an image size and window size, can i know if it overlaps with its right border using windowsize+imagesize<windowsize?

rocky dragon
#

you can apply a regex to it but not needed here when we have spinboxes

gaunt portal
#

Oh cool, that's literally what I needed

#

Thanks

#

@mighty rock Why don't you just test that? (I'm not familiar with tkinter, but just make some tests and see if it gives you the result you want)

mighty rock
#

ok

gaunt portal
#

If it doesn't, ask here

wide stump
#

How to set minimum size of all widgets in a QVBoxLayout

rocky dragon
#

you can set min size of rows and columns

wide stump
#

@rocky dragon Sorry I meant QVBoxLayout, and how can I do that?

wind current
#

Can I ask my help for kivy here?

sudden coral
#

Yes

wind current
#

Thank you

#
from kivy.animation import Animation, Sequence, Parallel
from kivy.app import App
from kivy.clock import Clock
from kivy.properties import ListProperty
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label

global l1


class MySequence(Sequence):
    widgets = ListProperty([])
class MySequence(Sequence):
    widgets = ListProperty([])

    def start(self, widget):
        super(MySequence, self).start(widget)
        self.widgets.append(widget)

    def stop(self, widget):
        if widget in self.widgets:
            self.widgets.remove(widget)
        super(MySequence, self).stop(widget)

    def __add__(self, animation):
        return MySequence(self, animation)

    def __and__(self, animation):
        return MyParallel(self, animation)


class MyParallel(Parallel):
    widgets = ListProperty([])

    def start(self, widget):
        super(MyParallel, self).start(widget)
        self.widgets.append(widget)

    def stop(self, widget):
        if widget in self.widgets:
            self.widgets.remove(widget)
        super(MyParallel, self).stop(widget)

    def __add__(self, animation):
        return MySequence(self, animation)

    def __and__(self, animation):
        return MyParallel(self, animation)


class MyAnim(Animation):
    widgets = ListProperty([])

    def start(self, widget):
        super(MyAnim, self).start(widget)
        self.widgets.append(widget)

    def stop(self, widget):
        if widget in self.widgets:
            self.widgets.remove(widget)
        super(MyAnim, self).stop(widget)

    def __add__(self, animation):
        return MySequence(self, animation)

    def __and__(self, animation):
        return MyParallel(self, animation)
#
class TestApp(App):


    def __init__(self, **kwargs):
        super(TestApp, self).__init__(**kwargs)
        self.label = Label(text='label', size_hint=(None, None), size=(100, 500), pos=(400, 200))
        self.animation = MyAnim(pos=(200, 200), d=5)

    def animate(self, instance):
        self.animation.on_complete = self.completed

        # sequential
        # self.animation += MyAnim(pos=(400, 400), t='out_sine')

        # parallel
        self.animation &= MyAnim(size=(200, 300), d=5)

        Clock.schedule_once(self.another_anim, 1)

        self.animation.start(instance)

    def another_anim(self, dt):
        global l1
        self.animation.start(self.label)
        l1 = self.animation.widgets

    def completed(self, widget):
        print('Animation completed - animated Widget:', widget)
        Clock.schedule_once(self.check_anim, 2)

    def check_anim(self, dt):
        global l1
        print(l1)
        print(dt, 'seconds after Animation completed - animated Widgets:', l1)

    def build(self):
        fl = FloatLayout()
        button = Button(size_hint=(None, None), size=(100,50), pos=(0,0), text='click here', on_press=self.animate)
        fl.add_widget(button)
        fl.add_widget(self.label)
        return fl


if __name__ == '__main__':
    TestApp().run()
#

I have a list called l1 which contains self.animation.widgets when I print the value of l1 it prints [] but I need the objects which are animated in l1!

alpine blaze
#

Don't use a global, you can easily put l1 as a listproperty of your app to access it easily

gaunt portal
#

What library do I have to import to use a QStringList in PyQt5?

#

The docs says it lives in QtCore, but when I try to import it from there :```Traceback (most recent call last):
File "d:/Proiecte/Python/OLDI/src/main/python/mainmenu.py", line 3, in <module>
from PyQt5.QtCore import Qt, QDate, QPoint, QModelIndex, QStringList
ImportError: cannot import name 'QStringList'

rocky dragon
#

Why do you want it?

gaunt portal
#

To set the lables of a QTableView

rocky dragon
#

you don't have QStrings, QStringLists or whatever in the python api. They get converted to python types or converted from them

gaunt portal
#

Exactly, I want to convert from a python list to a QStringList

rocky dragon
#

passing a list of strings should work

gaunt portal
#

Oh, ok

rocky dragon
#

QStringList doesn't exist in pyqt

gaunt portal
#

Yeah, apparently I was looking on the docs of qt4

#

Ok I have a list of column names that I want to use to change the column lables in a QTableView

#

What can I use?

split tide
#

hey, im drawing many (200+) 2D designs. its like a tessellation if youre familiar. they look like grids but each cell updates based on its neighbor

#

ive used tkinter before, but using it in an object oriented way makes it reallyyyyyy slow. and each cell's state must be saved for the program to update

gaunt portal
#

woah, that's cool

split tide
#

any suggestions on libraries/graphics engines?

gaunt portal
#

both PyQt5 and kivy are object-oriented

split tide
#

gotcha

#

the backend is sups simple: you start with an array like [0,0,1...] to represent every cell as dead or alive. then you have a rule, like if a 0 is surrounded by other 0's it stays 0. you make more rules and then you update the array. i just am not sure of how to draw it in python

sullen thunder
#

Hey JustAndy,

thank you for the previous link about redrawing line graphs. Do you know how to apply it to a pie graph? most of what they have in the tutorial seems to apply. But it doesn't seem to clear the graph.

sudden coral
#

@round hazel It's being saved in the selection attribute of the popup widget. Your main class has a reference to an instance of that widget in self.exPopup.

#

So self.exPopup.selection would get you that value.

round hazel
#

@sudden coral Thanks...but hmm, I'm getting AttributeError: 'searchPopup' object has no attribute 'exPopup' when I try to do something simple like

        y = self.exPopup.selection
        print(y)
sudden coral
#

That's supposed to be done in the main class, not the popup widget

#

It boils down to this ```py
class Main:
def init(self):
self.popup_instance = Popup()
print(self.popup_instance.selected)

class Popup:
def init(self):
self.selected = "hello, world!"

#

You need to access an attribute via an instance of the class

round hazel
#

Line 113 is where it's called.

#

Line 169 is the method in the class where it's created.

sudden coral
#

The error says that searchPopup doesn't have the attribute, which means self is a searchPopup. If it was in the main class it would say Ui_MainWindow 🤔

#

Oh, you're calling lookup from within the popup class

#

That's why self is the popup

#

Why are you doing that?

#

Do you want that behaviour i.e. for lookup to be called after clicked?

round hazel
#

Basically, it runs lookup based on a search inquiry. If it finds the result on its own, it runs "lookup" with the ID it found. Otherwise, it creates the popup with search results. If you select a result, it will get an ID that it should pass back into the main class and re-run "lookup" with the selected ID

sudden coral
#

I feel like using a QDialog would be better suited for this.

#

Or at least using signals and slots in some way so that your main class knows when the a selection was made

#

The main class should be responsible for calling the lookup, not the popup window.

#

So the popup can signal to the main class something was selected and that's it. The popup shouldn't need to know or care what the main window does with that info, as it's not the popup's job to be concerned with that. It's job is to display a list for a user to select a value.

round hazel
#

I originally was trying to use a qdialog but I didn't think it could have a list widget built into it so I abandoned that idea. It would be easier than a second class.

And I also thought about signals and slots but that's a bit more than I know how to do with PyQt at the moment. I've played around with them but haven't really grasped the whole concept even though it seems simple enough. You're right that either of those two options would be best. If I can figure out signal/slot I think that would work.

sudden coral
#

QDialog is convenient because it has some signals already built in and your main class could just connect to them

#

QDialog can have any widgets, including a list.

#

If you have more questions about it I can try to answer

round hazel
#

Ok well I appreciate the info you've given. I'll give QDialog a shot and see what I can do with that so I can abandon the second class.

sudden coral
#

Well it still should be a separate class

#

The dialogue window would be a separate window from the main window.

round hazel
#

Oh hmm. I guess I need to go back to the documentation then and try to figure this out. Didn't realize it would be such a daunting task to pass a single int, haha. I've given up on this project multiple times over the past few months because of this very reason.

sudden coral
#

Indeed I find the topic of inter-widget communication is a struggle for many beginners of the library.

#

There's probably a lot of bad ways to do it which are simpler 😄

round hazel
#

At this point, all I need is some simple hack job to make it work. This is really just a personal passion project to learn more about PyQt, and this is my last step to making it functional. What would YOU do in this instance to get that to work?

sudden coral
#

Me, given my experience, would make a QDialog. In your position, give me a moment to think about it.

#

But it's worth mentioning that if your goal is to learn PyQt then wouldn't you want to learn how to do things the right way?

#

QDialog is an opportunity for you to learn something new, if that is what you're after

round hazel
#

You're right, and I do like learning new techniques. I've just been working on it so long and the end is so close. But, you're right, I'll learn QDialog and try to make it work correctly.

sudden coral
#

Looking at examples really helped me learn this library. Maybe that a good learning method for you too.

round hazel
#

That's how I've been doing it. I've been deconstructing examples to learn how they work. That's how I learn best...taking a completed example and breaking it down.

sudden coral
#

I used QDialogs in this project of mine

#

It's not super well documented or high quality code cause it was a code jam and I had like a week

#

A thing to note is that I re-use dialogs rather than re-creating them, so my dialog classes sometimes have extra code to reset their state. You don't have to do it this way. Creating a new dialog is fine too.

round hazel
#

Hmm, I appreciate the help. I'll see what I can learn from that. One last quick question though. If I create the QDialog from the main class, as a separate method, what is the second class for then? All the other examples I've seen create the dialog within the main class.

sudden coral
#

You subclass QDialog to customise its UI and behaviour.

round hazel
#

Ah gotcha.

#

Wait but then wouldn't I be back to square one of having to send the result from that class back to the main class?

#

Or does QDialog have a built in signal for that?

sudden coral
#

Yes and yes

round hazel
#

Ok perfect. Thanks for all the help! I'll stop bugging you and go read haha

sudden coral
#

Well sort of, there's not a signal to retrieve a value per se, but there are signals for when the dialog is completed/closed, so you know the user is done choosing and its safe to retrieve the value now.

round hazel
#

Perfect!

round hazel
#

One final question. I'm just about there! I've got a QDialog working now, and I have it sending the accept signal, which outputs "1" as it should. How do I change this to send the int value back instead of just "1"? Relevant code:

# from main class
    def popup(self, results):
        self.popupsearch = searchPopup(results)
        self.result = self.popupsearch.exec()
        print(self.result)

#from dialog class
    def clicked(self, qmodelindex):
        self.item = self.listwidget.currentItem()
        self.row = self.listwidget.currentRow()
        self.selectionindex = self.results[self.row]
        self.selection = self.selectionindex.id
        self.accept()

I want the accept signal to send the value of self.selection

#

Scratch that! I figured it out. I used self.done(self.selection)

wind current
#

How to get objects that are animated in kivy?

alpine blaze
#

what do you mean?

#

there are animations, and there are widgets, and an animation can be applied to some widgets, until it's done

#

the animation knows which objects it's being applied to, but it's its internal state, i don't think you should rely on it, if you applied the animations to widgets, you should be able to keep track of which

#

@wind current

wind current
#

I did that my self

wide stump
#

How to change the PyQt file's icon?

rocky dragon
#

setWindowIcon on the app with a QtGui.QIcon object

slender shale
#

the background color (255,255,255) is drawing vertically off the screen instead of horizontally like I want it to

#

the code uses the screen size/play size to calculate the positioning of said background color, I could use some pointers to resources to fix this as I have no idea what to look for

dense whale
#
self.setCentralWidget(ImageWidget(surface))```
digital rose
#

Or at least they become so after one is true

gaunt portal
#

something like self.move(x,y) where (x,y) is the point where you want to move the widget

#

@digital rose What do you mean by 2 elifs are true? Does the app also run them?
Try to set a break point before the game_input func and run the app step by step in debugging mode, to see what if statement is executed

#

Does anyone know where to learn basic UI design, or how to make things look better in PyQt5?

digital rose
#

What break point?

#

There are 1 if and 2 elifs in the func

#

and all of them get run

#

Oh I was wrong

#

same if is getting run 3 times

#

fixed it

willow prism
#

stupid question but how can I use javascript to code a GUI but not have it open in a webpage but rather like a window with a x minimize and expand button. I want to make the frontend for my python code but don't want to use tkinter to do it

sudden coral
#

There are other options for GUIs besides tkinter that are in Python

#

It sounds like you're thinking of Electron but with a Python backend. Maybe that could work but it sounds complicated to me. I'm not a JS dev so what do I know.

#

Seems like the two languages wouldn't interface well

willow prism
#

oh its not just as simple as assigning functionality to javascript elements?

sudden coral
#

No, unless your Python app is like a REST API or something.

rough mauve
#

hello

#

got good indications for starting tk interfaces?

sullen thunder
#

JustAndy (didn't' want to ping you, but hope you see this)

Thank you again for the direction to the tutorial. I was able to utilize it to build my desired application. My nested pie graphs due now update upon receiving the proper signal.

I don't think i fully understand why the tutorial creates its own canvas class. I think, what it is doing is turning the Matplotlib canvas into a PyQt5 widget that can be interacted with via the FigureCanvasQTAgg object.

gaunt portal
#

From learnpyqt :

Plots from Matplotlib displayed in PyQt5 are actually rendered as simple (bitmap) images by the Agg backend. The FigureCanvasQTAgg class wraps this backend and displays the resulting image on a Qt widget. The effect of this architecture is that Qt is unaware of the positions of lines and other plot elements — only the x, y coordinates of any clicks and mouse movements over the widget.

#

So Qt(pyqt5) interprets the FigureCanvasQTAgg as a image

#

Which you can apply simple qt func on, OR use the functions provided by Matplotlib

alpine blaze
#

It's not great

rain prawn
#

is kivy developer 😄

lucid wraith
#

Tkinter is useful, but the documentation can be hard to find

flint river
#
<input ng-keyup="$event.keyCode === $ctrl.keyCodes.enter &amp;&amp; $ctrl.getMember($ctrl.keyword)" ng-model="$ctrl.keyword" class="form-control input-field ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched ng-empty" type="text" placeholder="Search Members" maxlength="120">
#

how do i get the element of this?

#

(its a searchbar)

digital rose
#

wdym element

#

like are you trying to pull this from a html document?

hallow mantle
#

stupid question but how can I use javascript to code a GUI but not have it open in a webpage but rather like a window with a x minimize and expand button. I want to make the frontend for my python code but don't want to use tkinter to do it
@willow prism you can use pyqt5/pyside2 webengine and communicate front and back ends using webchannels. I’ve done a project using that architecture

digital rose
#

Can I use modules inside a function?
Because I used one inside a function and it's not working instead it's giving me an exception.

cyan stirrup
#

!e ```py
def num():
import random
return random.randint(0,10)
num()

proven basinBOT
#

Sorry, but you may only use this command within #bot-commands.

cyan stirrup
#

tldr; yes u can

digital rose
#

I mean if that module wasn't mentioned inside a function but outside of it.
Will it still work?

cyan stirrup
#

ofc

latent mortar
latent mortar
#

I did it with Pygame :P

digital rose
#

Could you use module 'requests' in a GUI?
Because 'requests' gets a specific information from the chosen API.

#

And I think GUI can't interact with Internet connection, can they?

sudden coral
#

GUIs can interact with the internet

#

Yes, requests module can be used in a GUI.

#

Though you may want it in a separate thread so long requests don't seize your application.

bitter merlin
#

I think the best python canvas is probably QGraphicsView in pyqt5

alpine blaze
#

i must say kivy has a very powerful canvas too, it's basically opengl, but in easy mode

hexed vine
#

opengl and easy are two words that often shouldn't live together lol

latent mortar
#

@bitter merlin can it make live animations like those ^?

latent mortar
#

There are lines and circles in my py game

#

and i want all the lines to be above the circles

#

like no pixel of circle should be seen over a line

#

how will i be doing this?

#

in simple terms

#

i want no circle to overlap a line

#

like if lines and circles overlap i want line to be seen

latent mortar
#

ping me if you answer

elfin stirrup
#

@latent mortar what library

latent mortar
#

PyGame @elfin stirrup

elfin stirrup
#

ok

alpine blaze
obtuse thistle
#

just keep the lines and circles in different groups

#

with the graph program i'm working on, i keep node and edge instructions separate like this:

        self._edge_instructions = CanvasBase()
        with self._edge_instructions:
            self.edges = {edge: Edge(edge, self) for edge in self.G.edges()}
        self.canvas.add(self._edge_instructions)

        self._node_instructions = CanvasBase()
        with self._node_instructions:
            self._source_color = Color(*SOURCE_COLOR)
            self._source_circle = Line(width=SOURCE_WIDTH)
            self.nodes = {vertex: Node(vertex, self) for vertex in self.G.vertices()}
        self.canvas.add(self._node_instructions)