#user-interfaces

1 messages ยท Page 39 of 1

digital rose
#

@lethal rain well, the program says that the HOST variable (as well as the PORT I suppose) are undeclared (unknown) inside the kv file.
usually you create and set these variables in a widget class or in the App, then access them in kv using self., root. or app.

lethal rain
#

oh

rotund cove
#

hello

#

anyone know if there is a way to view a crash report or an error message when pyqt5 crashes?

lethal rain
#
  TypeError: can only concatenate str (not "method") to str
   File "D:\python\lib\site-packages\kivy\lang\builder.py", line 249, in create_handler
     return eval(value, idmap), bound_list
   File "D:\onedrive\python\socketio\signin.kv", line 153, in <module>
     text: "Connected to 'Server: " + self.HOST + ":" + self.PORT + "'"
 
   File "D:\python\lib\site-packages\kivy\lang\builder.py", line 692, in _apply_rule
     rctx['ids'])
   File "D:\python\lib\site-packages\kivy\lang\builder.py", line 254, in create_handler
     cause=tb)
 

Process finished with exit code 1

;-; cmon i though it would work ;-;

lethal rain
#

ok tried a new way

################ Connection ##################

    def HOST(self):

        conn = self.ids.conn
        port = 8080
        conn.text = f"Connected to 'Server: {socket.gethostbyname(socket.gethostname())}:{port}'"

    ##############################################

it shows main window but there is 0 text :/

alpine blaze
#

is HOST() called?

lethal rain
#
################ Connection ##################

    def host(self):

        conn = self.ids.conn
        port = 8080
        conn.text = f'Connected to Server: {socket.gethostbyname(socket.gethostname())}:{port}'

    ##############################################


BoxLayout:
        size_hint_y: None
        height: 50
        canvas.before:
            Color:
                rgba: (.102,.153,.190, 1)
            Rectangle:
                size: self.size
                pos: self.pos
        MainLabel:
            id: conn
            text: ""
            bold: True
            size_hint_x: .9
            markup: True
            spacing: 3
        ExitButton:
            text: "Disconnect"
            bold: True
            size_hint_x: .1

@alpine blaze

alpine blaze
#

that doesn't answer the question, unless the answer is No

lethal rain
#

idk what you mean tho i put it in mainLabel class

alpine blaze
#

i don't the host function called anywhere, MainLabel contains the conn id that host uses, that's good, but no use if host() is not called

tribal path
#

error doesnt match those snippets btw

alpine blaze
#

i guess there is no error now, just not the expected result either

#

which is totally normal if the host function is not called anywhere, the label is not going to be updated

#

you want to call it after the connection is done, i guess

lethal rain
#

@alpine blaze i got it working

rotund cove
#

does subplot2grid not function with pyqt5

digital rose
#

@worn viper

from kivy.core.window import Window
Window.size = (500, 300)
Window.borderless = True
#

but in the next step (I guess) you will want to create your own window title area
with ability to move kivy app window dragging it.
but such a window 'moving' will not be smooth, at least on Linux (it seems due to sdl)

lethal rain
#
BoxLayout:
        cols:1
        BoxLayout:
            cols:2

            Label:
                text: "Server 1"
                text_size: root.width - 500, root.height - 140
                valign: "top"
            Button:
                pos_hint: {"y":0.9, "x":0.3, "left":1}
                size_hint_y: None
                size_hint_x: None
                halign: "left"
                text: "Terminal-1"
                font_size: 20
                height: 25
                width: 120
            Button:
                pos_hint: {"y":0.9, "x":0.3, "left":1}
                size_hint_y: None
                size_hint_x: None
                halign: "left"
                text: "Start"
                font_size: 20
                height: 25
                width: 120
            Button:
                pos_hint: {"y":0.9, "x":0.3, "left":1}
                size_hint_y: None
                size_hint_x: None
                halign: "left"
                text: "Reset"
                font_size: 20
                height: 25
                width: 120
            Button:
                pos_hint: {"y":0.9, "x":0.3, "left":1}
                size_hint_y: None
                size_hint_x: None
                halign: "left"
                text: "Stop"
                font_size: 20
                height: 25
                width: 120```

trying to get my buttons to left with the text but seems to be having none of it ;-;
alpine blaze
#

2 solutions, either make sure the BoxLayout is exactly the width it needs to be, or add a Widget as the last children, that will take all the remaining space and push the previous widget to the left

candid eagle
#

anyone used pyqt5? im editing on the desktop then pushing it to my git then pulling on to the pi

#

my issue is the text sizes are different on the pi compared to the pc side

#

also you may notice the tabs are overlapped by the Pause and Refresh Log buttons

#

not sure how i resolve this issue without making everything look out of place on the desktop side

rocky dragon
#

are you using OS styles? that might be an issue

candid eagle
#

i think so

#

new to all this so not 100% sure on anything lol

candid eagle
#

okay so i tried QApplication::setStyle("windows");

#

but it didnt seem to do anything

#

i also tried QApplication::setStyle("fusion");

candid eagle
#

thinking thats not where i should be adding that line

rocky dragon
#

could just add it to your python code

candid eagle
#

hmm but its c++ and no idea where to add it

candid eagle
#

solved where to change the style for the app but still hasnt done anything with the sizes

sudden coral
#

Have you considered manually setting the font size and fontface?

#

It's probably not even the size that needs to change, just the font face

#

Some fonts look larger than others at the same size even

proper glade
#

have you turned up the scaling setting?

candid eagle
#

havent touched any scale settings that i can think of

#

tried changing the font

#

it changed it pc side so i readjusted then pushed it to the Pi and buttons still overlap

lost patrol
candid eagle
#

im currently looking into kivy as i was hoping to make an app that will work across PC, Rpi, Android

#

but i cant even get the same scripts to run in pycharm but i probably havent set it up properly

alpine blaze
#

probably yes, have you made sure you use the same python in pycharm as the one you install kivy for? @candid eagle

#

(can you run the kivy app from command line for a start?)

candid eagle
#

that just links to the official website guide which is what ive tried to follow

alpine blaze
#

well, i just installed pycharm trial, and recorded myself starting a new project and running kivy in it, i had to look around a bit so it took a few minutes, but just the time to compress the video, and i'll be able to share it

#

(obs produces a 100MB file, and i know ffmpeg will convert it to something like 10MB)

#

i though i had a valid license that they shared to us kivy devs, but apparently that expired in 2015, didn't think it was that far back ๐Ÿ˜† never used it

#

less than 5MB ๐Ÿ˜„

#

it's 5mn long, sorry i wasn't really sure how to do things

candid eagle
#

sorry only just seen this, ive managed to get the example to run

#

now i gotta try recreate what i did in QT Creator

alpine blaze
#

no worries, i wanted to check how hard it was anyway, but that doesn't seem too bad

candid eagle
alpine blaze
#

heh, i was actually wondering earlier how hard it would be to create a kivy theme that looks like that

#

people seems to complain a lot about the default look and feel

#

i don't really need to take on more projects though i have already too many orphans or neglected ones

#

๐Ÿ˜ฌ

candid eagle
#

ive been doing this one for over a year in total but ive had a few different versions/attempts at it lol

#

i barely know what im doing but slowly making progress here and there

sudden coral
#

This looks cool

#

Is it going to be used for an actual aquarium or is it just a scenario you came up with?

candid eagle
#

yeah for my Aquarium

candid eagle
#

trying to install Kivy Designer but it says Microsoft Visual C++ 14.0 is required, when i click the link it provides it takes me to the visual studio site, i already have VSC installed so im confused as to what i need

digital rose
#

kivy designer is deprecated unfortunately @candid eagle

candid eagle
#

has it been replaced by anything?

digital rose
#

Not yet.
But I'm sure itโ€™s only a matter of time. In any case, I would advise to take a closer look at this framework as well

candid eagle
#

What framework? Sorry I'm a complete beginner to all this so dont know all the jargon etc

digital rose
#

@candid eagle I mean kivy framework:)

alpine blaze
#

yeah, don't use designer, it's broken and nobody is working on it

#

people who learn to use kivy, and especially kvlang seems not to see a lot of need for a designer after a while

#

(visual studio โ‰  visual studio code btw, and to build cpython extensions, you need visual studio, but outside that, you probably don't)

candid eagle
#

Hmm does anyone know of a cross platform gui that has a designer? I want to make an app for windows, android, and pi

#

Wanted a designer so I can try replicating what I have already made with qt

cedar flume
#

hello

candid eagle
#

only reason im trying to move away from qt is i had issues with the layout on another os from what i designed it on

cedar flume
#

@candid eagle buddy i suggest you to try pysimplegui

#

im stuck on it

candid eagle
#

i previously used guizero

cedar flume
#

i wanna make a calculator but buttons doesn't seem to display in the window

candid eagle
#

what language you using?

cedar flume
#

python

candid eagle
#

dur i should have got that frompysimplegui

cedar flume
#

did you use pysimplegui before?

candid eagle
#

post your code or a link and if i cant help hopefully someone will see it

#

brb just gonna grab a bite to eat

cedar flume
#

import PySimpleGUI as sg

layout = [
[sg.Input(text_color=('Red'),background_color=('Green'),key='input')],
[sg.Button('1',size=(8,4),button_color=('white', '#3c0545')), sg.Button('2',size=(8,4),button_color=('white', '#3c0545')), sg.Button('3',size=(8,4),button_color=('white', '#3c0545')),],

[sg.Button('3',size=(8,4),button_color=('white', '#3c0545')), sg.Button('4',size=(8,4),button_color=('white', '#3c0545')), sg.Button('5',size=(8,4),button_color=('white', '#3c0545')),],

[sg.Button('7',size=(8,4),button_color=('white', '#3c0545')), sg.Button('8',size=(8,4),button_color=('white', '#3c0545')), sg.Button('9',size=(8,4),button_color=('white', '#3c0545')),],

[sg.Button('-',size=(8,4)), sg.Button('=',size=(8,4),key='igual'), sg.Button('+',size=(8,4),key='mas')],
[sg.Button('clear',size=(8,4))]
]
window = sg.Window("just a window name",layout,size=(500,500))
keys= ''

while True:
event, values = window.Read()
if event is None:
break
if event in '123456789':
keys= values['input']
elif event is 'clear':
keys = ''
window.FindElement('input').Update(keys)

candid eagle
#

uh edit your post and wrap your code with 3 ``` py with another 3 at the end

cedar flume
#

let's go to pm

candid eagle
#

think theres rules against that

lost patrol
#

haven't used it yet

#

ah idk

alpine blaze
#

i don't think pysimplegui has a designer, or that it can easily replicate the previously described interface

#

but anyway

#

designers give a false impression of ease

#

also there are no rules against people pm-ing each others if they agree, the rule is not to pm people without authorisation, or to ask them to help in PM.

candid eagle
#

no matter

#

im trying to press on with qt but i know its going to be a headache down the line

#

especially when i try get my app to android lol

alpine blaze
#

uh, yeah, kivy would certainly be easier for that

#

anyway, if you want to avoid as much headache as possible, make sure to split clearly between app logic and interface, usually by putting the app logic into a library that can be used separately, and having the interface just call functions or classes from it.

#

this way you can scrub the interface any time without losing too much work

candid eagle
#

yeah i plan on doing that on a rewrite as ill be hosting a server on the rpi to store any data and logic, then a client with the gui to read and edit the data stored on the server

#

thats the plan anyway

proper glade
#

anyone know a reliable way to check for losing/gaining focus in pyqt?

#

focusOutEvent seems to never get called

#

and event filters dont seem to even receive focus events

#

nvm fixed

#

had to call setFocusPolicy with StrongFocus

sudden wraith
#

Does kivy have a tkinter like style?

digital rose
#

if you mean the native appearance of widgets, then no, kivy does not have this. The idea is that you create apps that look the same on all platforms.

although of course, you can recreate almost any interface (if you have some skills)
@sudden wraith

alpine blaze
#

Yeah, kivy is pretty different from tkinter in default appearance and customizability of it

fickle needle
#

hi everyone - is it a good idea to make desktop applications with pyQT? pros/cons?

#

how's the support for pySimpleGUI?

#

better to stick to PyQT or should I switch to PySimpleGUI?

robust marsh
#

Hi all, i start python (as sysadmin and for personnal tests at home). I start on debian with python3 packages on the system (alonside the python2).
I've installed vscode + python plugins (python, pylint, intellisense)

#

since yesterday i look severals website to guess how to have a nice workflow for first tutos and real work after.
i've seen most speak about scaffold, virtualenv pytest/unittest (?),... i understand virtualenv will be a mandatory as i plan to use gitlab and CI (maybe with a docker runner) to add tests.

#

but starting with virtualenv, seems that every website/blog/tuto describe a different content, method, tools to mรนanage them .. i'm totally lost ๐Ÿ™‚

#

Current state : debian10, from apt packages python v2.7.16 and python3 v3.7.3, added apt packages : some modules like numpy, and python3-virtualenv (pip not installed), + vscode

alpine blaze
#

hello, i'm not sure why that question is in #user-interfaces, did i miss something specific? Unless that's because of the usage of vscode? here is more about using python to build user interfaces.

#

but it's normal to be a bit lost, that's a lot to process at first, virtualenv is always a good idea, though not really mandatory especially if you already isolate things in docker, but it never really hurts anyway.

#

if you do python3 (and you should) you can managed them with the venv module of python, or you can still install virtualenv and work with that

#

but on debian, you have a few more hoops to jump through, as they removed it pip and virtualenv by default, which doesn't make sense to me, but whatever, it's easy to fix

#

it's nice to use higher level things to manage your venvs, historicaly things like virtualenvwrapper have been used, and can still be used, but more recently tools like pipenv and poetry have appeared to take a broader scope of project management, it's hard to say at this point if they are here to stay, but there is definitely some adoption of them, so they might, i'm not fully converted, and i use a more classical wrapper for my shell, but you can try various ways and see what's best for you, it's a lively space.

#

@robust marsh

robust marsh
#

yes i put it because venv can be configurde ion vscode too it seems (dupliacet, again another method ???)

#

and not sure where to ask ๐Ÿ™‚

#

yes suree i'll start with python V3 (hope in the new job they have not keep v2 ...)

#

for command line only, i juste read a blog speaking about pip freeze > requirements.txt, and in comment many people says : don't do this !

#

i've seen some speakinf on pyenv, other python setup.py, other cookiecuutle, or pyscaffold ... and seems all those tools designed in the same goal

#

additional note : i have a gitlab server, and will add a runner for add CI to my projects. seems the better is to have CI runs in docker instances, and then will need the requirements.txt (and dev-requirements.txt)

#

and for IDE, can you confirm that vscode is a good choice ? i first try pycharm, but too complicated at start , vscode is really more user friendly for now

#

(python3-virtualenv and python3-pip added on my system via apt)

alpine blaze
#

some of these tools are higher level than others, and build on top of some of the other ones

#

i would advise to start by understanding (at least on a basic level) what python setup.py does, as it's the most fundamental one in python packaging

robust marsh
#

seems taht pip is abovce setup.py, or using it at least (i was reading on this ๐Ÿ™‚ )

alpine blaze
#

yeah, i do have a gitlab as well, i've yet to setup ci again, (did so at previous company), it's really cool

#

pip is mostly search + download + call setup.py yes

robust marsh
#

never done still, old job refuse to use git/gitlab/ other tools for devs

alpine blaze
#

ouch

robust marsh
#

new job : i will manage servers with ansible + python scripts (1st need to learen python ๐Ÿ™‚ ), and i suggest to manage and versionn all codes/snippets

alpine blaze
#

๐Ÿ‘

robust marsh
#

and will porpose a gitlab (and with a CI for pylint and mayne aother tools i've seen)

#

a whole SUPER stack to learn !

#

gitlab-ci, python, docker, ansible !

alpine blaze
#

yeah, i would advise to add things one at a time though, as maintaining them will take you time, and if you added a lot at once, it might quickly get overwhelming

robust marsh
#

at least, but really many things to understand (as i don't want to try blind "like this and i'll see"

alpine blaze
#

CI is nice to have, but takes a lot of time to get working at first

robust marsh
#

yes, but seems i'll have not many helps.. the team is essentially windows admins ... they don't have gitlab

alpine blaze
#

(not specific to gitlab, it's always the case as far as i know)

robust marsh
#

yes ๐Ÿ™‚ i would start with basics like linter + pep (?), and see tests later

alpine blaze
#

and devs will break your CI when they push bad code, and you'll have to understand why, or have them look at why

robust marsh
#

i already put a bash linter in gitlab, too wonderfll

#

for linux part, a whole new team, i'll try to discuss about good practice at the start ...

#

always too complicated to start "witout" rules and try add them after

#

i love best practices

#

hmmmmm mkvirtualenv not in pyhyton3-virtualenv package ...

#

for the chan, is there a better place to discuss workflow and tools and virtualenv ?

alpine blaze
#

python3 -m venv

#

ah no, mkvirtualenv is from virtualenvwrapper iirc

robust marsh
alpine blaze
#

but python3 -m venv should do the trick

robust marsh
#

ha ok

alpine blaze
#

"my legacy workflow"

robust marsh
#

he spoke about diffrent workflows in the time

alpine blaze
#

yeah

robust marsh
#

now using pyenv

alpine blaze
#

as a sysadmin, you should probably frown on the curl | bash call, that's not great security there

#

better download it, review and then execute

robust marsh
#

yes ๐Ÿ™‚

alpine blaze
#

sadly very common

robust marsh
#

and often working behind proxy/firewall too

#

and generally take the "latest current" version is not good, because if you try 2 weeks later, maybe another code

#

i prefer DL, test, and if ok i reproduce

#

and if newer version .. need to restart all

#

but at least, same version everywhere

#

(the same principle than using requirements.txt :)) )

alpine blaze
#

yeah, but then once you have pinned versions in CI, you can update the version in a PR, see if things still work, and then merge

robust marsh
#

pyenv not packages on debian, and not available in pip ?

alpine blaze
#

hm, it should be available in pip

#

pretty sure that's how i installed it

robust marsh
#

read that it's better to stick with packaged version than took on github/gitlab

alpine blaze
#

i guess the author just wants bleeding edge

robust marsh
#

pip3 search pyenv --> pyevn (0.0.1)

#

c'est bien pypi.org le repo officiel python ?

#

github ils sont ร  la 1.2.13 du 09/07

#

oups

#

on github it's 1.2.13, and pypi.org .. only 0.0.1

alpine blaze
#

haha

#

franรงais spotted ๐Ÿ˜›

robust marsh
#

at least not a beta ๐Ÿ™‚

#

lol

alpine blaze
#

hm, apparently no, pyenv only has a placeholder package on pypi, and is not installable through pip, weird

robust marsh
#

ok, they should switch repos to gitlab.com ๐Ÿ™‚

alpine blaze
#

well, i agree that open source is better, but the community is mostly on github, and github is pretty nice, it's hard to make people move

#

i use github a lot for both work and open source, even if i have a gitlab at home for myself, and used gitlab at my previous job

robust marsh
#

they says that requirement.rtx file are old-school ๐Ÿ™‚ now there's a better way ๐Ÿ™‚

alpine blaze
#

yeah, as i said, things are changing

#

a lot of existing projects still use requirements.txt though, personally i moved to putting the things as dependencies in setup.py

robust marsh
#

yes but i will start new projects

trim flume
#

is there a way to display a database in a kivy screen, or even anchor db browser on a screen?

tame spindle
#

Is electron the best language that can be used with Python to create beautiful gui

sudden coral
#

Electron isn't a language, it's a framework. Also, it's for JavaScript, not Python.

twilit copper
#

Does anyone here uses PySimpleGui?

bold gorge
#

In Kivy, is there a way to swap ActionPrevious and ActionButtons/Group positions? So that the buttons are on the left side

alpine blaze
#

@tame spindle i'm pretty sure kivy is better to create beautiful GUI than electron, but it's different, it depends a lot on how familiar you are with web technologies (for electron) and opengl (for kivy).

tame spindle
#

Thanx @alpine blaze I will definitely try kivy

proper glade
#

is there a quick built-in way to clamp a QPoint inside a QRect?

digital rose
#

yo

#

Im using tkinter

#

Im trying to display an image thats inside a function

#

however, when the display image code is inside a function it doesnt work

#

it works fine outside of the function

#

Any suggestions?

#

ughhh

tidal spruce
#

w1's lifetime is inside the function only

#

You have to make w1 avalible outside of the function

robust marsh
#

hi, some help to configure pylin3 in VSCode please ?

trim flume
#

is there a way to inbed a .py file in the screen of another python ap?

#

so i have a python file i import into my main and then use to query a DB and then great a ui to view the DB
but it opens in a seperate window and im trying to get it to display in the main app

bold gorge
#

I started creating a text/code editor with kivy. I'm at that point where I can edit the editor with itself finger_gun_dank

trim flume
#

gonna make the new and better sublime?

bold gorge
#

suglyme might be a better name for my app... But I plan on working on it long-term

digital rose
#

@tidal spruce I donโ€™t understand

#

Why does it only work outside the function?

tidal spruce
#

w1 dies when the function ends

digital rose
#

Wotttt

#

Ahh

#

Hmm

#

Still donโ€™t get it

#

and how can I resolve this @tidal spruce ?

alpine blaze
#

@bold gorge hey, nice start ๐Ÿ™‚

bold gorge
#

Thanks! Also my first time using kivy ๐Ÿ™‚

alpine blaze
#

๐Ÿ™‚ how is it going?

bold gorge
#

I haven't seen much of the documentation, but it's a bit confusing as to what i should subclass and what to use directly in .kv files

alpine blaze
#

well, the doc might be useful to understand concepts, the we tried to present most aspects of the framework in the programming guide, and the API doc is very useful too (though you can also just have the code and look into it, which is what i prefer when i wonder how something works)

bold gorge
#

Yeah the API doc is a big time saver ^^

#

i was all ready to code the syntax highlighting myself and there's this neat CodeInput that already does that

alpine blaze
#

๐Ÿ™‚

#

What's the objective of your editor btw? Are you doing it by curiosity, or do you plan features that you think are missing in other editors?

#

Code highlight is sometime broken because of line cuts if i remember well.

#

strings going over multiple lines for example

bold gorge
#

It's just a small project for myself. I thought it was a neat idea being able to develop a simple application with so many capabilities. Hopefully by the time I'm satisfied with it, it will have a lot of features ๐Ÿ™‚

alpine blaze
#

๐Ÿ™‚

bold gorge
#

Yeah it does that, and I also had this weird bug where a line goes invisible unless you change any character

#

But very happy with the lib overall

#

Also if anybody is brave enough to work with this smol editor it's open source aswell ^^

alpine blaze
#

you mean using one library with the api of another? why not use the other? or why not learn the api of the first one instead? if these things have a different api and capabilities, there are certainly reasons for it

bold gorge
#

Kivy: Is there a way to add a custom widget in separate .kv files? Or do I need to do that through code? Something like:
App.kv

    # Somehow reference CustomWidget ```
CustomWidget.kv
```<CustomWidget>:
    BoxLayout:
        ...```
#

Ok figured out there's a directive #:include filename.kv that fixes it ๐Ÿ™‚

ember pike
#

Is anyone here familiar with Bimpy?

hollow forge
#

anyone uses processing here?

fiery tree
#

Does anyone have experience with pygobject and glade?

still osprey
#

Hi, in a PyQt window which starts maximized, how can a set the width of a widget to be maximized as well? (maximized window -> maximized widget's width)

tight cedar
#

Hi, how can I only open a PyQt System tray menu on right click but not on left click?

digital rose
#

How can I make it open a new window everytime I click p

#

This is Tkinter

thorny spruce
#

Should there only be one window open at a time?

digital rose
#

@thorny spruce I need to make it so there can be multiple windows at a time

thorny spruce
#

Then you should use a tkinter.Toplevel window. You should only ever have one tk.Tk window

digital rose
#

What does that do?

thorny spruce
#

It's a widget that's another window

digital rose
#

So I just make it root = tk.toplevel?

thorny spruce
#

tk.Tk is your root window (your first one), any other windows you want should be a tk.Toplevel window

#

For example

import tkinter as tk

root = tk.Tk()
tk.Label(root, text='This is my root window').pack()

for i in range(3):
    win = tk.Toplevel(root)
    tk.Label(win, text=f'This is window #{i}').pack()

root.mainloop()
digital rose
#

I still seem to be having an issue

#

@thorny spruce I want it to open another window everytime I click p

thorny spruce
#

You can bind your window if that's what you want

digital rose
#

How can I do that?

thorny spruce
#

Use the .bind function

digital rose
#

hm

#

Well, I already have events

#

I just need to make a new window everytime I click p

stray moss
#

what's the best widget to display a paragraph of text?

#

Label works but when packing it, it isn't properly centred

thorny spruce
#

For tkinter? Text widget

digital rose
#

@thorny spruce my thing still isnt working

#

I cant figure it out

thorny spruce
#

Idk what to say really

stray moss
#

@thorny spruce isn't Text for editable text?

thorny spruce
#

Yes, you can disable it if you want

stray moss
#

oh

#

perfect

#

ty

thorny spruce
#

Actually I think you can specify the wraplength for a Label

stray moss
#

that might work

digital rose
#

welp

stray moss
#

turns out i was just defining a multiline string incorrectly ๐Ÿ˜…

atomic wing
#

How do I retrieve the list of selected items from QListWidget?

#

in pyqt5

rocky dragon
rocky dragon
#

it's for qt, and pyqt is just a wrapper around that

#

it's a method of the class, so call it like a method in python

atomic wing
#

I get this

#

But the selection thing works well

#

I just need to get the values in string format

#

This gives me

#

Any way I can get [0.0, 0.5, 0.613] ?

rocky dragon
#

that gets you the list items

atomic wing
#

Sorry but I don't understand ๐Ÿ˜ฆ

rocky dragon
atomic wing
#

ahh lemme try

rocky dragon
#

qt stores almost everything in items so you can do more things with them

atomic wing
#

I am still confused

#

Where do i use .data?

#

If I am not mistaken, .data takes in int value

rocky dragon
#

I believe what you want will be at role 0, or you can use the text method

atomic wing
#

Sir

#

Thank you

#

It works!

blazing pine
#

I've been thinking of making a small library that integrates a pandas dataframe with qabstracttablemodel

atomic wing
sudden coral
#

That should be fine

#

I think it's just PyCharm getting confused about the types

#

you could try addng an arg to the lambda

#

because technically the slot for the clicked signal has a boolean in the parameters

#

But it will work anyway if that parameter it not present

atomic wing
#

Okay so I have a QTableView which is populated using a pandas dataframe

#

And I use a QListWidget called memList to filter the dataframe

#

The dataframe has a column called memory and I would like to filter the df according to the selection i make in memList

#

I use this code to filter things out

#

My code works perfectly for all values except 'nan' and 'All'

#

What is going wrong?

#

I need to do the endswith thing cause the values in the dataframe aren't exactly all the same. My memlist has 1.0 GiB but the dataframe has 1 GiB

#

Hence the conversion

#

So I am converting all whole numbers like 2048.0 GiB to 2048 GiB to make life easier

atomic wing
lyric cave
#

Is there a name for the interface I'm thinking of? (command line job status report)

[checkbox] task
[checkbox] task
[checkbox] task
[red mark] task
[checkbox] task
[idler] task
[spinner] task
[spinner] task
 Complete: 7/XXX   ETA: {ETA}

EDIT: Looks like I can sort-of build this myself using blessings, as long as I keep track of row-number for these jobs.

#

Perhaps there's already a library that does this? :)

digital rose
#

I think theres one called tasktracker

#

or something

#

I'm 100% sure there's one

noble locust
#

Hi guys.
I am using Kivy and trying to create a program that compares 2 lists. I managed to create it in a fairly reusable way based on this example. https://stackoverflow.com/questions/53834602/kivy-selectable-recycleview-inside-screen-manager
I am using two lists on my design, but I want the buttons on each of the lists to do different things (if you click on the one on the left to do something, if you click on the one on the right something else).


        BoxLayout:
            orientation: "horizontal"
            ListButtonBox:
                button_text: "Send to right"
            ListButtonBox:
                button_text: "Send to left"

Anyone knows how to control each button differently?

tribal path
#

just bind to an event?

atomic wing
#

I have a Qtableview

#

However a new value is added to it every minute

#

How do I make my qtableview update every minute?

lilac ridge
#

Hello, I made a simple gui that is able to read text lines from a file.
I would like to be able to display some info about a word when the cursor hovers over it (through a tooltip or similar), is this possible?

tribal path
#

can add a tag to sections of text that you can bind enter/leave events to

blissful narwhal
#

Using PyQt, what would be the way to make a button that asks for a user input and then stores it as a variable?

#

preferably using a pushbutton

versed trout
#

Guys I have question is there any way to style you own PyQt5 App ? I mean setting a background color or pushbutton color ?

sudden coral
#

Yes, look up qt style sheets

versed trout
#

Ok thanks. It looks very similiar to CSS if it is not the same

sudden coral
#

Yeah I think that was the idea

versed trout
#

Maybe this is simplier than the Kivy style of doing interface

sudden coral
#

Using signals and slots

blissful narwhal
#

do you know how I get rid of that black outline in the bottom right corner?

blissful narwhal
#

could someone explain how I could use an interface to take in an imput from the user, take that, perform some sort of operation, and ouput something to the user?

sudden coral
#

you'd need a widget that takes text input

#

and another widget that can display text

#

and maybe a button the user presses to signify they are done entering input

#

QLineEdit and QTextEdit can take text input

#

QLabel can display text output

#

You should refer to the documentation on these widgets to learn how to retrieve or set the text for them

#

And I said before, you'd use signals and slots so you can know when the button has been pressed and you can do whatever operation you want

blissful narwhal
#

should I use lineEdit for text edit if I want the user to give me a string?

sudden coral
#

Depends

#

QLineEdit takes a single line

#

QTextEdit supports many lines

#

like paragraphs

#

and has more formatting options and so on

blissful narwhal
#

Ah so then i need line edit

blissful narwhal
#

how would I insert a label

#

?

blissful narwhal
#
    def onPressed(self):
        self.label.setText(self.lineedit.text())
        x = str(self.lineedit.text())
        print(x)
#
 stockvalue = si.get_live_price(x)
           stockvalues.append(stockvalue)
           print(stockvalue)
weary sun
digital rose
#

@versed trout what's wrong with "Kivy style of doing interface"? ๐Ÿ™‚

versed trout
#

@digital rose Well nothing like its just specific language if I remember right

#

And I didn't do much with Kivy but I think using something similiar to CSS is simplier than something new if you understand. It's just my opinion.

hollow mist
#

@weary sun From a cursory reading, it looks like you are not using sizers. You really should. They automatically size the element based on available space and you can give it a behaviour to grow or not etc.

slender burrow
#

I am currently using pygame and I am looking for a UI library to build the game GUI. Glooey was recommended, so long as I migrate to pyglet from pygame - a big ask! I can't find anything about UI for games so not sure how pyqt, tkinter etc. would hold up. Any advice?

hollow mist
#

QT and tkinter are not suitable

#

But you can easily use pygame to make a gui

#

a gui, in the end, is just images that serve as buttons and react on events like mouse over or clicks

#

or use pyglet

#

all you need is a renderer and input events to build a gui

slender burrow
#

Tbh, i've spent two days migrating to pyglet and I am yet to feel any benefit.

#

I am sure I can create a basic UI but it seems like it can get quite complex, quite fast. And my skills are pretty mediocre.

hollow mist
#

you are right there, but read the link

#

there are some readily available gui toolkits available

#

or stick with pyglet and use glooey

slender burrow
#

I've read that page a few times and there's only Thorpy still active.

#

And i've heard a lot of criticism for it.

#

Though I can give it a go if nothing else jumps out!

hollow mist
#

Okay, let's take it from this side: What kind of interface do you need?

#

Lists and complicated stuff? Or just buttons and health bars?

slender burrow
#

The former. Aspirational would be Pillars of Eternity, but more realisticalll something along the lines of Tome4

hollow mist
#

quite an undertaking you got there

slender burrow
#

Agreed

hollow mist
#

that looks really nice

slender burrow
#

I've spent a year building the architecture so whilst I lack skills I don't lack dedication.

#

Totally agree! That's the bar I am aiming for.

hollow mist
#

oh wait that is Taj

slender burrow
#

Yes!

hollow mist
#

thought it's your game

#

I own that on Steam

slender burrow
#

Haha, defnitely not mine!

hollow mist
#

does CeGUI have pythonic bindings?

#

try this out

#

CeGUI has been around for ages

#

Crazy Eddie's GUI

#

Crap, the py bindings are a bit outdated as well

slender burrow
#

"This page was last modified on 3 March 2011" ๐Ÿ˜ฆ

#

I love their logo, though!

hollow mist
#

CEGui is made for C++

#

Python is not their focus

#

and if a maintainer quits, not much you can do

slender burrow
#

Agreed.

#

Maybe its a roll my own situation then!

hollow mist
#

All you can do is search around and try things out

#

make sure to check your source into git and branch

slender burrow
#

That's what I've been doing tbh, buddy. This was pretty much my last ditch effort to find a hidden gem. ๐Ÿ˜›

#

Thanks for your help, mate.

alpine blaze
#

why not kivy?

#

oh my, that's a few days old, i guess i've not been around ๐Ÿ˜†

final flicker
#

why does kivy force you to import things like this:
from kivy.uix.widget import Widget
instead of calling
import kivy class MyWindow(kivy.uix.widget.Widget)

digital rose
#

@final flicker well it's because Label widget class is located in a separate module named label (label.py)
The directory is kivy/uix/label

Or maybe I got you wrong?

alpine blaze
#

does it force you?

#

hm, yeah, the sub packages are not imported automatically

#

automatically importing them even if you don't need would make app startup slower because of loading unneeded things.

still osprey
#

Hi, I'm trying to execute something when the Mouse Right Click is well clicked

    def eventFilter(self, QObject, event):
        if event.type() == QEvent.MouseButtonPress:
            if event.button() == Qt.RightButton:
                print("Finally!")

Why is this not working?

final flicker
#

@alpine blaze im working on my rendering engine and id love to be able to directly be able to interact with my Widget subclass

#
class MyApp(App):
    def __init__(self):
        super().__init__()

    def build(self):
        return MyWidget()
#

thats how im doing it right now

#

but id love to be able to just call MyWidget

#

this is the end goal:

class MyEngine(MyWidget):
    def __init__(...):
      super()...
    def on_touch_down(self, touch): # this is overwriting the on_touch_down function in MyWidget
       ...
    def on_update(self): # this is also overwriting a function that runs on a clock
       ...
#

if feel like doing this is kinda sketchy:

class MyApp(App):
    def __init__(self):
        super().__init__()
        self.window = MyWidget(my_on_keyboard, other_event_function, ...)
        self.root = self.window
        kivy.clock.Clock.schedule_interval(self.window._update_data, 1 / 60)```
and then having all the actual event functions call the passed in args.
alpine blaze
#

app.root always refers to the root widget of the app

#

so maybe you don't need all that contraption ๐Ÿ˜›

true schooner
#

Hi, i was wondering if anyone could help with with Tkinter. I have spin boxes, and wanted to know if their was a way to check if they changed, so i can have some code run.

#

found it, just had to use command in the spinbox

molten swan
#

I would like to make a GUI skinning tool (windows application) for a game's UI. It needs to have drag and edit functionalities like you would see in a design app or a user friendly 2d game engine (see image).
I'm searching for a program, api or library which could help me achieve this.
I have no ideal how to call this kind of functionality so I can't search for it online.
As far as I know (please tell me if I'm wrong) it's possible in pyqt but very difficult because you'd have to make it from the ground up.
Thanks in advance for any suggestions, links of open source projects with this functionality or terms!

final flicker
#

is that godot in the background?

molten swan
#

yup

final flicker
#

nice

molten swan
#

the basics of it's gui is a great example of what I'm trying to make.

proper glade
#

a QGraphicsView would be a good choice for the canvas I think. It renders a QGraphicsScene, which manages a collection of renderable items such as widgets, shapes, pixmaps etc that can be placed at any position on the scene.

#

so you wouldnt have to reinvent any wheels as far as that's concerned

molten swan
#

sounds good

#

is it only for displaying or would I be able to program user interaction in it?

proper glade
#

you can intercept keyboard/mouse events and interact with the items on the scene however you want

molten swan
#

sounds great!

#

I'll look into it

#

thx

proper glade
#

the examples are in c++ but should be fairly straightforward to translate to pyqt

#

and if you have any questions feel free to ask of course

#

another API you could use is Kivy, but im not as experienced with that so couldnt give you a worthwhile opinion on how well suited it is for this application. paging @alpine blaze

alpine blaze
#

yeah, kivy seems appropriate to this, it's pretty much done to draw collections of arbitrary things, and to manage them by drag and drop.

#

@molten swan

molten swan
#

thanks! I'll try it with pyqt first because I already know it's basics, but it's a nice backup if I don't like the way it's done or get stuck in pyqt

alpine blaze
#

ok, good luck either way ๐Ÿ™‚

molten swan
#

@proper glade I'm a bit stuck. I need QGraphicsObjects for my QGraphicsScene because of their signals but QGraphicsScene only takes QGraphicsRectItems. I also can't instantiate any QGraphicsObjects because they are abstract. I could be wrong about what I just said but this is what I understood from it

#

I'm just testing things right now but in the actual project I will need to make my own classes and somehow add them to the QGraphicsScene

proper glade
#

you can use addItem to add any QGraphicsItem to a scene

#

(and therefore QGraphicsObject since it inherits from QGraphicsItem)

molten swan
#

ahh

proper glade
#

i believe to instantiate a QGraphicsObject you can easily make your own concrete subtype, or inherit from one of the currently available graphics item types and also add your own signals to it

molten swan
#

could I also inherit from QGraphicsItem itself?

#

I'm trying but getting some errors

class ShortNote(QGraphicsItem):
    def __init__(self):
        super(QGraphicsItem, self).__init__()
    
    def dropEvent(event):
        print(event)
proper glade
#

so either:

class LineItemWithSignals(qt.QGraphicsLineItem, qt.QObject):
    some_signal = pyqtSignal()

or something like ```python
class LineItemWithSignals(qt.QGraphicsLineItem):
class Signals(qt.QObject):
some_signal = pyqtSignal()

def __init__(*args, **kwargs):
    super().__init__(*args, **kwargs)
    
    self.signals = type(self).Signals()
#

yeah and you can inherit from QGraphicsObject to make it concrete

#

sorry, excuse the qt. prefix that's a force of habit

#

what errors are you getting?

molten swan
#

one for super but that was fixed with *args, **kwargs

latent hemlock
#

Can someone help me out over in the "help-0" chat later?

molten swan
#

and the other didn't have self

#

thanks for the help again!

proper glade
#

no prob

molten swan
#

never done OOP in python nor with a 3th party framework yet so I'm still making some stupid mistakes

proper glade
#

growing pains ๐Ÿ™‚

#

@latent hemlock you got a user interface problem?

latent hemlock
#

No

#

It's all in the "help-0" chat. I need help resolving an error in my code.

proper glade
#

there's no need to go around to other channels and ask people to come to another one to help you

#

if someone sees your question and can help they will

latent hemlock
#

Alright my bad.

true schooner
#

Hi, i am using tkinter and have my gui code in interface(). I have spinboxes which call ReadData() when they change. I need to get the values of the spinboxes in this function. I tried making them global and using .get but i am just getting this <bound method Spinbox.get of <tkinter.Spinbox object .!spinbox>>.

#

Anyone know anything else i can try?

karmic shoal
#

do you have parenthesis after get? you should be calling the function like so: get(), since just having get results in the function itself being assigned to the variable rather than the return value of that function

true schooner
#

oh dam, dont even know how i missed that

#

cheers man

true schooner
#

Would anyone be able to help me format this right? Storiestxtbox.insert('1.0',"\"", sbstitle[i],"\"", '\n', sbspubData[i]) I am trying to get this

true schooner
true schooner
#

Storing it first is getting the closest result but is there anyway to stop it from showing {}

true schooner
#

Still looking for some help ๐Ÿ˜„

true schooner
#

'Storiestxtbox.insert(END, str(aqsdfa)[1:-1],"\n")' I've changed it to a str which work but the \n dose not seem to be working

#

fixed it with Storiestxtbox.insert(END, str(aqsdfa)[1:-1] + "\n\n")

molten swan
#

@proper glade My items somehow move the view in the scene or something when I drag them on startup. But after doing it for a while it stops

proper glade
#

note that setSceneRect is being called on the scene itself, with the rect of the view passed as argument

#

though it feels a bit backwards to me, like something that should be a function of the view rather than the scene

#

there we go, qgraphicsview has its own setSceneRect

molten swan
#

it worked!

#

now (0, 0) is also the top left

proper glade
#

noice

molten swan
#

@proper glade I'm sorry to bother you again. Just tell me if you are not interested in helping me every now and then throughout my project. That being said, I'm trying to make a list of all my custom GraphicsItem types which I could then drag into the GraphicsScene

proper glade
#

it's all good

molten swan
#

but QListWidgets only accept QListWidgetItems and they don't seem to to be able to hold classes as data

#

thanks a lot

#

I tried giving my GraphicsItem classes QListWidgetItems

#

but when I .setText() it gives errors

#

and without it won't display in the list (don't know if it's not added or just invisible because it has no name)

#

giving a normal QListWidgetItems text and adding it works fine

#

just to be clear, the goal is to instantiate a new class I dragged in and add it to the scene

proper glade
#

it's been a while since ive worked with a situation like this but iirc there are a couple drag/drop events you gotta override and also probably call something on the view to enable drops in the first place. gimme a couple minutes to play around with it and ill get back to you. as for QListWidgetItems holding classes as data, you can create your own subtypes that can hold a reference to anything like any other python object.

molten swan
#
class MyQListWidgetItem(QListWidgetItem):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.customClass = object()

    def setCustomClass(self, customClass):
        self.customClass = customClass

something like this?

proper glade
#

exactly

#

though self.customClass would just be object rather than object()

#

you want a reference to the class itself, rather than an instance of it

proven basinBOT
#

@proper glade, it looks like you tried to attach a file type we don't allow. Feel free to ask in #community-meta if you think this is a mistake.

proper glade
#

whoops

#

one sec

molten swan
#

you can send it to me privately

#

xD

proper glade
#

and theres another file called qt.py which is just

from PyQt5.Qt import *
from PyQt5.Qt import Qt as constants
#

which i use in all my pyqt projects

#

anyway, the gist of it is that you gotta override a couple of drag*Event methods on the GraphicsView to accept the event

#

and also the thing with subclassing QListWidgetItem to store a reference to the class like before

#

everything good?

#

@molten swan

molten swan
#

yes great

#

the view is autogenerated with a ui so I need to do some tweaking to my code

#

but I understand what to do

#

thanks

proper glade
#

np

#

ah there should be a mapToScene for the setPos

#

so this instead

                item.setPos(
                    self.mapToScene(event.pos())
                )
molten swan
#

๐Ÿ‘

molten swan
#

FINALLY got it to work

#

scene.addWidget returns the item while scene.addItem does not

#

so adding the QPushButton worked but my custom classes didn't while my custom classes did work when just added them to the scene in the MainWindow init

analog imp
#

what are you working on

molten swan
#

a 'design' application

analog imp
#

a application you can design stuff with

molten swan
#

kind of

#

but for a specific game

analog imp
#

ohh like e game engine

#

love making game engines

molten swan
analog imp
#

nicccce

molten swan
#

basically a game engine but without functionalities. just position and some other properties of objects in a canvas

analog imp
#

like the u.i very simple

molten swan
#

thanks

analog imp
#

soo you can make project with this

molten swan
#

I'm not done with it yet but it wonn't get much more complex

analog imp
#

ya i under stand

molten swan
#

sorry what do you mean?

#

ohh

#

you can make a ui skin with it

analog imp
#

well when i work on a project i dont what it to complex

#

easy to use and play

molten swan
#

exactly

analog imp
#

and custom skins for it would be nice

#

like you can pick in the setting for white or black or you can import you own

proper glade
#

scene.addWidget returns the item while scene.addItem does not

#

right, doesn't make much sense when you already have the item there to pass as argument ๐Ÿ˜›

#

scene.addWidget takes a widget and returns an item so it cuts out the work of converting the widget into a QGraphicsWidgetItem first

#

there's no such extra work to be done with addItem

molten swan
#

ahh

proper glade
#

sorry, QGraphicsProxyWidget not QGraphicsWidgetItem

molten swan
#

was kind of confusing because while debugging everything seemed to work and didn't think of something like that

#

but makes sense

proper glade
#

everything's gotta be in QGraphicsItem form first to be added to the scene so they gotta be converted first

#

the add* methods just make that more convenient for you

molten swan
#

does that mean that the items inside the scene lose all their custom code?

proper glade
#

i think custom widget behaviour is carried over

#

as for custom code for things like lines and polygons, i doubt it

#

theyre meant to be used more as values than anything else

#

if you have your own custom subtype of QGraphicsItem and define custom behaviour for it then thatll be carried over to

molten swan
#

but mine are kept since they already inherit from QGraphicsItem right?

proper glade
#

yes, youre adding those items directly to the scene

#

rather than converting some other object into a qgraphicsitem first

timber pecan
#

Any PyGTK Veterans here? I'm having some trouble with TextView resizing with large amounts (correction: no, 5 paragraphs is NOT large) of text. It's fine reizing larger, but resizing smaller is excruciatingly slow UI wise.

#

has problems with both Spellcheck enabled and not enabled

timber pecan
#

TKInter seems to have no trouble with grid resizings :/

timber pecan
proper glade
#

thats really weird

#

looks like a bug

timber pecan
#

Agreed. Itโ€™s on a relatively fast machine using the proprietary Nvidia driver, but I had the same problem in a vm on a Mac host at work too.
I donโ€™t see the grid getting incredibly huge, so I might continue down the tkinter path if I can get good inline spell checking working.

Still exploring ๐Ÿ˜Ž

sudden coral
#

I wonder if you could reproduce it if you ditched the wrapper and used gtk in c

#

Though I don't expect people in this server to all know C

timber pecan
#

I should try, but I was trying to keep it simple. Might try QT5 too

hazy matrix
#

So i am working on text summarizer by python using nltk .
i have finished the code part and my program summarizes text fields passed .

#

I want to make this as a web app

#

Can anyone help me with the web/UI part ?

#

i am beginner in python

elder valve
#

Am i going mental or has PyQt5 changed tbe way colSpan and rowSpan work? I cant get it to work in the newest version

final flicker
#

@alpine blaze can i somehow tell a kivy texture to clear itself? or do i just have to set it to 0 ever time?

alpine blaze
#

i don't think we have a specific api for that, setting it to 0 should be fine

final flicker
#

ok thx

#

i dont really get this:

When using a bytes representation of the data, for every change you have to regenerate the bytes instance, from perhaps a list, which is very inefficient. When using a buffer object, you can simply edit parts of the original data. Similarly, unless starting with a bytes object, converting to bytes requires a full copy, however, when using a buffer instance, no memory is copied, except to upload it to the GPU.```
#

right now i have a 3d array (size[0], size[1], 3) and i just flatten it to blit it:
self.texture.blit_buffer(data.flatten(), colorfmt='rgb', bufferfmt='ubyte')

alpine blaze
#

flatten certainly produce a copy that slow down things, and the explanation is that if you use a buffer object, it can update it in place, instead of creating a modified copy

final flicker
#

is it the scrollbar?

reef hound
#

Hey I just posted a project over in the projects channel. If anyone who is good with UI design is willing to help, I need an extra hand

ocean cape
#

is there a guide to writing events for qtwidgets?

#

I want to be able to essentially select a Qgraphicsview. Is there a easy way to set up an onclick even for Qgraphicsviews?

proper glade
ocean cape
#
class ClickableGraphicsView(QtWidgets.QGraphicsView):
    
    def __init__(self):
        super().__init__()

    def mousePressEvent(self, event):
        print("Event works")
        super().mousePressEvent(event)```
#

This is why I've tried, it doesn't seem to do anything though

proper glade
#

seems to work perfectly here

#

are you clicking on an item?

#

could be receiving and consuming the event first instead of the view

#

im not entirely sure what the event processing order would be here

ocean cape
#

I've figured out the problem

#

thanks for the help meta, I wouldn't have figured it out without it ๐Ÿ˜„

proper glade
#

what was it?

elder valve
#

Everything is in the wrong row, and the buttons, which i want to be in two collumns at once, are only in one collumn

elder valve
sand blaze
#

Hey guys, is anyone familiar with django-scheduler or something similar? I need to make an sscheduling calendar web app in Django, but im stuck. I searched every whole, and it seems that they are lack of documantation for that. JS has "fullcalendar", and im wondering is there something similar for django? (That actually works)

molten swan
#

the mouseReleaseEvent() in my QGraphicsScene causes weird behavior while moving my QGraphicsItem

#

I don't know if you can see it but it stutters and teleports the item

#

my code:

import sys

from PyQt5.QtGui import QBrush, QColor
from PyQt5.QtCore import QRectF, Qt
from PyQt5.QtWidgets import QApplication, QMainWindow, QGraphicsScene, QGraphicsView, QGraphicsRectItem, QGraphicsItem


class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setGeometry(500, 200, 500, 500)

        item_brush = QBrush(QColor(255, 255, 255))
        item_brush.setStyle(Qt.SolidPattern)

        item = QGraphicsRectItem(QRectF(50, 50, 100, 50))
        item.setBrush(item_brush)
        item.setFlag(QGraphicsItem.ItemIsMovable)
        item.setFlag(QGraphicsItem.ItemIsSelectable)

        scene = MyScene()
        scene.addItem(item)

        view_brush = QBrush(QColor(150, 150, 150))
        view_brush.setStyle(Qt.SolidPattern)

        view = QGraphicsView(scene)
        view.setSceneRect(QRectF(view.rect()))
        view.setBackgroundBrush(view_brush)
        self.setCentralWidget(view)


class MyScene(QGraphicsScene):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    #def mouseReleaseEvent(self, event: 'QGraphicsSceneMouseEvent') -> None:
        #pass


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

proper glade
#

make sure you call super().mouseReleaseEvent(event) when overriding

#

and also event.ignore() just to make sure it's not consumed

#

oh hmm, not sure about ignore() actually

#

but anyway my best guess would be that you need to call the super method to let all the normal mouse processing stuff happen

molten swan
#

it worked

#

it was the super

#

thanks again

proper glade
#

additionally you might need to do something with the alignments

#

@molten swan no worries

#

@elder valve also, i think the spacedoutness is just a byproduct of how QLineEdit is rendered

#

it's always meant to be a single line, so youll get the empty space around it

elder valve
#

Ah okay, thanks @proper glade

proper glade
elder valve
#

Yeah, i was gunna use QTextEdit, im tryna convert a JS+HTML quiz to python, was gun.a use QTextEdit as equivent of HTML textareas

#

Cause i wanna do formatting and stuff on the text.

wild rain
#

which is better for ui? tkinter or QT ?

proper glade
#

tkinter is to qt what a tricycle is to a spaceship

#

but in seriousness, it depends on what kind of ui you're making

#

you can use both to great effect

#

but qt is a lot more advanced and performant

rocky dragon
#

the disadvantage is that you need to get familiar with the framework and it's larger

#

but if those don't matter to you, it can be a lot better

wild rain
#

ok thanks guys

#

If using tkinter. How do I connect items in a nav menu to change to a different window

autumn badge
#

So people, what is your fav UI framework? Any opinions between PyQt and PySide2?

sudden coral
#

PySide2 has substantially better docs it seems and is supported (more?) directly by Qt. But the docs don't matter too much since both libraries are pretty faithful to the original Qt library and thus not only do PySide2 docs generally apply to PyQt5, so do the C++ docs. PySide2 also uses a less-strict license compare to PyQt5.

#

I use PySide2 but at the end of the day there hasn't been a huge difference for me.

terse delta
#

I use Wx with WxFormBuilder. Never needed anything better. Works great for what I do.

autumn badge
#

Thanks both of you.
I was using PyQt for a while but wanted to use a UI framework that would allow me to create software that was closed source if i ever got the opportunity to sell some of my apps. Even if I were to sell apps, I know I could never ROI the license cost.
I tried some other UIs like Remi, Kivy, tkinter (again) as well as some of the other tkinter like bindings like PySimpleGUI and others. Some of those bindings are very easy to use and allow you to reduce the amount of code you have to write, but I have been finding the limits of those pretty quickly with a simple app.

I liked PyQt. I might have to give PySide2 a shot. Looking through the list of missing bindings in PySide2, I am not too worried. The apps I have planned currently would not need those

sudden coral
#

I believe LGPL would let you make it closed source

#

which is what PySide2 has

autumn badge
#

one thing i do not like is that VSCode tends to not like PySide2. Keeps saying that it cannot find the widgets, but the app still runs. I am still trying to whitelist QT5 in VSCode

sudden coral
#

But don't take my word for it

autumn badge
#

yea. those licenses confuse me

#

I dont "plan" on writing closed source, but i really want to keep that option open to me

sudden coral
#

I think the other really mature one would be PyGTK, at least that is my assumption since it's based on GTK, which is mature

autumn badge
#

yea

sudden coral
#

Should have features comparable to Qt

autumn badge
#

thanks. i will look into that as well

sudden coral
#

I thought kivy was also pretty up there

autumn badge
#

i thought so too

#

but it is not mature enough yet

#

looks great though

sudden coral
#

I wouldn't know I've not used it

autumn badge
#

an app i wrote in PyQt, i rewrote in kivy

#

the UI looked a LOT better. More like a phone app than a desktop app. But, at the time, the functionality wasn't all there. I don't know about it now. I have not been following it

#

hmmmm. I will have to look into PyGTK a bit more. It seems about the same in the coding sense and there is even a builder (Glade) that I could use for some simple apps most likely

#

thanks again. you gave me a lot to think about

#

bed time for me

#

shoot. PyGTK is out. The target I am writing apps for are windows users. Dang it, that looked good too

molten swan
#

I'm having some trouble renaming QListWidgetItems with double click in PyQt

#

I've found some ways to do it in Qt on the internet but they somehow don't work (I'm probably doing something wrong)

proper glade
#

what have you tried so far

alpine blaze
#

what is kivy not mature enough for yet?

#

i mean, there are always things we can improve, but you can still do a lot of apps

#

i've done a lot of them, at least, and i'm far from alone

elder valve
#

@alpine blaze i believe a lot of people (including myself) just dont like the structure of Kivy.

alpine blaze
#

๐Ÿ˜ฆ

elder valve
#

The default look of kivy, however is something i like a hell of a lot

#

I just prefer to force PyQt5 to look pretty cause i like having access to the entirity of Qt5

alpine blaze
#

weird, i though our default look was actually quite a disadvantage, people tend to judge that and think all apps will look like that, and that it's ugly

#

i guess the truth of the second assertion is debatable, but the first one is essentially wrong, as you can change everything and draw anything

#

but do you don't like in the structure? how widgets are built? the package tree? the dispatch system? the graphical instructions?

elder valve
#

The package tree mostly, though i did find a nice little solution to that

alpine blaze
#

Interesting, how would you see it instead?

reef hound
#

Hey

#

I am using PySimpleGUI, I want to use a similar function like FileBrowse(), but for the menu option.
menu_def = [
[ '&File', ['Import::import_key', '---', 'Save::save_key'], sg.FileBrowse() ],
[ 'Help', ['About::about_key'] ]
]

How do I have the same functionality for an import that brings up file explorer so I can import a file with N file type?

versed trout
#

I have question about Pyqt5. How can I set number as a label <

#

*?

elder valve
#

@alpine blaze would be good to have a gui package, where i can import all of the gui elements like is possible with PyQt5.

#

@versed trout what do you mean Sasi? Like the label 341?? If so just do label = QLabel(text="341")

#

I think you actually helped me with the programatic import in the kivy server tshirtman, it was something along the lines of this ```python
imports = {
'uix' : ['Label', 'Button'],
}

for k, v in imports.items():
for I in v:
i = I.lower()
globals().update({I:getattr(import_module(f'kivy.{k}.{i}'), I)})

#

I did refine it later on i think, but i dont have that snippet handy right now

alpine blaze
#

hm, so like uix, but with all widgets from the submodules directly imported into it?

elder valve
#

Yeah, basically.

versed trout
#

@elder valve I figured it out the problem was I was calling the error so it did not worked

#

*work

elder valve
#

@versed trout okay, that doesnt sound like a thing that is possible but I'll take your word for it... feel free to explain yourself though

alpine blaze
#

@elder valve i think we would need a way to do that that wouldn't impact the performances, because i think right now it would slow down app startup and certainly increase memory consumption overall

elder valve
#

Yeah, the way that it's done is understandable, its just not fun to work with ๐Ÿ˜‚ ๐Ÿ˜‚

alpine blaze
#

there is an easy alternative though

#
from kivy.factory import Factory as F

F.Button()
F.Label()
โ€ฆ etc
elder valve
#

That is something i had no idea existed. Wow, ive legitimately never seen that

#

what would one even search to find that given they don't know of its existence

alpine blaze
#

(it works because all widgets in uix are registered in the factory in factory_registers.py, and you can have your own such module in your app to allow the same access to your widget without needing to preload them)

elder valve
#

Thats p cool though, thanks!

alpine blaze
#

Factory is used by kvlang to find the classes to use when you instanciate widgets in the string

elder valve
#

Ah, that makes sense

alpine blaze
#

yeah, it's the kind of things you kind of stumble upon :/

#

i should probably use it more in my examples to make people more aware of it

elder valve
#

Yeah, lmao.

#

It would be good

#

Im probably going to use kivy more now that i know that.

alpine blaze
#

but then i would need to explain why that works for kivy widgets, and not automatically for the widget classes defined by users, unless they have been imported before, or they use a similar factory_registers thing

#

hm, i'll try though ๐Ÿ™‚

elder valve
#

Perhaps Factory could be renamed to builtins? Idk how many files you'd have to refactor, but it would make it a lot more self explanatory @alpine blaze

#

I also don't know whether that would mask its other functions, but one would assume if someone knows the other uses of Factory, a name change wouldn't confuse them too much. I doubt many people will use it at the moment. Of course you could just make a package whose sole purpose is an alias for Factory, and leave Factory in tact

alpine blaze
#

i do think Factory is a proper name, and builtins would be a misrepresentation, i guess the solution is just more/better documentation

elder valve
#

Yeah, unfortunate solution, but a solution nonetheless

proper glade
#

@molten swan did you figure out your double clicking issue

molten swan
#

Not yet. I put it to the side and did some things I do know how to do

#

But the internet says I only need to give the items an 'editable' flag (doesn't work tho)

#

Also, I gave my QGraphicsItems a dragenter, dragmove and drop event and setAcceptDrops(True) but they don't recieve it when they're in the scene

#

could it be that either the view or the scene receives it instead?

molten swan
#

@proper glade

versed trout
#

Hello is there any way in PyQt5 to make the same window with different functions automaticly and don't copy paste the same code of the window all the time ? If yes then how can I ?

rocky dragon
#

create a base class?

proper glade
#

@molten swan not sure regarding event processing order but should be trivial to figure out with some debug output. in case either the scene or the view is consuming the event, you can use their itemAt methods to find whatever widget is under the mouse. additionally dont forget to event.accept() for the drag events.

#

as for making list widget items editable:

        self.setFlags(
            self.flags() | qt.constants.ItemIsEditable,
        )

on the item seems to be enough to make it editable

#

after i do this i can double click and edit the text inside with no extra effort

molten swan
#

both work now

#

It's beginning to look like a real application : )

undone cave
#

If I wanted to give my py program a UI what would I be looking at?

karmic shoal
#

@undone cave if you want a cross-platform desktop UI I recommend PySide2, which is the official Python wrapper for the C++ library Qt

undone cave
#

Hmm

#

Do i need c++?

#

@karmic shoal

karmic shoal
#

you don't

alpine blaze
#

If you want a cross platform desktop and mobile UI, there is kivy, which is a python-first multitouch UI library.

rocky dragon
#

Doesn't qt support multitouch? (Not saying it'd be a better choice for mobile)

digital rose
#

can i put a scrollbar in a Tk() object
i mean

from tkinter import *
root = Tk()

root.mainloop()
```can i create a scrollbar for root?
digital rose
#

Anyone?

thorny spruce
#

You can for a Canvas, I don't believe you can for the root window

vast bobcat
#

Hello guys

#

Guys I need a tkinterical help

#

Sorry for being late

#

does anyone know what is Entry?

thorny spruce
#

It's a widget that allows the user to type into it, you are then able to later retrieve whatever they typed

vast bobcat
#

GOod

#

Good

#

Ik it

#

but now that you'e familiar with it

#

you may be able to answer my real question

#

how to understand what is written in the entry part?

thorny spruce
#

How to get what they typed?

vast bobcat
#

yes

thorny spruce
#

text = my_entry.get()

vast bobcat
#

What

#

intresting

#

can you explain?

thorny spruce
#

my_entry is your Entry widget, you need to call the get method on it which returns a string of what it contains

vast bobcat
#

thanks

#

Are you a tkinter professional?

thorny spruce
#

You could say that

vast bobcat
#

๐Ÿ˜

#

So can youy teach me?

#

iK SOMETHING ABOUT IT

#

sorry for caps

#

Ik some normal regular things

#

lemme send you my best tkinterical work

#

and then you decide if you wanna accept teaching me or not

undone cave
#

So tkinter and QT4 or whatever. The only UI I've seen for these are like grayscale win98 windows. Can they make a cool UI like discord or any other program that's not grayscale and has icons and such?

versed trout
#

Why after clicking a button it isn't showing me the text "Sucesfully Logged ?"

tribal path
#

What is the if line supposed to be doing/checking?

versed trout
#

Its about to check if there is password or username and email in file

tribal path
#

!or-gotcha

proven basinBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

After all, that's how you would normally phrase it in plain English. In Python, however, you have to have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
tribal path
#

I think applies, and not sure you can just in a file object

versed trout
#

Well I've changed but still it is not showing the password username or email in the file

tribal path
#

still using f? reopening a file before closing it could be an issue there too

open stump
#

I belive you should do not in f.readlines() instead of not in f

versed trout
#

if username1 and pass1 and email1 != username1 and pass1 and email1 in f:

open stump
#

in f.readlines()

#

like so you gonna get a list of all rows in your file

#

in an str form

#

['row1', 'row2', ...]

versed trout
open stump
#

well try to print f.readlines() cause I think it comes from the fact that there not 1 info by lines in your file

versed trout
#

It's doing nothing god dammit

#

Do you want to send full code ? @open stump

open stump
#

is data.txt empty ?

versed trout
#

Yes

open stump
#

so that's why

#

email1 can't be in the file if the file is empty

#

as you said before you want to check if there is password or username and email in file and if they arent you want to write the email in the file ?

versed trout
#

Yes this is what the function needs to do

#

Well I think I will rewrite the code

#

Now I've rewrited that function and now it is writing memory id into the txt file so now it is working

digital rose
#

Is it possible to create modern GUIs like discord or any other desktop application in python?

tribal path
#

kivy you can theme essentially however you like, & theres kivyMD for prewritten MaterialDesign widgets. Theres also various Qt wrappers

craggy talon
#

Hi guys!

#

I'm having some problems with tkinter

#

I'm new

#
from tkinter import *
from tkinter import scrolledtext
from tkinter import messagebox
from tkinter.ttk import Progressbar
from tkinter import filedialog
from tkinter import Menu


window = Tk()
window.title("My first TK!")
window.geometry("500x500")

text = Label(window, text="Hello there!", font=("Nunito", 30))
text.pack()

window.mainloop()
reef hound
#

Does anyone know how to move elements to specific positions using pysimplegui? I can't seem to get my elements positioned properly

digital rose
#

@craggy talon does this happen with the default font?

craggy talon
#

no

digital rose
#

I haven't work with tkinter. but I had a similar problem with some fonts in kivy and pygame. I did not find a simple solution since I had a little time, so I just used different fonts.

scenic frost
#

I can't really help if I can't see your code

digital rose
#

@scenic frost the code is above I guess

scenic frost
#

Well unless I'm mistaken I don't think that's the full code

digital rose
#

im new to python gui and i am wondering if there are any better alternatives to tkinter?

lofty elbow
#

Can anyone point me in the right direction for making a desktop app with Flask? @here

alpine blaze
#

@digital rose certainly, but which one certainly depends on what your priorities are, i'm personally a fan (and contributor) of kivy, but a lot of people advocate pyqt/pyside for desktop apps, both have pros and cons.

digital rose
#

yeah i am mostly interested in desktop apps

alpine blaze
#

@lofty elbow flask is a backend, you need a way to display things, usually to build desktop apps with a web framework, you use electron or some other web view and front end technologies, html/css/js with react or vue or whatever to help build a modern front end.

brisk thicket
#

Hi I'm making a TUI application.
(new to python so keep it simple please)
Pretty simple just imagine the main part of the window being output, ie print()
As well as a small box right at the bottom where you can input text. I have looked into curses for this and I roughly know how to do it. An issue I ran into is with the text box you can only type, backspace and return. No left/right or whatever.

I'm open to and libraries anyone suggests. Just want to get this done

hollow mist
#

Electron is what runs discord on desktop

#

@brisk thicket PyQT and your woes are gone. pyWxWidgets if you need commercial usage without paying

#

Kivy if you want more eye candy

brisk thicket
#

thx

alpine blaze
#

i though the question was TUI, not GUI

#

there are usually two kinds of TUI, the graphical-like ones, with boxes and things, like curses allows, and the more shell/terminal oriented ones, where you type commands with sometime very neat autocompletion and feedback.

brisk thicket
#

Havenโ€™t looked into the 2 thing suggested. Basically a curses wrapper would suit I think

#

Curses has very poor support for text input without a lot of work I donโ€™t know how to do

keen hornet
#

Try out whiptail, I cant remember whether it was Unix only, but I should be able to give you some python bindings

#

@brisk thicket

brisk thicket
#

ok ill check it out

#

thanks

vast bobcat
#

Guys pls ping me when you wanted to answer

#

Do we have drag buttons in tkinter?

#

I mean like the circles we drag for example in color chooser and then colors change

spare verge
#

I'm trying to use Kivy for the first time and just trying to get a scrollable list of buttons ```py
class MyApp(App):
def build(self):
layout = BoxLayout(orientation='vertical', size_hint_y=None)

    for i in range(50):
        layout.add_widget(Button(text=f'Button {i}', size_hint_y=0.1))

    root = ScrollView(size=(Window.width, Window.height))
    root.add_widget(layout)
    return root```

This is what I have right now but it's very broken and I don't know what direction I should go

#

oh hmm, if I do layout.height = 12345 it kind kinda works

#

not what I want but closer to it

spare verge
#

Update: I just used pyside2 and got it working yert

digital rose
#

@spare verge

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
from kivy.uix.scrollview import ScrollView

class MyApp(App):
    def build(self):
        layout = BoxLayout(orientation='vertical', size_hint_y=None)

        layout.bind(minimum_height=layout.setter('height')) #<-- add this

        for i in range(50):
            #layout.add_widget(Button(text=f'Button {i}', size_hint_y=0.1))
            layout.add_widget(Button(text=f'Button {i}', size_hint_y=None))

        root = ScrollView(size=(Window.width, Window.height))
        root.add_widget(layout)
        return root


MyApp().run()
spare verge
#

I see

digital rose
#

I used to do this using kv and GridLayout, something like this

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button


KV = """
ScrollView:
    size: self.size

    MyGridLayout
        cols: 1
        size_hint_y: None
        row_default_height: '50sp'
        height: self.minimum_height
"""

class MyGridLayout(GridLayout):
    def __init__(self, **kw):
        super().__init__(**kw)

        for i in range(50):
            self.add_widget(Button(text= str(i)))

class MyApp(App):
    def build(self):
        return Builder.load_string(KV)

MyApp().run()
#

Yea, it's not quite intuitive and a little cumbersome, but I suppose it's necessary to keep ScrollView "universal"

btw I think itโ€™s easy (at least definitely possible) to implement a widget that behaves like a simple BoxLayout but has ScrollView behavior

loud mountain
#

How do i make buttons black with PyQt5?

proper glade
#

you can edit its stylesheet

loud mountain
#

ty <3

proper glade
#

no worries

loud mountain
#

i cant seem to get it right, nothings changing color;

#
            self.setAutoFillBackground(True)
            p2 = self.palette()
            p2.setColor(self.backgroundRole(), Qt.red)
            self.setPalette(p2)
proper glade
#

im not sure how youd do it with palette objects but you can use a stylesheet like so:

some_button = QPushButton()
some_button.setStyleSheet('background-color: black; color: white;')
loud mountain
#

so thats html?

proper glade
#

it's qss, basically css with some bells and whistles

loud mountain
#

i see

#

thanks

#

ill try ^^

#

Thank you so much that worked!

proper glade
#

cool cool

vast bobcat
#

Guys pls ping me when you wanted to answer
Do we have drag buttons in tkinter?
I mean like the circles we drag for example in color chooser and then colors change

blazing pine
#

I'm trying to find some reference for "best practices" regarding building PyQt application, specifically to things like logging, good strategies for avoiding breaking C++ Object Already Deleted RuntimeErrors and so on

green badger
#

does anyone have experience in Kivy?

near lagoon
#

@green badger Just ask the question, someone is probably able to help

alpine blaze
#

I do

green badger
#

nvm i figured it out

subtle snow
#

Cool now the rest of us don't get to learn ๐Ÿ˜›

loud sapphire
#

Hi! Anyone know why the dropdown is automatically open, displaying all buttons?

<StationDropdown>:
    id: stations
    Button:
        id: DropdownMainBtn
        text: 'Stations'
        size_hint_y: None
        height: 44
    #    on_release:
    Button:
        text: 'Raadio 2'
        size_hint_y: None
        height: 44
    #    on_release:
    Button:
        text: 'SRF 4'
        size_hint_y: None
        height: 44
    #    on_release:
#

Kivy*

tribal path
#

whats in the py

alpine blaze
#

maybe you want a Spinner, not a DropDown

loud sapphire
#
class StationDropdown(DropDown):
    pass

Thats in the py.

#

Will check out Spinner, thanks

#

So the dropdown is meant to be an all-time-active widget?

alpine blaze
#

it's meant to be dynamically added/removed from the widget tree, using its methods

#

this is what Spinner does

#

i know it's a bit confusing, but DropDown is a low level widget in kivy, kind of an implementation detail of Spinner, which is what people usually want

agile barn
#

Hey im new to python and my img is not appearing using tkinter i have pillow installed and everything but the photo is just not displaying

#
def mainImg(self):
        img = ImageTk.PhotoImage(Image.open("compickerlogo.jpg"))

        label = Label(root, anchor=LEFT, image=img)
        label.pack()
karmic shoal
#

@agile barn I don't think you've placed the img

green badger
green badger
robust marsh
#

on windows, do you know how to launch vscode in debug or verbose mode ?
I had to install in user space, and crash at start (no admin rights).
i've only seen .net Framework requirements (4.5+ and i have 4.8)

agile barn
#

@karmic shoal wdym what am I suppose to do

stoic lynx
#

What GUI does you guys use and what do you recommend

tropic otter
#

Hey, how can i make the left Vertical layout be a fixed size? ๐Ÿค” i wanna resize it so its smaller

mighty frigate
#

@!Pancake#0290 with the designer idk

#

I can tell you how to do it in the code tho

#

(I deeply hate the designer)

#

@stoic lynx I use Qt (QtWidgets to be accurate) because that's the one I know how to use ๐Ÿ˜„

alpine blaze
#

@stoic lynx i use and love kivy (and i'm/have been quite involved in the dev) it's easy to get started with and has a few nice things, like being a python first lib (not a wrapper of a C++ one) which makes it more natural to use in python, it's multiplatform (including android and ios), and it gives the same result on all of them, (though some people would prefer a native-like look on all plateform, i'm not one of them).

loud mountain
#

With PyQt5 i made a calculator, it works.. i just want to be able to type the numbers with my keyboard instead of using the calculator on the screen, so much faster.

#

not sure how i would do that tho.

#

You can press enter and it will calculate the equation but you cant press numbers. ๐Ÿค”

#

(Please do ping me if you know how to help me with this ^^)

stoic lynx
#

@Taste My Frost#5027 how did you learn pyqt5

loud mountain
#

Tutorials and such @stoic lynx

green badger
#

how would i update an image thats in a .kv file every second?

near lagoon
#

The kivy Clock object has a schedule_interval method you could use to call an updating function every second. Would that help? @green badger

green badger
#

@near lagoon Thanks! can you send me a code simple code example?

near lagoon
#

Sure, I only just got home though. Lemme see what I can do

#

@green badger Here's a button that updates its text with a random number every second:

from kivy.app import App
from kivy.uix.button import Button
from kivy.clock import Clock
from random import randint

class RandomButton(Button):
    def __init__(self):
        super().__init__()
        Clock.schedule_interval(self.update_label, 1)

    def update_label(self, dt):
        self.text = str(randint(0, 10_000))

class Test(App):
    def build(self):
        return RandomButton()

Test().run()```
digital rose
#

how would I place gifs there?

alpine blaze
#

@green badger yeah, clock can help, but it really depends on what you want to do and how that widget relates to the rest of the app

#

so if you can give some more context, we might be able to provide a more precise answer

green badger
#

@digital rose what are you using to make the GUI

digital rose
#

@green badger tkinter

#

or something like that

green badger
#

@digital rose next time you should say that. you need to be specific as possible eg

#

"How do i place gifs here in TkIner"

digital rose
#

ah sorry

green badger
#

@digital rose np

digital rose
#

are you familiar with tkiner?

green badger
#

@digital rose I used it once two years ago then frogot about it

amber burrow
#

Besides arcade & pygame, does anyone know of any other relatively-easy-to-use graphics-focused (not tkinter, pyside2, pyqt5...etc) gui libraries?

gentle sapphire
#

Are there any good beginner projects to get started with interfaces? I think I have a pretty decent beginner foundation for python, and am interested in GUI's as I feel like that opens up ALOT possibilities.

alpine blaze
#

@amber burrow did you look at kivy?

#

@gentle sapphire the classical starting project is a notes/todolist manager, but you can get crazy and build other things.

gentle sapphire
#

@alpine blaze I actually made a decent to do list earlier today, and planned on implementing a GUI once I learned how to do it, but if thats a good place to start, then i guess ill start working on it

amber burrow
#

Thanks @alpine blaze , ill look into it

green badger
#

how would i put an image inside a floatlayout that i created inside my kv file

digital rose
#

@green badger

FloatLayout
    Image
        source: '1.jpg'
green badger
#

@digital rose how would i create a image inside a float layout in a kv file inside a python file

digital rose
#

@green badger
what do you mean?
don't you want to use kv file?

green badger
#

@digital rose lets say i create a floatlayout inside a kv file. I then want to create a image inside the aready existing kv file

digital rose
#

@green badger
just add lines

Image
ย ย ย ย  source: 'my_image.jpg'

inside your FloatLayout in kv

green badger
#

@digital rose I want to create the image inside my python file then put it inside the kv file

digital rose
#

The simplest option for what you could do is use the "app" in the kv file as follows:
your kv file

FloatLayout
    Image:
        source: app.image_source

your main file (where your application runs from)

from kivy.app import App

class TestApp(App):
    image_source = '1.jpg'


TestApp().run()

although itโ€™s not always convenient

hoary oxide
#

Hey guys, it's my first time working with GUI's and BS4, and I'm trying to display this HTML in a QTextBrowser (using PyQT5).
My current code to display the html is:

        soup = BeautifulSoup(source, 'lxml')
        table = soup.find('table')
        self.textBrowser.append(str(table.prettify()))```
#

I'm trying to display the schedule of the soccer team Tottenham FC

#

I want to remove all timezones, and only only display the EST one, which I found here:
timeZone = soup.findAll("span", {"class":"shsTimezone shsESTZone"})

hoary oxide
#

Any help?

alpine blaze
#

@green badger the other way is to give an id to your layout and to refer to that id in the python code, if the id is in the root rule, you should be able to use app.root.ids.the_id and use add_widget on it, to create a new image widget with the source inside, if it's not in the root rule, then you do need to get a reference to the widget for that rule, usually giving it an id in the rule that contains it, up until you are back at the root rule, so you can use app.root.ids.some_id.ids.some_other_id.ids.the_id or something like this.

rocky dragon
#

a recent convo reminded me about a problem I wanted to get to a few months ago, can I tell Qt to only keep a single instance of a window or delete it after it's closed?
say I create it like this

    def end_route_pop(self):
        w = popups.RouteFinishedPop(self.main_window)
        w.show()
        w.close_signal.connect(self.main_window.disconnect_signals)
        w.new_route_signal.connect(self.new_route)

that runs fine but when the window is closed it stays in memory, while not much of a problem because tens of thousands of them would need to be opened to have a noticeable inpact, it's still I'd like to avoid

lyric cave
#

hallos, I'm looking for ideas for doing this better!
I'm just printing the status of some workers in a loop.
I'm interested in whether there's a better version of doing the screen update

โ ผ 2
โœ“ 3
โœ“ 4
โ ผ 5
โ ผ 6
โ ผ 7
โœ“ 8
โœ— 9: Error: ...
โ ผ 10
from blessings import Terminal
...
term = Terminal()
while True:
    ....

    for work, position in active_workers:
        with term.location(x=0), term.hidden_cursor():
            print(term.move_up * position, end="")
            print(f"{work.status} {work.name}", end="")

    ....
    sys.stdout.flush()
    sleep(...)
kind kraken
#

you could use curses but that might be overkill

#

I'd probably clear the screen and include y=0 in term.location

#

instead of the move_up * position

#

that or get it all on one line (maybe skip printing the error information, i don't see how you're doing that) and just use '\r' instead of any library at all

#

oh, you can probably switch the term controls and the for loop

#

and just print them in order

#

hmm or something like py print('\n'*len(active_workers)+term.move_up*len(active_workers)) # clear space while True: with term.location(), term.hidden_cursor(): for work, position in active_workers: print(f"{work.status} {work.name}") # just print them on each line normally, the end of term.location() will move back to the top for the next time sleep...

#

@lyric cave

lyric cave
#

Well, the organization of the information is preferential. The error information presented magically through str, I just elided that.
I mostly care about alternative versions of terminal positioning.

What would curses look like for updating a line at worker_position? And would it work on Windows too?

kind kraken
#

i have no idea how or if blessings works on windows

lyric cave
#

It do! :D

#

But, is curses maybe a better way to do this than blessings?

kind kraken
#

like i said, curses might be overkill, it's a full screen management library rather than just moving the cursor

#

which lets you avoid garbage on the screen in edge cases like "what if an error message makes one of them take up more than one line"

#

just clearing the screen, and drawing the statuses from the top of the screen instead of near the bottom, might help with that too though

#

anyway