#user-interfaces

1 messages Β· Page 53 of 1

solid dome
#

Guys ,I want to structure my pyside2 project. This is the folder structure that I am thinking to go with. I am creating a gui using qtdesigner and then exporting it to python program so I wont be using .qml files for gui . There is utils folder for all utility funtions and also a resources folder where I will be placing all the icons and images to display on the gui. I will run my project using the main.py file. There will also be files that will be exported using the application. while the project will run normally using the terminal but if I am going to package my project using pyinstaller I am not sure it is going to function properly. If anyone of you have used pyinstaller before can suggest me how my folder structure should be and how I can package my project using pyinstaller using same folder structure
project /
utils /
init.py
file1.py
file2.py
views/
init.py
window1.py
window2.py
resources /
init.py
images/
icons/
exported_docs/
file1.csv
file2.csv
main.py

lofty wyvern
#

Am I using this correctly?

user = user_name_ent.get()
password = user_pass_ent.get()

ok_button = tk.Button(master=confirm_buttons_frm, text="OK", 
                      command=lambda: create_user(user, password))

The create user function works independently just fine, but the parameters are not passed to the SQL DB.

safe cipher
#

Lambda has arguments too

#

lambda user, password: create_user(user, password) for example

lofty wyvern
#

That was just me trying something out. Even without the lambda the data is not passed

#

This is it now

ok_button = tk.Button(master=confirm_buttons_frm, text="OK", 
                      command=create_user(user, password))
#

Might be something else in my code, I'm only a week in and no formal training

safe cipher
#

yeah, you have to get user and password from somewhere

#

Where do you define the 2 vars?

#

and also, this wont work as you have to pass a callback and dont call it

lofty wyvern
#

About 10 lines up

user_info_frm = tk.Frame(master=new_user_window)
user_name_ent = tk.Entry(master=user_info_frm, width=25)
user_name_lbl = tk.Label(master=user_info_frm, text="New user name")

user = user_name_ent.get()

user_pass_ent = tk.Entry(master=user_info_frm, width=25)
user_pass_lbl = tk.Label(master=user_info_frm, text="New user password")

password = user_pass_ent.get()
safe cipher
#

and whats the issue? the params do get passed, but it instantly gets executed

#

lambda should work tho

#

(the first implementation)

lofty wyvern
#

I have a function built that takes that info and puts it into an SQL data base. The other info that is defined inside the function is added but nothing but blanks in the user and pass fields

static cove
#

Do you have multiple tk.Tc() instances by chance?

lofty wyvern
#

No, not anywhere in the code

static cove
#

So this issue is that the .get() functions aren't grabbing what's inputted into that entry box or that the information isn't get appropriately saved to the db?

lofty wyvern
#

correct

static cove
#

!paste could you paste your full code here?

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.

lofty wyvern
#

I might have messed some stuff up trying to fix it

#

I can link the working code I had yesterday that the function is based on, it's saved on git hub.

static cove
#

In your create_user() function, you re-define user and password to "", overwriting whatever is passed in

lofty wyvern
#

Yeah, that was something I added trying to fix. I removed them and its the same issue

static cove
#

well, you definitely want to use the lambda in that command= call you had earlier

lofty wyvern
#

gotcha, let me try readding that without the arguments in the function

static cove
#

OH. I know what the issue is

lofty wyvern
#

πŸ‘€

static cove
#

You want your command code to be:

ok_button = tk.Button(master=confirm_buttons_frm, text="OK", 
                      command=lambda: create_user(user_name_ent.get(), user_pass_ent.get()))
#

the GUI only launches once your code reaches root.mainloop(), anything before that is run before the user can even interact with it

#

So your code where you grab the user and password is done before the user has entered anything, hence why it's returning the blank strings

#

The code above will only pull the values from the entry boxes when the user presses the button

lofty wyvern
#

Awesome, I'll check that as soon as I get back. Thank you! I'm still very new to this. You rock

static cove
#

No worries~ happy to help

buoyant tendon
#

Hey! I'm trying to make a GUI in PyQt5 for editing a JSON list of hundreds of thousands of words. Since the list is so long, it's literally impossible to display it all in one label without it crashing, which is to be expected. So, I thought a good workaround would be to use tabs that dynamically load a long enough list of words where it is just short enough to not crash (however, at the moment I am just displaying 64 words per tab). I was originally going to use QTabWidget but I realized that it needed to have all the tabs in memory for it to work, which is even worse than just the list. However, I found that I can create just a QTabBar by itself to avoid this. But, for some reason, my QTabBar isn't emitting the currentChange() signal when I switch tabs. Any ideas what I am doing wrong? Or is there any better ways to do this? Sorry if my code is messy, I'm very new to Qt so only got the hang of it a few hours ago lol
Here's my full code at the moment: https://hastebin.com/orepuzodey.rb

static cove
#

@buoyant tendon Are you actually using a QLabel or something like QTextEdit/ QTextBrowser?

buoyant tendon
#

I don't know what QTextEdit or QTextBrowser are so a QLabel πŸ˜…

static cove
#

So I highly recommend using a QTextEdit. It'll be better suited for displaying a list of text items.

buoyant tendon
#

I feel like there will be no possible way to display 600,000 words at once without significant lag, though

static cove
#

mmmm, let me test something real fast

orchid yoke
#

Is it better to store settings for an app in json?

buoyant tendon
#

Could you please explain how QTextEdit would do this? As far as I can tell, it just makes you able to have both rich text and standard text in one object, which is anything sounds like it would be worse for performance

stoic vale
#

Is it better to store settings for an app in json?
Some app like Visual Studio Code do it.

buoyant tendon
#

It's also worth noting I plan on making each of these words selectable so you can run functions on many words at once (deleting them from the list, duplicating them, making a filter with them...)

stoic vale
buoyant tendon
#

Let me have a look

stoic vale
buoyant tendon
#

That's a lot of code and information @_@ I don't quite know what I'm supposed to be looking at

static cove
#

I mean, QTextEdit works for me. It takes a bit to do ctrl+c and ctrl+v and it takes a bit to spin it up, but I don't know how you'd get past that with over half a million words.

stoic vale
#

I just give you some examples of building a text editor in QT.

buoyant tendon
#

Well, surely the option would just to be to display only a small amount of words at any one time, which is what I was originally trying to do?

static cove
#

Well you said it was literally impossible to display it without crashing, which is not the case with QTextEdit.

But for the signal not emitting, can you post your code for how you're using the signal?

buoyant tendon
static cove
#

I don't see where you actually connect to the signal though. Are you familiar with how Qt's signal/slots work?

buoyant tendon
#

As far as I knew, I was just overriding a function on the parent class and when an event occurs, that function is called? It worked for resizeEvent so I thought it would be the same for the currentChange one

static cove
#

That's not really how Qt's signals/slots are intended to work

#

There is a currentChanged() signal for QTabBar

#

Uhm... let me write up a quick example for how it's typically supposed to be used

#

I think that'll be the clearest way

buoyant tendon
#

Alright, thank you πŸ˜„

static cove
#

give meeeeee 3 minutes

#

@buoyant tendon Check out this code for how to connect your own function to a pyqt signal. It's super basic but hopefully it's clear.

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

import sys


class MainWindow(QMainWindow):

    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.mywidget = QTabBar()

        layout = QVBoxLayout()
        
        # Setting up a super basic QTabBar with 2 tabs
        layout.addWidget(self.mywidget)
        self.mywidget.insertTab(0, "Tab 1")
        self.mywidget.insertTab(1, "Tab 2")

        # Let's connect to the signal 'currentChanged' and attach it to our own function 'tab_changed'
        self.mywidget.currentChanged.connect(self.tab_changed)
            
        # Adding it to the layout
        widget = QWidget()
        widget.setLayout(layout)
        

        self.setCentralWidget(widget)
        
    def tab_changed(self, *args):
        print("tab changed!")
        print(args)


app = QApplication(sys.argv)

window = MainWindow()
window.show()


app.exec_()
#

mmmm probably should've paste bin'd that but oh well

buoyant tendon
#

Ah, so I don't even need a need class for it πŸ˜„

#

Thank you so much, let me try it πŸ‘

static cove
#

It's still useful to subclass if your tabs will have unique functionality, but yeah. That's how you connect your own functions to the signals emitted by the default classes.

#

If you make your own subclasses you can also add your own signals which is useful

#

You'd typically only need to override the existing signals if you want to fundamentally change behavior that pyqt does.

#

It's not common that you'd need to do that

buoyant tendon
#

Makes sense

static cove
#

I really like the design behind pyqt's signals and slots~

buoyant tendon
#

It works πŸ˜„ Thanks so much πŸ‘

plush stream
#

How do i close all my secondary window when i close my main window? I have three window classes; QMainWindow and two QWidget

bronze basin
#

@plush stream

#

you can connect the close function i am pretty sure to another function as well as the self.close() functtion

#

so inside that function you can make an instance of your other classes or windows

#

and close them all there as well

plush stream
#

Okay thanks, but how do i connect the close button in the title bar? I know how to do it in tkinter but not in pyqt

bronze basin
#

wdym @plush stream

#

are you using the standard windows title bar

#

the method i said for will work well with a custom title bar and custom close button

plush stream
#

Yes i did

bronze basin
#

i am not sure how to do it for the standard title bar

#

maybe look it up

#

but should be the same way i said except the button or connecting will be different

#

i suppose

plush stream
#

Okay, thanks πŸ‘

bronze basin
#

np

digital rose
#

in tkinter, is it better to to:
a = Label(root, text="hi")
a.pack()
or:
a = Label(root, text="hi").pack()
?

inner nest
#

first method is more readable i think especially if you add some parameters on pack() method

brittle hull
#

I'm stuck trying to plot realtime data, could someone give me a hand?

static cove
#

What framework are you using?

brittle hull
#

Umm, I'm working on Pycharm. I have tried to plot with pyplot and with pyqtgraph (that you mention a few days ago). Sorry if I don't answer properly, I'm a newbie πŸ˜†

#

This is a part of the script:

import pyRofex
import pandas as pd

AL30_T2 = "AL30 - 48hs"
AL30D_T2 = "AL30D - 48hs"

tickers = [(AL30_T2, None, None, None, None, None),
(AL30D_T2, None, None, None, None, None)]

Create empty DataFrame to store Data

prices = pd.DataFrame(tickers, columns=["Ticker", "Time", "Price"])

Initialize the API connection

pyRofex.initialize(config.user, config.password, config.account, pyRofex.Environment.REMARKET)

def market_data_handler(message):
prices.loc[prices['Ticker'] == message["instrumentId"]["symbol"], 'Time'] = message["marketData"]["LA"].get("time", None)
prices.loc[prices['Ticker'] == message["instrumentId"]["symbol"], 'Price'] = message["marketData"]["LA"].get("price", None)

pyRofex.init_websocket_connection(market_data_handler=market_data_handler)

pyRofex.market_data_subscription(
tickers=[AL30_T2,
AL30D_T2],
entries=[pyRofex.MarketDataEntry.LAST],
depth=1)

#

It's a websocket connection that received market data from two items. I need to graph the timestamp in the x-axis, and the price in the y-axis, like a time series; I've tried to update the plot but I couldn't. Sorry if my message it's too long or not proper

static cove
#

So which plot are you using for the script?

brittle hull
#

i trying with pyqtgraph, beating my head against a stone wall

static cove
#

So, overall your code should probably be structured something like:
function that receives/pulls data --calls--> function that processes data --calls--> update your pyqtgraph data + call .processEvents() to get the graph to update

brittle hull
#

Done! great help, greatly clarifying

#

pw = pg.plot()
while True:
pw.plot(date, price, clear=True)
pg.QtGui.QApplication.processEvents()

And works! just need to beautify the x-axis πŸ˜†

digital rose
#

how to insert something into a text widget in tkinter?

#

just text.insert('text_to_insert')?

#

assuming text is the widget name

#

welp, didn't work

#

ok i figured it out πŸ‘

#

thanks again for the help

urban coral
#

Guuuys why isn't Kivy installing on Manjaro Python 3.8.5 , and it gives ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output....Any solutions? On windows this gave the same error, but when I tried Python 3.6 , it works

#

(The Kivy installation Python 3.6 works on windows , not sure about linux)

urban coral
#

Oh nvm it worked with yay -S python-kivy

tribal path
#

pip install --pre kivy[base]

lofty wyvern
lyric nebula
#

can i send emails through tkinter, not to spam or anything as i dont wanna break rule 5 but for something like app verification?

lost tangle
#

i am building a kivy app for android and the app needs internet, while packaging the app
Buildozer doesn't add the permissons i specify to the Manifest. So the app now can't access the internet ? anyone faced this ? how to fix this ?

undone knot
#

hi

tribal path
#

What permission(s) are set in your spec?

lost tangle
#

What permission(s) are set in your spec?
@tribal path INTERNET

#

isn't that how i do it ?

#

the permission i need is android.permission.INTERNET in the manifest.

tribal path
#

Uncommenting the permissions line in the spec will provide that

lost tangle
#

Okay.. Thankyou.. i will try

tribal path
#

You may hit certificate issue, for which you need to use certifi, see first if just that permissiin is all that was needed

zealous zenith
#

Hi guys i have a question.
My class and I are building a room finder for our school building with voice command. As i am in the coding and UI/UX team we are currently looking for a GUI librarie which can both show text formatted well and display images easily. In the best case scenario wallpapers are also easy to programm.
If you guys have any suggestion on which libary to use i'm happy to hear them πŸ™‚
P.S. as obvious it should be MEGA complicated

echo swan
#

tkinter?

lost tangle
#

You may hit certificate issue, for which you need to use certifi, see first if just that permissiin is all that was needed
@tribal path i faced it and fixed it by setting an environment variable..

tribal path
#

Yea its a straight forward enough fix, especially with certifi

lost tangle
#

Yea its a straight forward enough fix, especially with certifi
@tribal path when i try to install it in my emulator i get INSTALL_FAILED_NO_MATCHING_ABIS

tribal path
#

What arch is the emulator? x86_64 I assume, havent used emulators in a while so didnt know they were that restrictive. An actual emulator like bluestacks/nox would run them fine. So either that or create an arm/64 emulator I if I assumed correctly

lost tangle
#

I am using Anbox(linux)

tribal path
rose trench
#

Hello

#

I need help installing TKinder

#

I have re-installed Python

static cove
#

What OS are you on?

rose trench
#

Windows

#

I have tried using pip

static cove
#

Then it's part of the standard library, you shouldn't need to install it

#

In your script you just need to something along the lines of import tkinter as tk

rose trench
#

oh

#

thx

#

i was doing the commad wrong

silver kelp
#

How do I do so that the text of the label changes every second?
I tried using time.sleep(1) but it doesn't work. I'm using PyQt5 and Qtdesigner it

rose trench
#

wdym

#

in tkinter?

neon ibex
#

in tkinter how do i insert to an entry what is said on a button

#

so lets say i have the number 5 on the button and a number 1 on a button, when i press one or the other (there are a total of 9 buttons) i want to print what is said on the button

#

i could show you what i mean through a code

rose trench
#

im fairly new to this,
but i think i get it

#

i'll be a bit, i need to find something

neon ibex
#

so anyway here is the code

#
 self.exit_button = Button(master, text = "Exit", pady = 20, padx = 20, command = master.quit) 
        self.exit_button.grid(row = 2, column = 0) 
        self.clear_button = Button(master, text = "CE", padx = 20, pady = 20, command = self.clear_entry)
        self.clear_button.grid(row = 2, column = 1)
        self.zero = Button(master, text = "0", command = self.insert_number)
        self.zero.grid(row = 3, column = 0, ipadx = 25, ipady = 25)
        self.one = Button(master, text = "1", command = self.insert_number)
        self.one.grid(row = 3, column = 1, ipadx = 25, ipady = 25)
        self.two = Button(master, text = "2", command = self.insert_number)
        self.two.grid(row = 4, column = 0, ipadx = 25, ipady = 25)
        self.three = Button(master, text = "3", command = self.insert_number)
        self.three.grid(row = 4, column = 1, ipadx = 25, ipady = 25)
        self.four = Button(master, text = "4", command = self.insert_number)
        self.four.grid(row = 5, column = 0, ipadx = 25, ipady = 25)
        self.five = Button(master, text = "5", command = self.insert_number)
        self.five.grid(row = 5, column = 1, ipadx = 25, ipady = 25)
        self.six = Button(master, text = "6", command = self.insert_number)
        self.six.grid(row = 6, column = 0, ipadx = 25, ipady = 25)
        self.seven = Button(master, text = "7", command = self.insert_number)
        self.seven.grid(row = 6, column = 1, ipadx = 25, ipady = 25)
        self.eight = Button(master, text = "8", command = self.insert_number)
        self.eight.grid(row = 7, column = 0, ipadx = 25, ipady = 25)
        self.nine = Button(master, text = "9", command = self.insert_number)
        self.nine.grid(row = 7, column = 1, ipadx = 25, ipady = 25)
#

i have nine buttons here

#

each has a text on it

#

when that specific button is clicked i want to be able to print its text on the screen

#

hmmm let me try this

rose trench
#

hmm

neon ibex
#

i was thinking of adding all of these variables to a tuple

#

or a list

#

but more a tuple because it is immutable

#

so anyway i was thinking of adding it to a tuple and making that tuple with all those variables an instance of the Button class

#

then i could just do this

static cove
#

@silver kelp You want to use QTimer, not time.sleep

neon ibex
#

but i dont know if i could do it

rose trench
#

umm

neon ibex
#

anyway if somebody knows how to do it thanks for helping

rose trench
#

this is what i have so far:

import tkinter as tk
from tkinter import *

def printSomethingelse():
for x in range(1):
label = Label(root, text= str(2))
label.pack()

def printSomething():
for x in range(1):
label = Label(root, text= str(1))
label.pack()

root = Tk()

button = Button(root, text="1", command=printSomething)
button.pack()

button = Button(root, text="2", command=printSomethingelse)

root.mainloop()

#

It shows a button saying 1 and when you click it,
it prints 1

#

Other than that,
I can't really help
sorry

neon ibex
#

yeah thats too long

#

i need it short

#

that would be many lines of code

#

if it was shorter i would do it that way but now in this case it would be too long.

rose trench
#

even if you removed the spaces?

neon ibex
#

yes there r 9 numbers

#

i would need to write 9 different methods (because it is in a class)

rose trench
#

oh well

#

I hope your issue gets resolved

neon ibex
#

its ok thanks for helping. your way is not bad, its just that now i have 9 numbers

#

if i would have 2, your way would work very well

#

but now i need a shorter way because i dont want to write extra lines of code

rose trench
#

I'll keep looking

amber roost
#

this could be a solution if you fit self.insert_number accordingly

self.btns = []
for i in range(11):
    def _handler(n=i):
        self.insert_number(n)
    btn = tk.Button(master, text=str(i), command=_handler)
    btn.grid(row=3+i//2, column=i%2, ipadx=25, ipady=25)
    self.btns.append(btn)
neon ibex
#

haha

#

there

amber roost
#

using the _handler like that for default arguments is super icky but unfortunately the only way

neon ibex
#

yeah

rose trench
#

do you need to import more modules than tkinter

#

to use that code

neon ibex
#

i dont think so

rose trench
#

i get a error:

NameError: name 'self' is not defined

neon ibex
#

for me it works

#

thanks @amber roost

#

@rose trench thats because you need to create a class

#

copy this code

#

and dont do it idle please dont

rose trench
#

idle?

neon ibex
#

yeah u r using idle

rose trench
#

what is idle

#

ooh

#

why not?

neon ibex
#

idle is the python REPL

#

you use it do run test code and stuff

#

but you shouldnt use it for long code and stuff

#

you can use idle for simple statements

#

like if statement a loop, etc

#

i use idle to test some things out

rose trench
#

my pc takes too long to load a ide if thats what your saying

neon ibex
#

its really good because you dont have to save the code on your pc

#

idle is not an IDE

#

it is an REPL

#

read evaluate print loop

#

it is usually used to REPL (read evaluate print loop). idle is really good to start learning python and to learn the basics of it

#

after IDEs come in handy once you start making projects like tkinter projects

#

but you can always use the editor within IDLE

rose trench
#

i just use that to write code

#

run it

#

and before i show it

neon ibex
#

yes

rose trench
#

I open it with the cmd thing

neon ibex
#

thats what u use

#

exactly

#

that is IDLE's built in text editor

rose trench
#

ok good

neon ibex
#

anyway copy the code i sent

#

and you will see that it does work

rose trench
#

oh wow

tribal path
#

Idle is itself a tkinter app

neon ibex
#

i actually didnt know that

#

wow

#

cool

rose trench
#

thats good

neon ibex
#

its a pretty simple code

#

the only complicated part was what i needed help with

rose trench
#

your code is not simple for me

#

lol

neon ibex
#

how long have you been programming

rose trench
#

like 11 months

neon ibex
#

thats good

rose trench
#

i don't think it is that long

tribal path
#

(Its of note as running in idle, you can get away with note stating a mainloop as idle is already running one)

neon ibex
#

i started python 3 years ago, i did 3 months of python then i stopped and then, i came back to it now so basically i have like 6-7 months of programming

#

it was very hard for me 3 years ago

#

so i stopped

#

but now i understand it better

rose trench
#

lol i have stopped for 3 months and now i started again

neon ibex
#

thats good

#

how r u learning

#

youtube is good

rose trench
#

I've got 2 coding books

#

And the internet

neon ibex
#

nice thats how i am learning

rose trench
#

But i havn't looked at youtube

#

I'll see

neon ibex
#

i bought automate the boring stuff

#

really sick book

rose trench
#

lol

#

I had a very nice book

#

but i lost it

neon ibex
#

i also bought a book from one of the people in the server

#

paul craven

#

his book is rlly good as well

#

and i bought a book by matt harisson

rose trench
#

I can't get them unless there in whsmith : (
I'm currently reading this python book from Mike McGrath
Im on 2nd edition,
I skipped the first

#

I knew lots of book 1

kindred ferry
#

How can i change the color of the QPushButton widget with the colour i choose in colorPicker dialog?

neon ibex
#

nice

rose trench
#

colorPicker?

#

Do you mean the color of a tkinter button?

kindred ferry
#

Not tkinter i mean pyqt5 button

rose trench
#

sorry i cannot help

normal wing
#

hey guys, does anyone know how to pack widgets next to each other in tkinter? like side by side? I have an app that packs everything going down, like a list, but there is one widget that I want to be to the right of another

kindred ferry
#

Pyqt5 or tkinter ?
@normal wing

normal wing
#

tkinter

kindred ferry
#

Use attributes side="left"on all widgets u want to stack side by side
Maye this can help

normal wing
#

so like "button1.pack(side='left')"?

wooden osprey
normal wing
#

your variable is capitalized, like "Width", but when you set it, you used a lower case "Width=width"

#

so just change your variable "Width" to a lowercase w

#

on line 10

#

@wooden osprey

wooden osprey
#

ohh thks

viscid crystal
#

I'm compiling my application with PyInstaller, but it keeps crashing in certain situations. To debug this I pass the -c option to PyInstaller, but it doesn't lock the command line.

teal hearth
#

HI guys , totally new to UI dev in python. where is a good place I can learn about PyQT ? I am using this to create some VFX tools . if anyone know anything about that also would be helpful

silver kelp
#

I learnt the basics of PyQt5 from Tech with Tim's YouTube channel.

normal wing
#

tech with tim is cool

distant sand
#

Hello. So the scenario is that I’m trying to link a python script as backend to a front end. How do I make a front end with very decent UI. Like what language and how do I link it with python

#

No tkinter please no

#

Something that looks more like in this century

#

Please

bronze basin
#

Pyqt/Pyside2

#

or you can use eel to develop front end with css/html/js and connect backend with python

#

recommend you search these up to get a good idea on what you want to use

echo swan
#

No tkinter please no
Something that looks more like in this century
Most framework can be customized to whatever look you like. Just going with default is sorta like using HTML without CSS

fluid tinsel
#

The more you know about tkinter, the worse it becomes.
not really good if you’re planning to make anything advanced.

echo swan
#

Well... can't say I have a lot of experience with it

#

so you might be correct

#

was just commenting on the fact that he thinks it looks outdated

amber roost
#

if you punch it in the right ways, you can make tkinter look really decent

#

although it will involve ttk's create_image command and that always slows down redrawing upon window resize really heavily

fluid tinsel
#

it has very low resolution and quality

granite escarp
#

Popen(['ssh','-o' ,'StrictHostKeyChecking=no','-R','80:localhost:8080','ssh.localhost.run'],stdout=open('link.url','w'),stderr=DEVNULL)
This causes the stdout to hang , is there any way to perform this in the background , without halting the main program/stdout.

digital rose
#

guys i need help w tkinter & time module

#

how do i get a countdown to display on my tkinter window using the time module

#

this is what ive done

#
from tkinter import *
import tkinter as tk
import time

window = tk.Tk()
window.geometry("200x200")
timer = 0
def timer_test():
    global timer
    while timer != 10:
        timer += 1
        time.sleep(1)
        window.update()
        return timer
lbl = Label(window, text=timer)
lbl.pack()

window.mainloop()
#

it only displays a 0 on my window thats all

#

please help

digital rose
#

bc you don't call the function @digital rose

digital rose
#

yea but theres more issues too

#

heres the solution

#
from tkinter import *
import tkinter as tk
import time
window = tk.Tk()
window.geometry("200x200")
timer = 10 + 2
lbl = Label(window, text=str(timer))
def timer_test():
    global timer
    while timer != 0:
        timer -= 1
        time.sleep(1)
        lbl.configure(text=str(timer))
        lbl.pack()
        window.update()
        
timer_test()
lbl.pack()
window.mainloop()
static cove
#

@digital rose you're calling your timer_test() function before you GUI can even run. You want to call it through a button press probably

digital rose
#

@static cove can you fix the code and send it to me here?

static cove
#

So, what do you want your code to do? You have a timer, but it's unclear how you want to start/stop the timer

digital rose
#

i just want it to countdown

#

i have a project in mind

#

i just want to get this component clear

visual stag
#

I'm trying to port a Tkinter-based folder picker to Gtk, and while this works it seems to hang. It looks like I'm supposed to use GObject.idle_add() to make it immediately show the dialog but I'm not sure where to add it ```python
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

def select_directory(title: str):
dialog = Gtk.FileChooserDialog(title=title,
parent=None,
action=Gtk.FileChooserAction.SELECT_FOLDER)

dialog.add_buttons(Gtk.STOCK_CANCEL,
                   Gtk.ResponseType.CANCEL,
                   "Select",
                   Gtk.ResponseType.OK)

response = dialog.run()

if response == Gtk.ResponseType.OK:
    result = dialog.get_filename()
else:
    result = ''

dialog.destroy()

return result

directory = select_directory('Select Ren'Py Projects Directory')

print(f'Directory selected: {directory}')

#

Anyone know how to improve this?

cunning sedge
#

im trying to use pyqt5 to display a video, but whenever i tried to play it i always got an error saying DirectShowPlayerService::doRender: Unresolved error code 0x80040266 (IDispatch error #102). i searched this up and one of the solutions was to download the K-Lite codec pack, is this safe?

static cove
#

@digital rose well, it'll be easier if you create a class for your window, otherwise we can start the countdown with a button press

digital rose
#

@static cove may i dm you?

cunning sedge
#

@smoky crag why is it as an exe?

#

?

static cove
#

@digital rose I'd prefer to help in this channel or in one of the help channels.

inner nest
#

@digital rose try to avoid update method on your app Root because its already a big loop. You can use After() method or update_idletask instead.

digital rose
#

alright

#

thx

inner nest
visual stag
#

@inner nest I actually borrowed snippets from that page to make the folder chooser. Even when I copied the whole example and ran it, it would hang for about 10s after clicking the button before opening the picker dialog

opal geyser
#

Hello. So the scenario is that I’m trying to link a python script as backend to a front end. How do I make a front end with very decent UI. Like what language and how do I link it with python
@distant sand pyqt5

deep sentinel
#

What do yall suggest Tkinter or Gi? or are they for diff applications.

teal hearth
#

Hi Guys I have a OOP question . its regarding the super() method.

I know the following usage of super()

     def _init_(self, var_1, var_2, var_3 ):
         super()._init_(var_1, var_2)
         self.var_3 = var_3```

so in this case the super method says to get var 1 and 2 from the ParentClass and the var 3 from the this _init_ method right ? I just saw some code where it was like below.

```class MainWindow(QtWidgets.QMainWindow):
     def _init_(self):
         super(MainWindow, self)._init_()```

this time the variables are inside super(....) and not super()._init_(.....) like before. I am confused at what this is doing ? any help is appreciated
tawdry idol
#

@teal hearth they're two different things

#

notice that in the first case stuff is passed to __init__

#

and in the second case stuff is passed to super()

#

and in the second case stuff is passed to super()
@tawdry idol this is, loosely speaking, to help super() find out which superclass you want the __init__ from

#

in the first case you could well do super(MyClass, self).__init__(var_1, var_2) (incidentally, note that it's two underscores, so your code is wrong)

#

for the same effect.

#

and I believe that was necessary in Python 2, but no longer

#

look up help(super), that might help.

teal hearth
#

@tawdry idol thank you . yeah I mispelled the double underscore. sorry. so If super(MainWindow, self).__init__() means which super class I want __init__ from . why am I supposed to define it in the MainWindow class it self. I am already inside the MainWindow class and in the init function as well. why do I need to explicitly say that there ? to prevent it from accessing the Qt.Widgets.QMainwindow class's init function ?

tribal path
#

Yea its unneeded in py3. Its py2 syntax, but will work in py3 as well. If you dont need to add code to the subclassed init, you dont need to define one at all

cedar crescent
#

Hi, I have been advancing my Python knowledge with some textbooks and tutorials for a considerable time. I have been using VSCode and happy with it so far.

#

I am now setting my environment for web and data science projects.

#

To me it seems like the only thing I need as an extra is Jupyter, but should I really need to install Anaconda or an IDE such as Pycharm?

bronze basin
#

no you can use jupyter in vscode

cedar crescent
#

@bronze basin which extension specifically?

bronze basin
#

@cedar crescent

#

no extension i dont think

#

its in-built with the pylance extension or with vscode itself

#

this should solve your queries

hollow pewter
#

why is sqlite3 so slow?
sometimes it workes fine, but other times:

    @timing
    def update_setting(self, setting: str, value) -> None:
        self.cursor.execute(
            f'UPDATE settings SET {setting}=:value',
            {'value': self.real_to_sql(setting, value)}
        )

where @timing is (it prints the time the function took to run):

def timing(f):
    def wrap(*args, **kwargs):
        time1 = time.time()
        ret = f(*args, **kwargs)
        time2 = time.time()
        print('{:s} function took {:.3f} seconds'.format(f.__name__, (time2-time1)))
        return ret
    return wrap

printed

update_setting function took 3.557 seconds
!!!

note that sometimes this function only takes like 0.005 seconds to run.

the table settings only contains one row, then why does it take so long??

I am using multithreading with qt

any ideas?

maiden dragon
#

is there a clean solution for this error

File "<COMObject <unknown>>", line 2, in Item
pywintypes.com_error: (-2147417842, 'The application called an interface that was marshalled for a different thread.', None, None)
#

found something on stackexchange that explains whats going wrong but nothing on how to fix it

#

!paste

#

https://paste.pythondiscord.com/kehuruxuyu.rb The problem I would like to solve is that each of these update functions take like 2-4 seconds to run and that is way too slow especially when they are in series. it takes something like 10-20 seconds to run them. id prefer running them all in about 1 second but idk if i could ever acheive speeds that fast\

cedar crescent
#

@bronze basin Exactly! Thank you!

tacit ravine
#

Has anybody attempted to use PyForms? It looks like a really attractive option for GUI dev - especially for newbies who have trouble learning tkinter at the same time as the rest of python

kindred ferry
#

I use pyqt5..and it's a great for making mordern ui too..i want to know is there any way to detect my mouse when it's over an targeted widget?
I mean i want to open a menu when the user just keep the cursor on that button..?

bronze basin
#

@kindred ferry

#

Usage: widget.underMouse()

#

(connect to a function like : self.function)

#

for examle

kindred ferry
#

@bronze basin
Yeah i got it..
UnderMouse( ) function only return bool type so we have to make an loop and if statrments to get my work done

lavish trail
#

Anyone particularly knowledgeable in Blender Python scripting or might be able to point me to a specific discord more geared towards that area of application. I am currently working on an addon for Blender that utilizes python and stuck on pie menus, specifically operators and enum properties. What i'd like is a pie that has 8 options in the center with set of side buttons on a panel to control which set of 8 options is showing. I am not quite entirely certain how to phrase this into a question on stack overflow so must of my searches there have only taken me so far. Any help is greatly appreciated, if not just a point in the right direction towards who might know.

eager beacon
#

@lavish trail

lavish trail
#

Not yet.

eager beacon
#

I'd imagine its probably the best place for something specific like that. I haven't seen many mentions of Blender/Nuke or any other VFX related stuff on this server

wooden latch
#

Uhmm

teal hearth
#

@lavish trail I am doing blender Dev as well. you should checkout that earlier sent discord plus the blender developer chat

ruby pawn
plush stream
#

How do i set the opacity of the whole ui in pyqt? (excluding the window)

#

If i use the self.setWindowOpacity() it will set the opacity of the whole thing including the title bar

ruby pawn
#

Okay I've gotten a little further, is there a way to get all children of a PySide2.QtWidgets.QWidget object?

eager beacon
#

findChildren

ruby pawn
#

Thanks, I found out I could do what I needed by using .layout() on the QWidget

eager beacon
#

@plush stream you need to create a custom frameless widget and it needs a widget to mock the functionality of a title bar. Then use the custom window to wrap your widget

#

if you do that you can apply the transparency to all but the title bar or just certain portions of the UI

plush stream
#

I see, thanks

sonic sonnet
#

is it possible that i made a calculator.py where i made a simple calci which didnt had gui
so if i made another file.py where there is a gui interface
so am i able to write an open function to open my gui in my calci

timid ether
#

Is there a python module or built-in function to automatically swap active window/program when a python script is launched? Let's say I want windows to bring photoshop to the foreground automatically when the script starts.

inner nest
#

@sonic sonnet sure, you can make a call from like button gui to your calculator function

lofty wyvern
#

I am attempting to make my life easier by generating input fields with a for loop:

        
        for y in self.data_needed:
            self.row=tk.Frame(self.user_data_info_frm)
            self.lab=tk.Label(self.row, width=15, text=y, anchor='w')
            self.ent=tk.Entry(self.row)
            self.input_data.append(self.ent.get())
            self.row.pack(side=tk.TOP, fill=tk.X, padx=5,pady=5)
            self.lab.pack(side=tk.LEFT)
            self.ent.pack(side=tk.RIGHT, expand=tk.YES, fill=tk.X)```
#

However, I can't manage to pull the data from it, or if I do, it's only the last entry. Is what I am attempting possible?

proven basinBOT
runic patrol
eager beacon
#

here

#

@runic patrol

digital rose
#

i NEED HEELLLPPP

#

Hellppp

#

heeeeeeeelp

#

WITH PYQT

static cove
#

@digital rose what specifically do you need help with?

digital rose
#

SO whenever i try to open import the second (temperature_window.py) in main.py

#

and run the main.py without even calling anything from second file just import

#

it opens the second window

#

and the first window never opens

#

@static cove

static cove
#

what does temperature_window.py look like?

digital rose
#

take a look at second screenshot

static cove
#

That doesn't show me what the file itself looks like

digital rose
#

i didn't get it, did you mean how the UI Looks like or How the code looks like?

static cove
#

the code

digital rose
static cove
#

Is that what your temperature_window.py looks like?

#

that would be the problem then. You need to keep that if __name__ == "__main__":

digital rose
#

if i keep it then the second UI aka Chart Ui will never show up

static cove
#

Well, you need to create an instance of the DynamicSpline class and then use it for it to show up

digital rose
#

ok can you just simply tell me How to open a second window in PyQt , that would be easier for both of us

static cove
#

How much experience with pyqt do you have?

digital rose
#

almost begginner

#

i've done few projects but this is going to be the most complex so far for me

static cove
digital rose
#

i've gotta add Bluetooth+ wifi connectivity and so much more

#

aight

trail venture
#

why does this line selected_device = tk.StringVar() give me the following error?

static cove
#

Could you post more of your code?

trail venture
#

the code is a bit messy but I'll try to give some context, basically, I'm using the sounddevice library for a device recorder I'm making, and right now I'm trying to make an OptionMenu that allows you to select which audio device to record from

#

I looked at the code in the tkinter lib and it seems to be a problem regarding the tk.StringVar() constructor itself

#

but idk what to do, all examples I've found online just do tk.StringVar() and it works fine

static cove
#

Yeah, that's why I'm wondering if something else in the code is making it be wonky

trail venture
#

mind if I post the whole thing?

#

it fits within one message

static cove
#

!paste you can also use the pastebin

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.

trail venture
#
import keyboard
import sounddevice
import tkinter as tk

def change_hotkey():
    keyboard.remove_all_hotkeys()
    hotkey = keyboard.read_hotkey()
    keyboard.add_hotkey(hotkey, record_audio)
    field_hotkey.config(text=hotkey)


def record_audio():
    print("test")


device_list = sounddevice.query_devices()
selected_device = tk.StringVar()

hotkey = "ctrl+q"
keyboard.add_hotkey(hotkey, record_audio)


root = tk.Tk()

root.resizable(0, 0)
root.title("Epic brown shapiro sampler!!!")

canvas = tk.Canvas(root, width=256, height=256)
canvas.pack()

icon = tk.PhotoImage(file="brownicon.png")
root.tk.call("wm", "iconphoto", root._w, icon)
background_image = tk.PhotoImage(file="background2.png")
background_label = tk.Label(root, image=background_image, )
background_label.place(relwidth=1, relheight=1)

label_hotkey = tk.Label(root, text="Hotkey", fg="white", bg="#60676d", anchor="w")
label_save = tk.Label(root, text="Save Loc.", fg="white", bg="#60676d", anchor="w")

field_hotkey = tk.Label(root, background="white", text=hotkey)
field_save = tk.Label(root, background="white")

button_hotkey = tk.Button(root, text="Change", command=change_hotkey)
button_save = tk.Button(root, text="Change")

label_device = tk.Label(root, text="Audio Device", fg="white", bg="#60676d", anchor="w")
menu_device = tk.OptionMenu(root, selected_device)

label_hotkey.place(relwidth=0.3, relx=0.05, rely=0.2)
label_save.place(relwidth=0.3, relx=0.05, rely=0.3)
field_hotkey.place(relwidth=0.35, relx=0.35, rely=0.2)
field_save.place(relwidth=0.35, relx=0.35, rely=0.3)
button_hotkey.place(relwidth=0.2, relx=0.75, rely=0.2)
button_save.place(relwidth=0.2, relx=0.75, rely=0.3)
label_device.place(relwidth=0.3, relx=0.05, rely=0.45)
menu_device.place(relwidth=0.35, relx=0.35, rely=0.45)


root.mainloop()
static cove
#

HA. Okay

#

Move root = tk.Tk() to the very top (but below import statements) above the tk.StringVar()

#

I always wondered if that was the case and this proved it

trail venture
#

awesome, tyvm

#

working now

static cove
#

yay!

#

Turns out StringVar needs a Tk() instance otherwise it's constructor fails

trail venture
#

oh also, is there a way to change the visual aspects of an OptionMenu widget?

#
  • text anchoring and what not
#

actually, nevermind, I'm gonna migrate to pyqt instead

#

seems much better than tkinter overall

ruby pawn
#

I have a problem with a stubborn QWidget inside a scrollArea. It doesn't want to take up it's minimum amount of space. I've tried setting size policy to minimum, set minimum height to 0, but nothing seems to work. Any ideas? (I'm working in PySide2)

eager beacon
#

have you tried scrollArea.setWidgetResizable(True)?

ruby pawn
#

Yes

#

This is with scrollArea.setWidgetResizable(True) and green is the widget's background color

#

And here it is with scrollArea.setWidgetResizable(False) and red is the scrollArea's background

#

So that leads me to think it is the scroll area that makes the widget scale up to fit the scrollarea

eager beacon
#

So what behavior are you looking for?

ruby pawn
#

I basically want it to be the exact length of it's content

#

It shouldn't be taller than the two bars named "Name Editor" and "Settings" combined.

#

If I unfold one of the bars, it does get the exact length. It's just that it can't go small enough.

#

Here is with one of the bars unfolded. And it doesn't force the scroll area to be a tiny bit too long

eager beacon
#

So the scrollArea should always be the same height it is in the red/green screenshots?

ruby pawn
#

No the scroll area should never force the window taller. The scroll area should be as long as the window height allows it. But when I scale the window down to it's minimum height, there shouldn't be any extra green/red at the bottom.

#

Basically the problem is that the scroll area won't scale down enough vertically. It forces an extra about 28 px even though the minimum height is set to 0

eager beacon
#

try setting it to 1

ruby pawn
#

Alright 2 sec

eager beacon
#

wait

ruby pawn
#

?

eager beacon
#

whats the sizePolicy?

ruby pawn
#

Minimum, minimum

eager beacon
#

vertical

ruby pawn
#

On literally everything

eager beacon
#

try setting vertical to Preferred

ruby pawn
#

If I set the minimumHeight to 100, it scales up to 100px, but it won't go lower than 48 pixels

#

Okay

#

Setting it to preferred allows me to scale it down to 0, but it doesn't initialize in minimum size

eager beacon
#

what is the minimum height on the Widget that you used for scrollArea.setWidget(Widget)?

ruby pawn
#

it's also 0

#

And set to minimum, minimum

#

And I want it to look like this when I open it, and I don't want it to be able to be scaled shorter than this. But it needs to be able to scale taller.

lofty wyvern
#

Could someone help me out with this? I have been trying to pull the information from the entry fields and place them into a list for later use. Best I have been able to do is just pull the last field.
https://paste.pythondiscord.com/jeqafehubi.rb

#

I've been beating my head against it for 2 days

eager beacon
#

Can you post the code for the expanding group boxes and scrollArea?

ruby pawn
#

I can't post the code for the expanding group boxes because I call their creation in Autodesk Maya. It is not something I have written myself.

#

I basically create them using Maya's own scripting language and then grab the Qt object after creation and work with that

#

But here is for the scroll area, and I apologize for it being messy I've just been throwing stuff at the wall to see what sticks ```python
self.scrollAreaLayout = QVBoxLayout()
self.dropdownLayout = QVBoxLayout()
self.dropdownLayout.setSpacing(0)
self.dropdownLayout.setMargin(0)
self.nameEditorContainer = QVBoxLayout()
self.extraSettingsContainer = QVBoxLayout()
self.dropdownLayout.addLayout(self.nameEditorContainer)
self.dropdownLayout.addLayout(self.extraSettingsContainer)
self.nameEditorContainer.addWidget(self.editorWidget)
self.extraSettingsContainer.addWidget(self.extraSettingsWidget)

    self.dropdownLayout.setStretchFactor(self.nameEditorContainer, 0)
    self.dropdownLayout.setStretchFactor(self.extraSettingsContainer, 1)

    self.scroll = QScrollArea()
    self.scroll.setMinimumHeight(1)
    self.widget = QWidget()
    self.widget.setStyleSheet('QWidget {background-color: green;} QVBoxLayout {background-color: blue;}')
    self.widget.setMinimumHeight(1)
    self.scroll.setSizePolicy(
        QSizePolicy.Minimum,
        QSizePolicy.Preferred
    )
    self.widget.setSizePolicy(
        QSizePolicy.Minimum,
        QSizePolicy.Minimum
    )

    self.widget.setLayout(self.dropdownLayout)
    self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    self.scroll.setWidgetResizable(True)
    self.scroll.setWidget(self.widget)
    print(self.scroll.sizeHint())

    self.mainLayout.addLayout(self.scrollAreaLayout)
    self.scrollAreaLayout.addWidget(self.scroll)

    self.mainLayout.setStretchFactor(self.nameLayout, 0)
    self.mainLayout.setStretchFactor(self.settingsLayout, 0)
    self.mainLayout.setStretchFactor(self.scrollAreaLayout, 0)```
#

Okay the indentation messed up a bit

#

@eager beacon Okay this is odd. I set the minimum size to 44, which is apparently the height I want it at. And then I added a self.adjustSize() right after self.setLayout(self.mainLayout) and it fixes the issue. If I set the self.adjustSize() before the setLayout or after I add he scrollArea it doesn't work.

eager beacon
#

oh

#

well in that case couldn't you use scrollArea.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContentsOnFirstShow)

#

the base policy ignores size adjustments

ruby pawn
#

I'll try

#

I have a new problem though

#

Window doesn't get automaticly longer when I unfold one of the bars anymore. It used to force the scroll area and window taller

#

Maybe that is the size policy?

eager beacon
#

Minimum will do that

ruby pawn
#

The setSizeAdjustPolicy didn't work

eager beacon
#

might try AdjustToContents then

#

it will adjust anytime the scrollArea viewport changes

ruby pawn
#

Just tried, didn't work

#

It doesn't change at all

#

Unless I manually resize the window

#

Not sure how I fucked it up

eager beacon
#

Do you know the size of your group boxes when expanded ahead of time?

ruby pawn
#

I will when they are done

eager beacon
#

you could just change the sizeHint then

ruby pawn
#

I'd have to do that dynamically when I open and close them?

eager beacon
#

yeah. you could emit the size, or something else, depending on how you wanted to do it

ruby pawn
#

How do I set a size hint?

eager beacon
#

scroll.sizeHint = lambda s=QtCore.QSize(400,200):s should work since you aren't subclassing the scrollArea

#

or you could define a normal function and assign that as the sizehint

#

doesn't really matter, it just needs to be a function that returns a QSize

ruby pawn
#

It works

eager beacon
#

what does

ruby pawn
#

The command to change sizeHint

#

But how will changing the size hint make the scroll area get the right size?

#

If I adjustSize() it jumps back to that weird spot it has always wanted to be in

eager beacon
#

you can try updateGeometry instead

#

but why do you even need adjustSize if the sizeHint is working?

ruby pawn
#

Oh I mean it's literally changing the number

#

Not that the window is actually following those sizes

eager beacon
#

hm, if you change a sizeHint and then explicitly call updateGeometry the size of the widget should be updated

ruby pawn
#

It updates horizontal, but not vertical

eager beacon
#

check the sizePolicy for vertical

ruby pawn
#

I changed it back to minimum

#

Should it be preferred?

#

Welp, doesn't make a difference

eager beacon
#

can't you remove the policies if you're setting the sizeHint?

ruby pawn
#

Sure let me give it a shot

#

No difference

#

I've tried setting it to scale to 1000 px vertically on updateGeometry and it's like "Nah boi"

eager beacon
#

is the widget containing the scroll area enforcing a maxHeight or something else?

ruby pawn
#

Only minimum height

eager beacon
#

maybe a Maximum SizePolicy

ruby pawn
#

What the fudge is it about QScrollArea that wants to be 74 pixels tall

eager beacon
#

pretty sure thats the combined sizeHints of your boxes within

ruby pawn
#

Let's figure it out

eager beacon
#

+- any contentsMargins on layouts or widgets

#

how tall is a collapsed widget?

#

the group box thing you have

ruby pawn
#

They're 44 together, so 22 individually

#

sizeHint for the boxes are 75 wide and 22 tall per group box

eager beacon
#

have you removed all of the contentsMargins on widgets and layouts?

ruby pawn
#

Yes

#

setSpacing(0) and setMargin(0)

eager beacon
#

setContentsMargins

ruby pawn
#

Ah, let me try

eager beacon
#

0,0,0,0 should be the values

#

and layout.setSpacing(0) also

ruby pawn
#

Yes, that is set now

#

No difference

eager beacon
#

scrollLayout too

ruby pawn
#

Aight, gimmie a sec

eager beacon
#

You can also apply it to the widgets, but I'd think that would be taken care of by the qss

ruby pawn
#

Okay I think I have found a mistake

#

I think I've made some kind of mess up between self.scrollAreaLayou and self.dropdownLayout. I need a minute or two to figure out wtf I've done

eager beacon
#

the border?

#

ahh

#

I've gotta go make my kiddo some dinner, I'll be back after

ruby pawn
#

Thanks for all the help Chris

stray jackal
#

speaking of GUIs - is there any logic behind Star Treks LCARS displays???

ruby pawn
#

@eager beacon sadly I'm gonna have to go catch some Z's, but I've hooked up functions on expand and collapse for both of the bars and then I hope to get current size of the window and add or subtract the height of that group box. And we'll see how that works. Thanks for all your help, it is much appreciated. πŸ™

lofty wyvern
#

Could someone help me out with this? I have been trying to pull the information from the entry fields and place them into a list for later use. Best I have been able to do is just pull the last field.
https://paste.pythondiscord.com/jeqafehubi.rb
I've been beating my head against it for 2 days

eager beacon
#

@lofty wyvern

#

Which lines are you having trouble with?

lofty wyvern
#
    def create_list(self, event):
        #self.text= tk.StringVar()
        for x in self.data_needed:
            self.text = self.ent.get()
            self.input_data.append(self.text.get())
        print(self.input_data)
    
    #creates input fields
    def makeform(self, user_data_info_frm, data_needed):
        
        for y in self.data_needed:
            self.row=tk.Frame(self.user_data_info_frm)
            self.lab=tk.Label(self.row, width=15, text=y, anchor='w')
            self.ent=tk.Entry(self.row)
            self.input_data.append(self.ent.get())
            self.row.pack(side=tk.TOP, fill=tk.X, padx=5,pady=5)
            self.lab.pack(side=tk.LEFT)
            self.ent.pack(side=tk.RIGHT, expand=tk.YES, fill=tk.X)```
#

I've tried a ton of solutions I found, but I can't get the entries into a list

eager beacon
#

I don't know much about TK, but is this intentional?

   self.text = self.ent.get()
   self.input_data.append(self.text.get())
#

Do you really need to call get twice on the same object?

lofty wyvern
#

One of the many things I've tried.

#

no, that was me just trying anything

eager beacon
#

alright, just asking, because I really don't know much TK

lofty wyvern
#

I've gone through at least 30 different iterations of the makelist function

#

I can get it to pull the last field, but not any of the others, so it is not looping through the entries

eager beacon
#

in makeform, or create_list?

lofty wyvern
#

The makeform is working, but that's where the entries are. I'm using the create list to build a dynamic list

#

I've probably messed it up more trying to fix the createlist function to work like I want it

amber roost
#

How are you going to get text from entries that you have no reference to?

lofty wyvern
#

Might be my issue, I've tried a lot of things and probably deleted them.

#

I'm only two weeks into learning python so it could be something as simple as that

amber roost
#
    for x in self.data_needed:
        self.text = self.ent.get()
        self.input_data.append(self.text.get())
#

You only have x as a loop variable and do not use it

eager beacon
#
    def create_list(self, event):
        for x in self.input_data:
            self.text = x.get()
            print(self.text)
#

that seems to work

amber roost
#

You only have self.ent to query and it is not going to change

lofty wyvern
#

Awesome, thanks y'all! I'll give that a go.

amber roost
#

input_data will only contain the text the entries were created with

#

so a bunch of empty strings

#

you will need to store the references to the entries themselves in a list and call .get on them for create_list

#

something like


def makeform(self, ...):
    self.form_entries = []
    for i in self.data_needed: #why is it both a self attribute and a parameter?
        ...
        ent = tk.Entry(self.row)
        self.form_entries.append(ent)
        ...

#

then you can run through all the entries in create_list, but you may consider using a dict instead of a list if the order is going to change in any way

lofty wyvern
#

Thank you, I'll dig into this now. Thank you so much!

#

@amber roost @eager beacon between the two of you all, that got it! Thank you!

bronze basin
#

hey i have a problem with PyQt i am using the Qt designer when i try to apply Qscroll bar customizations

#

it shows as its applied but in the preview window it reverts back to the default style

#

thinking it might be a visual glitch i saved the ui file as a.py file and tried to launch up the main window

#

but the customization still doesnt show

#

how do i fix this?

lucid trench
#

Can somebody help with Tkinter and the after function

#

I'm trying to make a while loop but using the after function

hollow ether
#

I have programmed a lot in Python, but never worked with any GUI libraries. I have done some in Java with JavaFX. What I'm wondering is what would be good choice for me to start working with in Python?

eager beacon
#

pyside2 or pyqt

#

those are the two with the most # of features

hollow ether
#

Alright, great. I will check these out. Thanks!

bronze basin
#

hey i have a problem with PyQt i am using the Qt designer when i try to apply Qscroll bar customizations
@bronze basin This is for the widget QTextBrowser just in case that helps to solve the issue i am having or smth

timid ether
#

Can I somehow add a black line between the item header row and value row? Pic related. Also how can I turn a cell value into a multirow string?

ruby pawn
#

I'm building a PySide2 application inside Autodesk Maya. It is built in a QDialog and have some unfolding content that on unfold resizes the window to make space and I had it working as intended until I set my class to inherit from mayaMixin that adds the widget to another QWidget that can dock inside the Maya UI. Any ideas how I can get the new mayaMixin QWidget to resize like I did my QDialog, because it doesn't seem to respond to any kind of resize function.

quasi pilot
#

Thinker or kivy?

eager beacon
#

@ruby pawn Did you ever get your scrollArea working?

ruby pawn
#

Yes @eager beacon , I got it to work by resizing the window.

#

Calculate the desired size and then resize.

eager beacon
#

glad to hear it

strange owl
#

Hi! Im working on a simple web app with python and django and i need to decide which frontend framework i will use, i have never worked with fronted libraries or frameworks before, which one is the most easy and quick to learn?

eager beacon
strange owl
#

Ok, thanks!

silk basin
#

Would anyone know how to create a nested layout with QBoxlayout. I am trying to make a button when pressed that opens up a calculator. The problem with this and I do not know how to make another popup.

eager beacon
#

@silk basin I don't understand

#

Where does the nested layout come in to play

silk basin
#

I am running into an issue that I cannot create another QVBoxLayout

eager beacon
#

Whats stopping you from doing that?

silk basin
#

let me grab the error code hold up

eager beacon
#

okay

#

is it the one that says you cant add a layout to a widget with a layout?

#

or something like that?

silk basin
#

yes

#

it's so stupid

eager beacon
#

you're using setLayout to get that error?

silk basin
#

yeah

eager beacon
#

try addChildLayout

silk basin
#

ohh bet. give me a second

eager beacon
#

are you trying to get the calculator to appear in a new window or in one of the columns in the screenshot above?

silk basin
#

in a new window

eager beacon
#

a grid layout should work well

#

have you considered that?

silk basin
#

I haven't actually. What widget?

eager beacon
#

QGridLayout

#

you basically create widgets and choose a row/col to add the widget to

silk basin
#

Oh i see, okay let me see if the addChildLayout is going work. I deleted the code so gimme a second

eager beacon
#

sure

silk basin
#

@eager beacon

  def showBox(self):
        layout = QVBoxLayout()
        layout.addWidget(self.c)
        layout.addChildLayout(layout)
#

wait

eager beacon
#

that will never work

#

its like a snake eating its tail

silk basin
#

I have to addChildLayout to the original layout

eager beacon
#
l1 = QVBoxLayout()
row1 = QHBoxLayout()
l1.addChildLayout(row1)
#

you would add rows of buttons to the row layouts

silk basin
#

oh I see. but Still nothing pops up when I click my temporary button which calls showBox(self)

eager beacon
#

use a dialog?

silk basin
#

I added a print statement and the button is calling the function

eager beacon
#

use the QDialog and exec_() instead of show()

#

or post your code

silk basin
#

I'll be honest very new to Python so I am not sure what exec_() even is

eager beacon
#

its a method of the QDialogue

silk basin
#

I could post the code but its 217 lines

#

is that too long?

eager beacon
#

!paste

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.

silk basin
#

oh wow

#

so yeah this is controlling what I call the bottom bar of the program

eager beacon
#

ok

#

so in showBox you need to create a widget

#

then set a layout on that widget

#

that would be the vBox

#

then add hBoxes to the vbox with addChildLayout

#

but I'd still argue that you should go with a grid layout

#

its entire purpose is to do what you want to do

silk basin
#
    def showBox(self):
        print("T")
        l1 = QVBoxLayout()
        row1 = QHBoxLayout()
        c1 = QPushButton("c", self)
        l1.addWidget(c1)
        l1.addChildLayout(row1)
#

Yeah that still doesn't work for some reason

#

I also agree with you. Once I get a popup I'll switch

#

I notice addChildLayout is part of the QLayout class. Would that have anything to do with it

eager beacon
#

no

silk basin
#

Holy hell that worked

eager beacon
#

yes

#

because you create a widget and give it a layout

silk basin
#

You sir are a genius

#

oh

eager beacon
#

you cant view a layout without a widget to contain it

silk basin
#

That makes so much sense

#

@eager beacon I bestow upon you a cookie, as gift for your time and effort. πŸͺ

real parcel
#

anyone brave enough to test a tiny wxpython script/app i've put together? i just want to see if any major errors happen on different kind of systems

leaden tiger
#

hello, is this the right channel for tkinter questions?

agile socket
#

hey how to add amzing gui to pyqt

#

like the ones in qt designer are stock designs

#

how to add our own designs

#

if u have answer pls dm me

bronze basin
#

wdym?

#

you have to make designs?

#

@agile socket

gaunt saffron
#

hey guys, how do you make modern looking GUIs in pyQt5

#

and is there a way to add dynamic images

bronze basin
#

@gaunt saffron yes there is through learning and getting good at design

#

also if you mean gifs yes you can add gifs

gaunt saffron
#

@bronze basin I mean like any modules that I could use. And by dynamic images i mean like dynamic wallpapers that move based on user interaction.

bronze basin
#

maybe you would use Qpainter for that but not entirely sure

digital rose
#

does anyone know what specs do i give a virtual machine to run linux?

static cove
#

@digital rose that's not python related or user-interface related. Give it the minimum required unless you're planning on running something that requires more resources. It's a VM, you can always recreate it or allocate it more resources later.

digital rose
#

oh ok thanks

#

and sorry for wrong channel. which one should i go to?

static cove
#

there isn't really a proper channel for a non-python question on a python server. Maybe off-topic? But again, just give it the minimum required and get on with it.

digital rose
#

ok...... :)))

real parcel
#

anybody who works with wxpython have any tips for speeding things up/getting smoother rendering results for things like resizing your window and stuff? i'm working on an image viewer and it's going well but repainting a large image during any frame resize events is kind of stuttery

digital rose
#

i thought that this is related to UIs and OSs so i asked.......

static cove
#

The channel topic: "For help relating to Python User Interface libraries (e.g. PyQT, Tkinter, WxPython, Curses, PySide)"

#

Setting up a linux VM does not fit that channel description

digital rose
#

sorry........ 😦

static cove
#

@real parcel are you using double buffer?

real parcel
#

oh i forgot i meant to try that

#

lemme set that up right quick

real parcel
#

@static cove it didn't seem to help. idk

#

it's weird; like the graphics of the window appear to be ghosting while the window is resizing

#

i'm sure i'm doing something wrong but i dunno what. what should i be sure i'm doing in the paint event?

#

to clear the background i mean

#

i'm guessing that's the issue

#

like, that the background isn't clearing properly or fast enough

real parcel
#

oh wait ALL my windows in xfce are like that, lmao 😎

digital rose
#

in tkinter: .grid or .pack?

real parcel
#

yeah it looks way better in gnome3. lmao 😭

static cove
#

@digital rose I prefer grid, but usually end up using a combo with frames to prevent space manager conflicts

leaden tiger
#

@static cove do you possibly know how buttons in tkinter work?

spark furnace
#

what do you call this window?

#

is is just a popup window?

#

I want to create a popup window like that which is linked to the main window as you can see in pyqt5

normal plinth
#

Is anyone online willing to help me with a PyQT5 Qgridlayout() question? I'm getting some funky behavior.

eager beacon
#

whats the problem?

#

@normal plinth

#

@spark furnace thats just a widget that contains a tabWidget and a lineEdit

normal plinth
#

Basically, every element is showing at position 0,0.

eager beacon
#

did you specify row/col positions?

normal plinth
#

I did, 0, 0 through 0,6 but they all stack on top of each other at 0, 0.

#

When I comment them out, they all show in the same position 1 by 1.

eager beacon
#

you need to call self.setLayout(self.grid)

#

you are only seeing them because you assigned Window as the parent of the buttons'

#

if you removed the self argument from the buttons they wouldnt even be visible

normal plinth
#

When I do that, I'm getting an error "QWidget::setLayout: Attempting to set QLayout "" on Window "", which already has a layout", but you've definitely made it easier for me to diagnose.

#

Thank you Chris! You should start a YT channel and a Patreon, lol

eager beacon
#

hah

#

You are using a mainWindow

#

and it has whats called a centralWidget

#

so you need to set a centralWidget

#

then set a layout on that widget

#

and add things to that

#

instead of directly to the mainWindow

normal plinth
#

Okay, so my layout grid will be contained inside the central widget, which will be contained in the main window.

eager beacon
#

exactly,

w =QWidget()
self.setCentralWidget(widget)

sets the centralWidget

somber halo
#

if any1 is listening PLZZZZ HELP ME OUT...i need to know how to correctly embedda pie chart in tkinter gui and update its values on the run with a button.PLZZZ HELP😒 😒

#

plz dm if possible

spark furnace
#

@eager beacon But how do you make the widget popup

eager beacon
#

connect the buttons clicked signal to the widgets show()

#

that one is popping up right above the button it looks like

#

so they are also mapping a position to have it appear in that position

normal plinth
#

I'll reading up on the mainwindow/central widget to see how best to structure it. Thanks for the help!

bronze basin
#

@spark furnace hide the widget and when something happens show it?

#

or make a new window in case you need to use the space in which the popup will show

dark gulch
#

hi does anyone know if tkinter message boxes work in python 1.8.3

#

on every documentation site if have seen it says they are a thing

#

Im getting an error that basically is saying they dont exist

static cove
#

@leaden tiger I do mostly, are you having an issue with buttons?

ruby pawn
#

Hey guys, I have some problem with my PySide2 application messing up when I dock it in Autodesk Maya. Any helpful tips to figure this out?

eager beacon
#

How many of the AUTO bars should be visible?

#

@ruby pawn I've seen similar things happen to widgets if you have a minimum width or height larger than the maximum

ruby pawn
#

It's supposed to look like this

#

Can it be because the minimumHeight is shorter than sizeHint height?

eager beacon
#

sounds plausible but I'm not positive one way or another

ruby pawn
#

I'll give it a shot in a moment

#

If that is indeed the problem. I guess the damn scroll area strikes again

eager beacon
#

is the gap on the right side happening because that where the vertical scrollBar is?

ruby pawn
#

Which gap?

eager beacon
#

Maybe maya has some weird dockWidget policies

ruby pawn
#

It does

#

You have to inheret something called mayaMixin

eager beacon
#

like, nothing goes out to the edge

ruby pawn
#

And they rewrite the .show() command

eager beacon
#

its like there is a scroll bar there but its been hidden but not removed

ruby pawn
#

To create a new widget that they slam your UI into

#

This is what it looks like with a scroll bar btw

#

Anyway. I have posted on the Maya Programming forum, to see if any of those people have an idea what I've done to misplease the Maya Gods

eager beacon
#

yeah, Nuke does the same sort of stuff and it also enforces arbitrary rules for some things that can't be modified by the user

ruby pawn
#

If I mouse over anything button that has a :hover stylesheet thing, it redraws the button in the right place. Like wtf

eager beacon
#

oh

ruby pawn
#

Thank god I've only ever had to do a few yes/no dialog boxes in Nuke

eager beacon
#

try calling update or repaint then

ruby pawn
#

On which widget

eager beacon
#

i'd guess the container

#

that holds the once that you mouseover

ruby pawn
#

I don't even know which one is the container anymore

#

Like after doing the maya docking

eager beacon
#

hah

ruby pawn
#

It puts the QDialog into a QWidget

#

That has a QSplitter above it

#

That has a QTabWidget above it

#

That has, another freaking QWidget above it

eager beacon
#

gotta have a pretty property panel!

ruby pawn
#

(β•―Β°β–‘Β°οΌ‰β•―οΈ΅ ┻━┻

#

Okay, which one do you think works? Repaint?

eager beacon
#

update calls repaint

ruby pawn
#

I have found an event call that happens most of the times I dock it, it doesn't seem 100% reliable but oh well

eager beacon
#

so w/e

ruby pawn
#

updateGeometry()?

#

And would I have to do it inside a QTimer or no?

eager beacon
#

maybe you can save and restore the geometry?

#

timer on the repaint? I'd just do it on w/e signal fires when docking or undocking]

#

since that's when the issue appears

ruby pawn
#

Alright I've tried to call updateGeometry() on all QObject from QDialog and up

#

Nothing changed

eager beacon
#

did the repaint work?

#

I'm assuming thats whats triggering the update as you mouseover and the enterEvent is fired

ruby pawn
#

Oh I can try repaint()

#

2 sec

#

Nope

#

No luck

#

Destroying the UI and doing .show() again does fix the issue

#

Or resizing the window fixes it

#

But I can't seem to do it with code

eager beacon
#

calling resize manually doesn't change it?

ruby pawn
#

Maybe I'm not trying to resize on the right widget

eager beacon
#

just for the sake of testing start on the inner most widget and if it has children resize them otherwise resize the widget

#

then move on to its parent and to the same thing

#

resizing widgets to the current size would probably be fine

#

or start with the thing that inherits the mixin and resize all of its children and childrens children

ruby pawn
#

Okay here's a weird thing, if I repaint on a button click. It fixes everything but the scroll area

#

Like wut

#

Oh my god

#

It literally is the scroll area fucking everything up

#

If I don't have the scroll area, no bugs what so ever

#

Or well no I'm being an idiot. Sorry.

#

It's the maya expansion thingies

#

The maya expansion thingies inside the scroll area is doing it

#

I'll try to add them back but remove the scroll area to confirm

#

Yup

#

It's the fucking maya group box things. FUCK

#

I will find another solution than the weird group boxes. Thanks for your help troubleshooting again @eager beacon it is much appreciated as always

leaden tiger
#

@static cove yes, i am using the buttons by importing an image by path over an object. i want after a click to change the image, is that possible?

static cove
#

Click in a specific spot or just a click in general?

leaden tiger
#

@kutiekatj, just click in general. i programme my first python programme in python and tkinter. its a card game. i can send you the code what i am doing to import the image?

eager beacon
#

its a similar situation to what you have going on with scroll area contained in a dock

#

you might have to throw a verticalSpacer in under the scrollArea to get the behavior you want though

ruby pawn
#

This is creating a collapsible box from scratch no?

eager beacon
#

yes

static cove
ruby pawn
#

Thanks for the resource, but I don't think I want to bother creating my own collapsible boxes. I was only using them to stay within the maya design language. If necessary I'll find another way of containing more options while keeping the UI footprint small. Such as tabs.

eager beacon
#

you could also consider using collapsible layouts instead of a resizing the widget

leaden tiger
#

@static cove do you mean command binding?

ruby pawn
#

But I found out that the issue with the collapsible box is the way I add content to them. Apparently getting the Qt object, querying the layout and adding a widget is not okay with Maya.

eager beacon
#

I don't remember where I stole this from but I've used it in place of what you're doing before and didn't run into any of the issues you've seen

ruby pawn
#

Or I might go with menuItems.

static cove
#

@leaden tiger yes, you can bind the user pressing their mouse or specific keys to a specific command and the command can be a function you write.

eager beacon
leaden tiger
#

@static cove i have already done that ... my problem is the following

            global playerTwoCard1
            newcard = stack.pop()
            img = Image.open(newcard.bgpath)
            img_resize = img.resize((150,300),Image.ANTIALIAS)
            newimage = ImageTk.PhotoImage(img_resize)
            playerTwoCard1 = Button(root,image=newimage,command = lambda: player2click(1))
            playerTwoCard1.image = newimage
            playerTwoCard1.grid(row=0,column=0)

how do i get the newcard.bgpath to newcard.imgpath after a click?

eager beacon
#

the tabs might be an okay solution if you don't need to constantly swap between them to use your plugin

ruby pawn
#

Oh no, it'll be like once in a blue moon

eager beacon
#

sounds like that might be the way to go

ruby pawn
#

Problem with tabs is the height of the app is defined by which ever tab that is tallest

#

I did write some code that auto resize them but.. It wasn't amazing

eager beacon
#

I had to make some shelf things for Maya a couple of years ago and it was a pain so I get where you're coming from

ruby pawn
#

So I might make a main window and add menu items where you can switch the widget in the main window

eager beacon
#

I'd say just go with the easiest solution at this point

ruby pawn
#

And then it's even easier to expand the plugin

#

Well it's a learning opportunity

eager beacon
#

sounds reasonable

ruby pawn
#

I was supposed to do a pipeline internship at a VFX studio

#

But the studio is dissolving

eager beacon
#

but so did the collapsible boxes lol

ruby pawn
#

So they just let me do my own shit

eager beacon
#

are you in LA?

ruby pawn
#

No, Copenhagen

eager beacon
#

ahh, all of the VFX work over here is pretty much exclusively in LA and they don't like people working remotely but if they did I'd love to be a TD

ruby pawn
#

A few people I know went to LA

#

Mostly animators though

#

But most people here do London or Copenhagen

eager beacon
#

makes sense. London has a bunch of studios

static cove
#

@leaden tiger I don't see the code that captures the user clicking

ruby pawn
#

Oh we're definitely filling up this chat, I feel bad

leaden tiger
#

@static cove it should look like this for the first card

def player1click(chosen_card):
    global round
    global stack
    global playerOneCard1
    if chosen_card == 1:
        playerOneCard1.grid(row=1,column=1)
        if round == 3:
            newcard = stack.pop()
            img = Image.open(newcard.imgpath)
            img_resize = img.resize((150,300),Image.ANTIALIAS)
            newimage = ImageTk.PhotoImage(img_resize)
            playerOneCard1 = Button(root,image=newimage,command = lambda: player1click(1))
            playerOneCard1.image = newimage
            playerOneCard1.grid(row=2,column=0)
    elif chosen_card == 2:
        playerOneCard2.grid(row=1,column=1)
        if round == 3:
            newcard = stack.pop()
            img = Image.open(newcard.imgpath)
            img_resize = img.resize((150,300),Image.ANTIALIAS)
            newimage = ImageTk.PhotoImage(img_resize)
            playerOneCard2 = Button(root,image=newimage,command = lambda: player1click(2))
            playerOneCard2.image = newimage
            playerOneCard2.grid(row=2,column=1)
    elif chosen_card == 3:
        playerOneCard3.grid(row=1,column=1)
    elif chosen_card == 4:
        playerOneCard4.grid(row=1,column=1)
    elif chosen_card == 5:
        playerOneCard5.grid(row=1,column=1)
    
    round = 1
#

@static cove but i am thinking about to skip playervsplayer and just write a random card for playervscomputer and dont change backgrounds

#

@static cove but when the computer plays a background card i need to switch the bgpath to imgpath too ... so no difference

#

@static cove i am looking for something like playerOneCard1.method(object.value) ... does something like this for a button exists?

#

or is it better to programme that with pygame?

#

because i have also recognized, that the code stops running after clicking and dont get back to the function before?

trim ibex
#

in pyqt5, how do i hide a specific menu item; not a whole menu, but one item in it

dark gulch
#

does anyone know how to make it so you dont have to use a button to print a listbox selection

#

I bound my function to mouse1 and it does work

#

but when I use a button somehow it magically does

static cove
#

@dark gulch can you share the code where you bind mouse1?

fluid tinsel
#

is there a way to install pyside2 on Python 3.8?

static cove
#

It should work for 3.8

fluid tinsel
#

let me try again, since I last tried 2 weeks ago

static cove
#

pyside version5.14 definitely works for 3.8, but you should make sure you have at least python 3.8.1+

#

The last release of it was Sept 10, so nothing would've changed since 2 weeks ago

#

How are you installing it and what OS?

fluid tinsel
#

I’ve only tried on a repl, which gives me a forbidden error for the version.
The specific version on the repl is 3.8.2.
would it work on Windows 10 python 3.8.5?

static cove
#

Huh, I don't use repl much. It should work though with win10 and 3.8.5

fluid tinsel
#

also, is Qt Creator also available (for .ui) on PySide2?
there’s not much I can find unless it comes with the normal Qt Creator.

static cove
#

I don't use Qt Creator much, but the .ui should work with PySide2

#

Huh, looks like it's an issue with poetry/repl.it

#

Repl.it is specifying for python versions ^3.8, but that means every python version >= 3.8 and <4.0. Pyside2 doesn't work for 3.9 yet

#

So poetry can't resolve the dependency

#

Repl.it should probably be using the notation of 3.8.* to get that not to break since 3.9 is so new

fluid tinsel
#

oh it isn’t a problem then, I can always finish, and except name errors so I can test on the repl first.

static cove
#

Curious. That could probably be an improvement on poetry's part

#

It's a bit unintuitive to me that ^3.8 would include 3.9

fluid tinsel
#

yeah it installed successfully. but are the .ui files generated from Qt Creator for Python same as the CPP ones for pyside?

#

i mean does pyside2 read the same files as ones made with the CPP qt creator?

eager beacon
#

There could be some slight differences but it shouldn't be anything visible to a user

dark gulch
#

@static cove

import tkinter as tk
root = tk.Tk()
root.geometry("400x240")

listbox = tk.Listbox(root)
listboxitems = ["Mass", "Volume", "Area", "Height", "Width", "Length"]
listbox.insert(1, "Length") 
listbox.insert(2, "Width")
listbox.insert(3, "Height")
listbox.insert(4, "Area")
listbox.insert(5, "Volume")
listbox.insert(6, "Mass")
listbox.pack()

def SelectFunction():
    selection = listbox.curselection()
    print(selection)
root.bind('<Return>', SelectFunction)

# submit = tk.Button(root, text='Submit', command=SelectFunction)
# submit.pack()

root.mainloop()
#

Sorry for responding so late

#

the button works fine

#

but when I bind the function to mouse 1

#

I get this

static cove
#

@dark gulch Change the function definition of SelectFunction to:
def SelectFunction(*args):

#

Depending on which key you bind it'll pass additional information you can use to what's attached as the callback. You need to make sure you account for it and catch it

#

The mouse click will pass the coordinates of where the user clicked as an example

#

*args will catch anything it passes and put it in a tuple for you to use

leaden tiger
#

@static cove may i ask you ... any idea?

static cove
#

@leaden tiger Did you check out the link I gave you about bindings and events in tkinter? Your code isn't tracking when a user clicks anywhere, only when they click the button

dark gulch
#

@static cove thanks so much I was just staring at it for like 2 hours not knowing what to do

leaden tiger
#

@static cove i read your link, but the binding is like the command which i give on button creation and i still dont know how to access the value of the object in the button

static cove
#

So I think I'm not fully understanding what you want to do. I thought you wanted to change the picture of some element in your window when the user clicks anywhere their mouse

leaden tiger
#

@static cove nope

fluid tinsel
#

wait does pyside2’s license allow creating public applications?

dark gulch
#

@static cove not to be a bother but how would I use the indices of the selected string in a something

if selection == "(0,)":
    selection = "Length" 
if selection == "(1,)":
    selection = "Width"
if selection == "(2,)":
    selection = "Height"
if selection == "(3,)":
    selection = "Area"
if selection == "(4,)":
    selection = "Volume"
if selection == "(5,)":
    selection = "Mass"

I tried this and its weird

#

It just prints the same stuff

leaden tiger
#

@static cove i assigned a object from a list to a variable, that variable contains the background and foreground path to images ... i set the foreground path to the button and it shows me the button with the picture but i want to change the foreground to the background ... therefore i need to access the object within the button

#

@static cove maybe with an image its better to understand

dark gulch
#

are you making a card game?

leaden tiger
#

@dark gulch yes πŸ™‚

dark gulch
#

what game?

leaden tiger
#

its called schnapsen

dark gulch
#

is it your own?

#

nvm

leaden tiger
#

no, its spreaded around in our country

dark gulch
#

your from austria correct?

leaden tiger
#

yes

static cove
#

@leaden tiger from what you typed the button only contains the path to the foreground image. It doesn't contain the object with both the foreground and background

dark gulch
#

Thats cool that its the "national card game". Weird but cool

static cove
#

@dark gulch where is the "(1,)" coming from? What is selection specifically?

leaden tiger
#

@static cove ok? how do i need to reprogramme that ... so i can change background and foreground card?
just a second, i give you my code

dark gulch
#

well curselection assigns selection to the indices of the list box so I thought it would just be a string and I could simply convert it back

leaden tiger
dark gulch
#

But its something else so I have no idea

#

its selection 4 so it prints (4,)

static cove
#

@dark gulch just try:
if selection == (4,):
no quoted around the specific thing you're checking against

dark gulch
#

I did but I will try again

#

wait

#

On this site it says it returns a list

#

so the (5,) is a list?

static cove
#

(5,) is a tuple

dark gulch
#

ahhh

static cove
#

@leaden tiger currently on my phone so it's a bit tough to read that much code. Is it cool if I take a look at it in the morning and get back to you?

leaden tiger
#

@static cove sure, no problem πŸ™‚ ... i set the paste for 1 hour, so just write me if you have time and i send you the code again?

static cove
#

@dark gulch when you do selection = "Length" what are you trying to do there?

#

@leaden tiger yeah, I'll ping you tomorrow

dark gulch
#

Reassign what it prints to Length

leaden tiger
#

@static cove idk, if pygame is better for creating card games, because i have seen some on their website

dark gulch
#

Im making a volume calculator

static cove
#

@leaden tiger I think it'd be worth checking out. I think it handles images better than tkinter

dark gulch
#

In theory when I click on one of the listbox inputs it will come out as what is clicked

leaden tiger
#

@static cove yeah, thats the point ... i need buttons to click and the code does not run in a while loop 😦

static cove
#

@dark gulch so you're effectively printing .curselection() right now?

dark gulch
#

I got it to work @static cove For some reason when I did

global selection 
#

so I just put the entire thing inside the fuction

#

and it works

static cove
#

Try this:
your_listbox.get(your_listbox.curselection())

dark gulch
#

global selection just wasnt working and it wasnt producing an error

#

so idk

static cove
#

And print it

dark gulch
#

But this works

#

Ill try that

#

I was trying that earlier

#

I dont think listbox.get is a thing

static cove
#

That'll prevent you from writing the 'if selection == (5,):' thing

dark gulch
#

oh

#

wow

#

I guess I was just writing it wrong bc I tried to do this earlier bc I knew it would work bc for every other widget it did

#

Thanks

maiden dragon
#

anyone have decent experience with Automating Windows Applications Using COM

#

I am able to access the aplications library fine and call any of the methods i want, problem is i want to call that as fast as humanly possible, and right now it takes like 20 seconds to call them all and i cant start the next cycle till the first finishes

fluid tinsel
#

does PySide2 legally allow public applications?

dark gulch
#

no idea whats wrong

leaden tiger
#

@static cove i managed changing the foreground and background image with pygame ... i think i will get into pygame to create the game πŸ™‚