#user-interfaces

1 messages · Page 54 of 1

leaden tiger
#

@static cove thank you for now!

cloud crypt
#

do you know any gui designers for beginners?

fluid tinsel
#

nvm yeah it doesn’t

ionic forge
#

Hey! why the quit function(Tkinter) does not work when i run the program through my python file? when i run the program through cmd the quit button works🤔

static cove
#

@fluid tinsel pyside2 is lgpl, so if your code is open source it's fine

#

Stuff gets a bit weird when you want it closed source but with pyside2, if you do it correctly you can keep your specific code closed

#

@ionic forge what do you mean by "when you run the program through your python file"?

ionic forge
#

I mean by pressing F5 from the python file.
And the issue got solved idk how! Nvm

fluid tinsel
#

yeah it kinda won’t be so I won’t use it.
might write my own module using ctypes

dark gulch
#

can you assign a bind to multiple functions in tkinter

amber roost
#

you will either need to specify a function that calls all of those on their own or run the bind command multiple times with the add arg set to True

dark gulch
#

@static cove can you help me with making a global variable, Im still stuck on trying to do the listbox stuff

#
def LB():
        f = str(listbox.get(listbox.curselection()))
        print(f)

def F():
    f = ""
    if root.focus_get() == entry1:
        EL()
        print("EL")
    elif root.focus_get() == entry2:
        L()
        print("L")
    elif root.focus_get() == entry3:
        W()
        print("W")
        print(W())
    elif root.focus_get() == entry4:
        H()
        print("H")
    elif root.focus_get() == entry5:
        V()
        print("V")
    elif root.focus_get() == entry6:
        M()
        print("M")
    A = ""
    B = ""
    if f == "Length":
        A = str(v / (w * h))
    if f == "Width":
        A = str(v / (l * h))
    if f == "Height":
        A = str(v / (l * w))
    if f == "Area":
        A = str(l * w)
    if f == "Mass":
        if l != "" and w != "" and h != "":
            v = (l * w * h)
            A = str(d * v)
    if f == "Volume":
        if l == "" or w == "" or h == "":
            A = str(m / d)
            print(A)
        else:
            A = str(l * w * h)     
    label8['text'] = A
    if A == B:
        label8['text'] = "Error, Not Enough Entries"
    elif f == "":
        label8['text'] = ""
#

Why doesnt f get assinged the value globally

#

I tried global f and nothing

timid ether
#

void function that's not returning anything

dark gulch
#

So what do I return in order for f to be the list box output

#

I’m binding this to click in side of the listbox btw

timid ether
#

Mind posting code? I'll compile on my side

#

also try not to use same var names in different functions, makes it very confusing

dark gulch
#

its 200 lines

#
def F(*args):
    f = str(listbox.get(listbox.curselection()))
    return f


def callback(event):
    
    if root.focus_get() == entry1:
        EL()
        print("EL")
    elif root.focus_get() == entry2:
        L()
        print("L")
    elif root.focus_get() == entry3:
        W()
        print("W")
        print(W())
    elif root.focus_get() == entry4:
        H()
        print("H")
    elif root.focus_get() == entry5:
        V()
        print("V")
    elif root.focus_get() == entry6:
        M()
        print("M")
    A = ""
    B = ""
    if f == "Length":
        A = str(v / (w * h))
    if f == "Width":
        A = str(v / (l * h))
    if f == "Height":
        A = str(v / (l * w))
    if f == "Area":
        A = str(l * w)
    if f == "Mass":
        if l != "" and w != "" and h != "":
            v = (l * w * h)
            A = str(d * v)
    if f == "Volume":
        if l == "" or w == "" or h == "":
            A = str(m / d)
            print(A)
        else:
            A = str(l * w * h)     
    label8['text'] = A
    if A == B:
        label8['text'] = "Error, Not Enough Entries"
    elif f == "":
        label8['text'] = ""


root.bind('<Key>', callback)
#

here is the neccessary part

#

im trying to get f into the callback function

#

thats why its the same variable name

#

I want f to be a global variable, but

global f
#

Doesnt work

#

@timid ether

timid ether
#

add a parameter to callback

#

called f

#

im not too versed with tk so dunno about the internal logic

#

paste and share

dark gulch
#

@timid ether did u see the message?

timid ether
#

ye trying to make some sense of tk

dark gulch
#

ok lol

#

Thanks btw

timid ether
#

The function logic works now play around with the checks that you don't divide by 0 and so on
@dark gulch

obtuse nimbus
#

Dilove hi

timid ether
#

hello

obtuse nimbus
#

Ok

#

?

#

@timid ether

#

?

timid ether
#

?

obtuse nimbus
#

?

timid ether
#

I am there

obtuse nimbus
#

Ok

trim ibex
#

@dark gulch, you can bind multiple events with a parameter to bind add="+". This was really hard to find out btw.

#

oh i guess he said add=True works; i read it saying like this

river basalt
#

What’s a good library for UI ?

trim ibex
#

pyqt5 is nice

timid ether
#

Probably pyqt but it can be a real headache if you want some tiny changes

digital rose
#

hey guys, i wanna know how to draw a separator line in pyqt designer? like this

eager beacon
#

What framework?

#

Oh... You said

digital rose
#

hey guys, i wanna know how to draw a separator line in pyqt designer? like this
@digital rose

eager beacon
#

Make a qframe

digital rose
#

yeah i did

eager beacon
#

Oh.. In designer...

#

It's called HLine

#

It's in the widgets on the left

digital rose
#

Hline?

#

oh yeah there is it's called Horizontal Line

#

thanks

digital rose
#

Whats the easiest GUI framework for making an app like discord?

#

i mean with the complex mordernish style

static cove
#

@digital rose Probably kivy since it has kivymd. Are you looking to do this to learn a GUI framework or for some other reason?

eager beacon
#

what is kivymd?

static cove
#

kivymd is a set of widgets using material design that you can use with kivy. It has modern styling out of the box

eager beacon
#

ah neat

#

I wish PySide or PyQt had something like that

#

the closest I've found is QtModern and that's just a styled window widget

digital rose
#

how to make a "do you wish to save" message box on tkinter which can save and exit if you click yes, not save and exit if you click no and cancel if you press cancel?

#

i know how to make the message appear but idk how to make it save or not

#

Hey just a really simple Question, How do you Open a Qdialog from Main window Upon pushing a button

#

In PyQt

eager beacon
#

use QDialog.exec_() instead of show

digital rose
#

like this?

#

by the way i have the Qdialog class in separate file, (yes i'm importing it like from settings_dialog import Ui_Settings_QDialog)

eager beacon
#

if you have a UI file you should subclass QDialog and inherit Ui_Settings_QDialog

amber roost
#

@digital rose tkinter.messagebox.askyesnocancel will do just that and return True, False or None. This will however create a default dialog for the system; if you want to have more control over it, you will need to create a custom dialog involving tk.Toplevel

digital rose
#

@digital rose tkinter.messagebox.askyesnocancel will do just that and return True, False or None. This will however create a default dialog for the system; if you want to have more control over it, you will need to create a custom dialog involving tk.Toplevel
@amber roost how do i test if its value? do i just do if tkinter.messagebox.askyesnocancel is True?

amber roost
#

you'll have to call it, where it will block the program completely until the user clicked one of the buttons

#

the return value will correspond with the selected button

digital rose
#

ok it worked now

quaint hazel
#

hey, does anyone know how i can transfer variables between frames in tkinter?

quaint hazel
#

nvm got it

eager beacon
#

how did you do it?

modern folio
#

***Do anyone know Tkinter good??

If yes DM me***

noble kite
#

@modern folio what's your Tkinter question?

modern folio
#

just wanna learm

#

*learn

noble kite
modern folio
#

noo

#

i can see from YT also

#

but

#

i wanna see how a real guy does it

#

and

noble kite
#

it's best if you ask specific questions, just "learning Tkinter" is way too broad

modern folio
#

learn from them

noble kite
#

there is a lot to learn and you really need to build up from basic principles

modern folio
#

ya

#

just learned a bit

noble kite
#

same with any GUI system

modern folio
#

when we left click

#

it prints left click

#

like that

#

i made it yesterday

noble kite
#

sounds like a simple test of the mouse button

#

it's a good start!

modern folio
#

not test

#

sounds like a simple test of the mouse button
@noble kite TNX 🙂

noble kite
#

you need to describe it better, I don't know what you mean

modern folio
#

there is a window, when u left click, it prints left click in terminal, if you right clcik it prints right click in terminal, and if you middle click, it prints middle click in the terminal

noble kite
#

if that's all that the app does, it's just a basic example of using the mouse, which is a good first step

#

did that come from a tutorial?

modern folio
#

🙂

#

did that come from a tutorial?
@noble kite yes

noble kite
#

was that the whole tutorial, or is there more?

modern folio
#

it is like basics

#

so

#

for events

#

he gave this as the example

noble kite
#

so now you need to find another tutorial to take the next step

modern folio
#

he has a series of vids

#

me going in order

noble kite
#

the TKDocs one is very good, there are probably simpler ones

#

that's great, that's the way to do it

modern folio
#

thenewboston this is his channel name

noble kite
#

yes, he's good

modern folio
#

🙂

noble kite
#

go through the basics and get more comfortable about it, then start some simple projects of your own and come here and ask when you have specific questions

modern folio
#

sure

noble kite
#

that's really the best way to learn it

modern folio
#

can i add you as a friend

noble kite
#

yes you can

modern folio
#

sent you friend request

noble kite
#

accepted

modern folio
#

🙂

noble kite
#

good luck with it, I have to go for tonight, but will be on tomorrow

modern folio
#

sure

#

what is the time for you now??

noble kite
#

keep at it! it may take longer than you want, but you will learn it

#

1am

modern folio
#

what

#

ok

#

when will you nbe avalable

noble kite
#

I'm in the US, east coast

#

on and off during the day

modern folio
#

wait

#

so

#

in

#

like

#

ahh

#

NVM

#

leave it

#

good night / good day

noble kite
#

where are you?

modern folio
#

sorry can't say

#

but 10:30 am for me RN

noble kite
#

okay, 9 hours ahead of me so like timezone + 5 maybe?

modern folio
#

i guess

noble kite
#

we'll connect when we can, but ask specific questions here and people can help

modern folio
#

what is your WPM

noble kite
#

?

modern folio
#

words per minute

noble kite
#

never measured it, but I type with most fingers and can go pretty fast sometimes

modern folio
#

my averagew is 42

#

and

#

max

#

is

#

51

#

with

#

0 mistakes

noble kite
#

decent, keep practicing! for me it makes a big difference if I'm sitting up correctly! 😆

#

okay, gotta go but good luck!

modern folio
#

wait a min

noble kite
#

quickly

modern folio
#

bro

#

first test of the day

#

so

#

got

noble kite
#

it's good enough if you can type well, you don't need to compare your number to anyone

#

the backspace is my favorite key, but I get what I need said

modern folio
#

mine is backspace and space

noble kite
#

so I probably won't take that test, definitely not tonight

modern folio
#

lol

noble kite
#

there all good keys! 🙂

modern folio
#

if yours is a mechinical keyboard, don't take the test

noble kite
#

I won't! Good night Techno!

modern folio
#

GoodNight @noble kite

rain mantle
distant sand
#

hello

#

does anyome know how do i connect js

#

with a py script

#

bcuz i want a js ui

bronze basin
#

eel library

#

search it up

distant sand
#

ok thx

distant sand
#

hello is there a good eel tutorial

fluid tinsel
#

I was looking into wxPython since it seems interesting, what are some good resources for it?
I’ve already read the realpython tutorial, and tried reading the official documentation, what other resources are there?

digital rose
#

Hi, so i wanna Know How do you access a Push button in Qdialog from Your main window?
i tried like this but it doesn't work

self.dialog = Ui_Settings_QDialog()
self.dialog.connect_btn.clicked.connect(self.serial_connection)```
#

oh and im using PyQt5

charred comet
#

hey guys

#

anyone know why i cant start django server with python ?

grave steeple
#

code

charred comet
#

but it wont start

digital rose
#

Guyssss

grave steeple
#

show me code in a codeblock please

#

@digital rose don't blame me but idk what that even is

charred comet
#

im trying to learn django. it installs but it wont start the development server

grave steeple
#

code

#

code

#

source code

charred comet
#

ah ok

digital rose
grave steeple
#

yea'

digital rose
#

i wanna Know How do you access a Push button in Qdialog from Your main window?
i tried like this but it doesn't work

self.dialog = Ui_Settings_QDialog()
self.dialog.connect_btn.clicked.connect(self.serial_connection)```
 and im using PyQt5
digital rose
#

🥺

digital rose
#

can someone pls help me

#

i need help making a button without using tlink

red cape
#

Hey guys, I know a pretty good amount of python but all I do works on the command line, I want to create actual GUIs and I am not talking about the ones like TKinter but actual interfaces like that of Premiere Pro or Discord itself, I assume that would require to learn a front-end language, please guide me in the following. (Originally posted in questions but lead here)

eager beacon
#

Discord is an electron app. You'd need to know javascript/typescript for that. Premier Pro is built using the platforms native libraries which you can't do easily with Python. If you use pyqt5 you can create the entire app in ython and style it with CSS

trim oak
#

You can make discord like app with pyqt5 but you must put some effort to do it

eager beacon
#

what do you mean @trim oak

trim oak
#

I mean you can make it look like discord with pyqt5 if you put some effort

#

Not easy

eager beacon
#

Can you give a specific example?

silk basin
#

Any idea of how to implement a time picker like this in PyQt5? I tried QDateTimeEdit but that didn't really give me what I was looking for

silk basin
#

Also if anyone has any suggestions on closing a window when a button is pressed that would also be nice

bronze basin
#

just do self.yourbutton.cliicked.connect(lambda: self.close()/window.close())

#

@silk basin

silk basin
#

QVBoxLayout doesn't have a .close()

#

from what I can tell

bronze basin
#

there isnt a self.close()?

silk basin
#

no

#

I will check again but I am pretty sure there isn't

bronze basin
#

hmm

silk basin
#

'QVBoxLayout' object has no attribute 'close'

#

@bronze basin

#

So I have my QVBoxLayout called:

self.l1 = QVBoxLayout()

 self.done = QPushButton("Done", self)
 self.done.clicked.connect(self.l1.close)
 self.l1.addWidget(self.done)
#

Yeah that's what I tried to do but for some reason it simply wont work :/

eager beacon
#

QVBox isn't your window

#

Remember, you can't see a QLayout without a QWidget

#

@silk basin and as far as the time picker goes you said you tried QDateTimeEdit.. why not QTimeEdit?

silk basin
#

@silk basin and as far as the time picker goes you said you tried QDateTimeEdit.. why not QTimeEdit?
@eager beacon That did indeed work

#

Also so this is a different popup than the calculator

eager beacon
#

same premise

#

Whatever l1 is the layout for that is what you want to close

silk basin
#

So when I click done I try to close the window but it doesn't want to close

#

oh shoot

eager beacon
#

self.thatWidget.close()

silk basin
#

my goodness

#

Chris you are simply a genius

eager beacon
#

aw thanks pal

silk basin
#

I am just going to tinker with that QTimeEdit now

#

I would like it a list but its only showing one time slot at a time

eager beacon
#

hm

#

well you could just use a QComboBox

#

if a dropdown is what you are looking for

silk basin
#

I thought of that well see

#

I'll probably implement both methonds and then test to see which is better

eager beacon
#

a dateTimeEdit does inherit the QAbstractCombo so you could customize it but it would probably be a ton easier to just make a comboBox

silk basin
#

oof

#

the less work the better lol. Already like 4k lines deep in this project lmao

eager beacon
#

!e

hours = list('123456789') + ['10','11','12']
minutes = ['00','30']
periods=['AM','PM']
for period in periods:
    for hour in hours:
        for minute in minutes:
            time_ = f'{hour}:{minute} {period}'
            if int(hour) < 5:
                print(time_)
                break
proven basinBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

eager beacon
#

aww 😦

#

either way

#

just take out everything below time_

#

and add time_ to the combo

#

you might want to create an actual datetime.time object first

silk basin
#

ohh bet

#

I can definitely use that

#

Thank you, while I have you, you wouldn't happen to know how to include a warning message for that done button would you?

#

Should I use QDialog

#

I now want a warning that says, if an assignment has not been added and the user clicks "Done" I want a warning to ask to make sure they are aware they have not added an assignment if they are sure they want to continue.

I already set a trigger inside of Add Assignment that sets the trigger to 1 when an assignment has been added. I just need a way of the error message popping up. @eager beacon

eager beacon
#

Is it a warning or a confirmation

silk basin
#

I guess confirmation

eager beacon
#

gotcha

#

use QMessageBox

silk basin
#

Let me give that a shot

#

@eager beacon

    def Close(self):
        if self.global_trigger == 0:
            print("000")
            self.message_box = QMessageBox()
            self.message_box.setText("Are you sure you want to quit without adding any assignemnts?")
            self.message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
            
        else:
            self.pop.close()

It is entering the if statement but it isn't bringing the QMessagebox

delicate latch
#

what can i use for authentication with google and through email and password?

eager beacon
#

it's because you haven't opened it

#

you need to use exec_() to show it iirc

#

@delicate latch google-auth works

delicate latch
#

ok.. though @eager beacon i need to connect it in some way with firebase

eager beacon
#

how do you need to interact with firebase?

#

you'd probably be better off looking for a firebase python plugin from google

#

99.99% chance it includes an auth function somewhere in it

silk basin
#
    def Close(self):
        if self.global_trigger == 0:
            print("000")
            self.message_box = QMessageBox()
            self.message_box.setText("Are you sure you want to quit without adding any assignemnts?")
            self.message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
            return_value = self.message_box.exec()
            if return_value == QMessageBox.Yes:
                self.pop.close()
        else:
            self.pop.close()

Yep! this worked.

eager beacon
#

hmm

#

thats just for the popup, right?

silk basin
#

yeah

#

If user clicks yes it will close everything. if user clicks cancel it will return them to the add assignment widget

eager beacon
#

yeah, that's the benefit to using the message box over making your own dialog

#

you can even add fun little icons

silk basin
#

yeah I see that

#

my partners made a whole ass dialog adder function but is way too complicated

#

this method is way better

delicate latch
#

@eager beacon i need a database though...

eager beacon
#

I don't understand what the problem is

#

there is an auth example in the first code block

#

@silk basin what did they make?

silk basin
#

whats the command that allows me to post long code

#

Also @eager beacon can I explain my plan and then you tell me if I should 100% do this a different way or I have the right idea lol

eager beacon
#

!code

proven basinBOT
#

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:

```python
print('Hello world!')
```

Note:
These are backticks, not quotes. Backticks can usually be found on the tilde key.
• You can also use py as the language instead of python
• The language must be on the first line next to the backticks with no space between them

This will result in the following:

print('Hello world!')
eager beacon
#

that?

#

explain away

silk basin
#

So I have what I call an assignment adder. This allows the user to input details about an assignment they have.

eager beacon
#

okay I'm with you so far

silk basin
#

This is the information I grab from the user input (still working on time)

So what I need to do is get this organize it and set almost like a physical list this will be implemented into our GUI that will have all the assignments in order based on date/time along with ofcourse having the name and class next to the assignment

#

What I was planning on doing is using Pandas loading all the data I have for the assignment and implementing this sorting algorithm to allow me to output in the GUI an ordered list of up coming assignments and names. What do you think?

#

The only issue thusfar is I need a way for storing assignments even after the program is closed that way when the user opens up the program their assignments are still there(This method I have yet to think of)

eager beacon
#

how are you storing the assignments?

silk basin
#

lol

eager beacon
#

yeah...

#

well

#

is that the only widget a user can use to add info for an assignment?

silk basin
#

yeah I will need to make a way in the future of editing an assignment but thats for a later problem

eager beacon
#

if you want to keep it simple you could append every entry to a csv file and sort by the date column before adding it to a listWidget

silk basin
#

That is exactly what I was thinking

#

after sorting I would add in slot i of the list, date, name, class, and time and then print that out.

#

you think thats the best way of going about that?

eager beacon
#

oh

#

not a listWIdget

#

I meant a tableWidget

silk basin
#

tablewidget

eager beacon
#

same concept

silk basin
#

I'll do research

#

anyway idea of how I would save the files

eager beacon
#

the difference is a list widget has 1 column table widget has as many as you want

silk basin
#

Yeah bet. That makes sense

eager beacon
#

create an empty csv file if it doesn't exist when you start the app and use 'a' when you go to save it after the popup is closed

silk basin
#

yeah bet

eager beacon
#

i mean with open('assignments.csv','a') as file:

silk basin
#

I can definitely do that

eager beacon
#

sounds easy enough

silk basin
#

Lol well see when I am sitting here trying to figure it out

#

we get to demo our project tomorrow though so i am excited

delicate latch
#
from ui_Register_Window import Ui_MainWindow
import sys
from PySide2.QtWidgets import QMainWindow, QApplication
from Firebase import FirebaseManager
from PySide2.QtGui import QMovie

class RegisterWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.registerButton.clicked.connect(self.register)
        

    def register(self):
        manager = FirebaseManager()
        name = self.ui.usernameField.text()
        emailID = self.ui.emailIDField.text()
        password = self.ui.passwordField.text()
        confirm_password = self.ui.confirmField.text()

        if password != confirm_password:
            self.ui.errorMessage.setText("Passwords do not match.")
            self.ui.errorMessage.show()
        
        manager.registerUser(emailID, password, name)


app = QApplication(sys.argv)
window = RegisterWindow()
window.show()
sys.exit(app.exec_())
#

i am trying to call this register windows from an initial screen when the person preessed the button

#
from ui_Initial_Window import Ui_MainWindow
import sys
from PySide2.QtWidgets import QMainWindow, QApplication
from Firebase import FirebaseManager
from PySide2.QtGui import QMovie
from Register import RegisterWindow


class InitialWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.movie = QMovie("space.gif")
        self.ui.label.setMovie(self.ui.movie)
        self.ui.movie.start()
        self.registerButton.clicked.connect(self.show_register_screen)

    def show_register_screen(self):
        dialog = RegisterWindow()
        dialog.show()

app = QApplication(sys.argv)
window = InitialWindow()
window.show()
sys.exit(app.exec_())
#

however, when i run this, i get the register screen, not the initial screen

eager beacon
#

Is the app/show code at the bottom from your testing or is that how it's set up in your IDE?

#

if it's like that then that code is going to run when you import RegisterWindow

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

do the same with RegisterWindow

#

@delicate latch

delicate latch
#
from ui_Initial_Window import Ui_MainWindow
import sys
from PySide2.QtWidgets import QMainWindow, QApplication
from Firebase import FirebaseManager
from PySide2.QtGui import QMovie
from Register import RegisterWindow


class InitialWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.registerButton.clicked.connect(self.show_register_screen)

    def show_register_screen(self):
        dialog = RegisterWindow()
        dialog.show()

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

this doesn't work either

eager beacon
#

you did the same in both files?

delicate latch
#

no..

eager beacon
#

oh

#

technically you only need the __main__ in the registerWindow but it's good practice

marsh urchin
#

`` def multiMap(val, _in, _out, size):
if val <= _in[0]:
return _out[0]

if val >= _in[size - 1]:
    return _out[size - 1]

# search right interval
pos = 1  # _in[0] allready tested
while val > _in[pos]:
    pos += 1

# this will handle all exact "points" in the _in array
if val == _in[pos]:
    return _out[pos]

# interpolate in the right segment for the rest
return (val - _in[pos - 1]) * (_out[pos] - _out[pos - 1]) / (_in[pos] - _in[pos - 1]) + _out[pos - 1]

multiMap(3, [0, 20, 40, 60, 80, 100], [0, 15, 43, 53, 75, 100], 100)``

#

can some one see what im doing wrong here?

#

im new to phyton

oak portal
#

Is there a simple way to display a dialog window using tkinter?

#

GWchadThonkery Don't wanna create an entirely new Tk object for that

amber roost
#

@oak portal "Simple" dialogs like those "Yes/No" or Info/Warning/Error messageboxes are supported by tkinter in tkinter.messagebox, but for other dialogs you'll need to create tkinter.Toplevel objects and call a series of focus rerouting commands on them.

oak portal
#

Well... that's painful

#

Thanks

digital rose
#

how to make tkinter button accept coroutine???

oak portal
#

In tkinter, if you create a tk object, and don't give it a frame, when you start running the main loop, does it create it's own frame object?

lofty wyvern
#

@oak portal no it just adds it to the parent frame, I'm fighting that now as well.

oak portal
#

So what if you wanna create multiple windows? You just have to create a new Tk object?

lofty wyvern
#

I'm no expert by any means, I'm trying to use a class for a pop up window that is defined in a separate file and it just adds it the window that calls it. Trying to find the solution now. I'm sure there is someone on here that knows a lot more than me

#

Best I can tell you is yes

amber roost
#

You should only create two Tk instances if you really know what you're doing, they both claim an entire thread and both access a tcl background system where they may overlap and disrupt eachother in some way

lofty wyvern
#

I managed to get what I wanted by creating a function that called the class and used a different tk.TK(). Is that the optimal way to do it?

oak portal
#

@amber roost So how else would I create two windows without creating two Tk instances

#

And Frame is supposed to be put inside a Tk then?

#

I am confused GWchadThonkery

amber roost
#

I guess I could copy-paste the code I use here

#

Although to be honest these commands are just the result of trial and error until they worked; then I never touched them again

#

Basically in the one and only tkinter program i have all dialogs inherit from a common base dialog, which itself inherits from tk.Toplevel

oak portal
#

And what's Tk.Toplevel?

#

I don't understand which class creates the window, if it's Tk, Frame, or whatever else class

amber roost
#

tk.Toplevel is responsible for the window itself

#

Tk and Toplevel are similar in that fashion, but Tk is more than a Toplevel

oak portal
#

Well, there must be some pythonic way to create multiple windows GWchadThonkery

amber roost
#

After the dialog is created, it needs to be explicitly brought up using a show method

def show(self):
    """Show the dialog."""
    self.grab_set() # Events will only be routed to this dialog
    self.focus_set() # Request focus to this dialog

    #setup interface
    self.rootframe = ttk.Frame(self)
    self._mainframe = ttk.Frame(self.rootframe)
    self.body(self._mainframe) # Overridden in subclasses
    self._mainframe.pack(expand = 1, fill = tk.BOTH, padx = 5, pady = 5)
    self.rootframe.pack(expand = 1, fill = tk.BOTH)

    self.withdraw() # Creates the toplevel, but in a hidden state
    # configure some stuff, this is copy-pasted from tkinter.simpledialog iirc
    if self.parent.winfo_viewable():
        self.transient(self.parent)

    if self.parent is not None:
        self.geometry("+{}+{}".format(self.parent.winfo_rootx() + 50,
            self.parent.winfo_rooty() + 50))

    # show on screen
    self.deiconify()
    # wait until self is visible
    self.wait_visibility()
    # wait until self is destroyed
    self.wait_window(self)
#

To be fair, I have no idea if wait_visibility or withdraw are neccessary

#

I think wait_window and the entire grab_set thing may also be replaceable with mainloop in some sense

#

I'll try around a bit

oak portal
#

Hmm

amber roost
#

yeah, still works just as fine without withdraw, deiconify and wait_visibility

#

you want wait_window though, in my case the main program continues running alongside with the dialog otherwise and screws up its config

oak portal
#

I'll have to look at the docs because I don't know half of those methods

amber roost
#

It seems that replacing the wait_window thing with mainloop is a bad idea as well, since the code that should run after the dialog is closed just doesn't anymore

#

however the invoking code atm looks like

dialog = Settings(self.root, ...)
dialog.show()
```, while it probably should be
```py
dialog = Settings(self.root, ...)
dialog.show()
self.root.wait_window(dialog)
```, since it makes no sense the dialog is waiting for itself to be destroyed
#

It works, but ... feels off

#

also an interesting thing i noticed, if a button is responsible for opening up dialogs and you spam Space on it super fast, it opens 2 dialogs for no reason

#

maybe i should report that issue to the poor soul that still maintains tk today

oak portal
#

What does the Tk.mainloop() run? GWchadThonkery

lofty wyvern
#

Simplified, it runs the window. Nothing will run without it

oak portal
#

But what's inside GWchadThonkery

#

I was thinking that it might be doing something like

while True:
  self.windowfunction()

So that you can take that function and run multiple of them

true harbor
#

has anyone had success in installing kevi?

static cove
#

@true harbor what version of python are you trying to install Kivy on?

#

@oak portal you mean what's inside .mainloop()?

true harbor
#

@true harbor what version of python are you trying to install Kivy on?
@static cove not sure, im trying to download it on pycharm and this is the error

also, is there a better gui library that you know? i just choose the first one that had decent documentation

static cove
#

@true harbor Can you go to File -> Settings -> ProjectName -> Project Interpreter and take a screen shot of that window?

true harbor
#

@static cove not sure, im trying to download it on pycharm and this is the error

also, is there a better gui library that you know? i just choose the first one that had decent documentation
@true harbor i assume this is the version?

static cove
#

Ah, okay

bronze basin
#

there is PyQt @true harbor

#

for a better gui library

true harbor
#

@true harbor Can you go to File -> Settings -> ProjectName -> Project Interpreter and take a screen shot of that window?
@static cove

static cove
true harbor
#

i tried that

#

but will try again

static cove
#

oh just do pip install --pre --extra-index-url=https://kivy.org/downloads/simple kivy[base] then

true harbor
#

oh just do pip install --pre --extra-index-url=https://kivy.org/downloads/simple kivy[base] then
@static cove seems to be work, will try runnig kivy to test

oak portal
#

@oak portal you mean what's inside .mainloop()?
@static cove Basically. I am trying to figure out how to make multiple windows GWchadThonkery

#

You can't tell me that the creator(s) of tkinter didn't think about that

static cove
#

@oak portal use Toplevel()

#

mainloop() starts the Tk() instance, of which there should only be one

oak portal
#

And what is Toplevel and what does it do GWchadThonkery

static cove
oak portal
#

Thank you

#

Okay, that's for popups from the 5 lines that I read. GWchadThonkery

static cove
#

It's not? It's like a Frame but it's top level instead of being a child

oak portal
#

That conflicts with what the site you just sent me says

static cove
#

It doesn't

The Toplevel widget work pretty much like Frame, but it is displayed in a separate, top-level window. Such windows usually have title bars, borders, and other “window decorations”.

true harbor
#

@static cove seems to be work, will try runnig kivy to test
@true harbor it works, thank you so much

oak portal
#

Nice

#

It does

The Toplevel widget is used to display extra application windows, dialogs, and other “pop-up” windows.

static cove
#

@true harbor and also check out kivymd for material design widgets you can use if you don't now about it yet

true harbor
#

ok, thanks

oak portal
#

Well, it works for what my intended purpose is

static cove
#

Do you not want other application windows?

#

Toplevel is what gets you multiple windows

#

It can just also be used for dialogs and pop-ups

#

Because those are also, technically, other windows

oak portal
#

Does it disable the original window?

static cove
#

Nope, but you can hide/show the original window as necessary

oak portal
#

Uhuh, so this is exactly what I was looking for, thank you

#

:]

true harbor
#

there is PyQt @true harbor
@bronze basin where would i find the docs for that?

static cove
#

@true harbor PyQt is a binding of a C++ library, so the source documentation is in c++. There are the pyside2 documents, which tries to convert the docs to use python syntax, but it's not the greatest

true harbor
#

ok, what library would you recommend for begginers?

oak portal
#

Okay, last question, Frame still needs a Tk, right?

static cove
#

Your tkinter program should always have a Tk() instance as that is what runs your GUI. But it should almost always only have 1 Tk() instance

#

@true harbor I would give kivy a shot, I don't have a lot of experience with it but it's pretty nice from what I've seen

true harbor
#

@true harbor I would give kivy a shot, I don't have a lot of experience with it but it's pretty nice from what I've seen
@static cove ok, any else?

oak portal
#

Okay okay, probably last question, what's the difference between super and super()? GWchadThonkery

#

Super() returns what the class is inheriting from GWchadThonkery

oak portal
#

I'm trying to make a frame have the same size as the original, but it just ain't working

#
from tkinter import *

class main(Tk):
    def __init__(self):
        super().__init__(className=" Blackjack ")
        self.frame()
        self.geometry("300x300+50+50")
        self.mainloop()

    def frame(self):
        self._f = Frame(bg="black", width=self.winfo_width(), height=self.winfo_height())
        print(self.winfo_width())
        self._f.pack()
#

Took some time, but you gotta give the .pack() arguments expand=1, fill="both"

digital rose
unique forge
#

Hi

#

if anyone knows QT

#

or

#

QT Designer

#

please answer my stack overflow

#

@rotund flax

#

@vast grove @foggy junco

static cove
#

Why are you tagging one of the owners?

#

What's your GUI code so far?

oak portal
#

I am having trouble setting window icon in tkinter, I am not sure what function to call

#

Google more or less returned non-existent functions

#

Do I have to specify where it is, even though it's right next to the .py file?

static cove
#

what does your code look like now for setting the favicon?

oak portal
#

self.iconbitmap(self.PhotoImage(file='ace_of_spades_t.png'))

#

Somewhere, I found this weird photoimage method GWchadThonkery

#

Favicon?

unique forge
#

I posted the code

#

of the current GUI

#

in the stack overflow

#

@static cove

static cove
#

@oak portal that window icon is usually called a favicon. So you load in the image you want. Usually with Pillow and then use the iconbitmap to point to that photo that you loaded in

oak portal
#

Well that's annoying

unique forge
#

hello?

oak portal
#

I don't like using external libraries GWchadThonkery

static cove
#

(I'm looking at your code, give me a minute)

unique forge
#

oh sorry

static cove
#

@oak portal why?

oak portal
#

Since the person then needs to have that library

static cove
oak portal
#

Well, I just have to convert it to a .gif then GWchadThonkery

static cove
#

@unique forge Could you post a picture of what the UI looks like? It'll make it a bit easier for me to explain how to structure your code

oak portal
#

Now what to do with the gif file GWchadThonkery

#

file=Tk.PhotoImage("filename")?

unique forge
#

ok @static cove

static cove
#

mhm
and then you can do:
self.iconbitmap(file) and that shoooould work

oak portal
#

Shouuuulllddddddd

unique forge
#

I use Mu because Pycharm keeps saying errors

oak portal
#
self.icon = self.PhotoImage('ace_of_spades_t.gif')
self.iconbitmap(file=self.icon)

This didn't work

#

And I did try opening the file

#

...Does it actually have PhotoImage?

static cove
#

Okay, so each of those main buttons pulls up the next UI widget, which is good. Each of those UI widgets should have their own "Enter" buttons to run the required code. When the user presses the "Enter" button in the sub-widgets, you should get the values they entered in the LineEditWidgets associated with the sub-widget, and then run the code

oak portal
#

OOOHH

#

PhotoImage is a class itself

static cove
#

@oak portal what does:

self.icon = tk.PhotoImage('ace_of_spades_t.gif')
self.iconbitmap(self.icon)

get you?

oak portal
#

That explains it

#

I thought that PhotoImage was a function of Tk class

#

It doesn't get me anything

#
        self.icon = PhotoImage('ace_of_spades_t.gif')
        self.iconbitmap(file=self.icon)
#

This neither

static cove
#

are you doing from tkinter import * as your import

oak portal
#

Ye

static cove
#

so don't do the file= in the iconbitmap, just put (self.icon)

oak portal
#
from tkinter import *

class blackjack(Tk):
    def __init__(self):
        super().__init__(className=' Blackjack ')
        self.icon = PhotoImage(name='ace_of_spades_t.gif')
        self.iconbitmap(self.icon)
        self.frame()
        self.geometry('300x300+50+50')
        self.mainloop()

    def frame(self):
        self._f = Frame(self, bg='#303030')
        self._f.pack(expand=1, fill='both')

main = blackjack()
#

I am unsure why it doesn't work, because it does open the window

#

...

#

I have this weird feeling that it's running something different that I am thinking

#

There is literally a print statement that doesn't work, soooo... I might be running completely different file

#

Oh god

#

@static cove I'm so sorry, the whole time, I've been editing a completely different file with the same name

unique forge
#

how do you add code snippets to discord?

static cove
#

!code

proven basinBOT
#

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:

```python
print('Hello world!')
```

Note:
These are backticks, not quotes. Backticks can usually be found on the tilde key.
• You can also use py as the language instead of python
• The language must be on the first line next to the backticks with no space between them

This will result in the following:

print('Hello world!')
unique forge
#

'''python

static cove
#

so you need backticks, this: ` not '

unique forge
#

where is the tilde key

static cove
#

It's above the tab key for me

oak portal
#

Same for me, but I have to press right alt for it

unique forge
#


import sys
from PyQt5.QtWidgets import (QApplication, QMainWindow,)
from PyQt5 import QtWidgets

import PTCGUI

class MainWindow (QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = PTCGUI.Ui_MainWindow()
        self.ui.setupUi(self)
        title = ("Pythagorean Theorem Calculator")
        self.setWindowTitle(title)
        self.setFixedSize(16777215, 16777215)
#

done

#

it was above tab for me

oak portal
#

This

from tkinter import *

class blackjack(Tk):
    def __init__(self):
        super().__init__(className=' Blackjack ')
        self.icon = PhotoImage(file='ace_of_spades_t.gif')
        self.iconbitmap(self.icon)
        self.frame()
        self.geometry('300x300+50+50')
        self.mainloop()

    def frame(self):
        self._f = Frame(self, bg='#303030')
        self._f.pack(expand=1, fill='both')

main = blackjack()

returns

_tkinter.TclError: bitmap "pyimage1" not defined
static cove
#

Is that gif file located in the same directory as your script?

oak portal
#

Yes

#

If I remove file=, it returns

_tkinter.TclError: bitmap "ace_of_spades_t.gif" not defined
static cove
#

hmmm... so question, you're subclassing the Tk instance, why?

oak portal
#

Well, my original thought process was that I could define the mainloop function so it runs another function during it, but at that time I did not realize that this was a dumb idea and that mainloop is a while loop

#

Basically, flawed logic lead to that monstrosity

static cove
#

aaaah, could you try this code? I'm curious if it's an oddity with the Tk() instance getting initialized wonkily

from tkinter import *

class blackjack():
    def __init__(self):
        self.root = Tk()
        self.icon = PhotoImage(file='ace_of_spades_t.gif')
        self.iconbitmap(self.icon)
        self.frame()
        self.geometry('300x300+50+50')
        self.mainloop()

    def frame(self):
        self._f = Frame(self.root, bg='#303030')
        self._f.pack(expand=1, fill='both')

main = blackjack()
oak portal
#

I sure will

#

Btw I am running 3.9, just in case that's important

#
AttributeError: 'blackjack' object has no attribute 'iconbitmap'

is returned

static cove
#

okay, progress. Give me one second to pull up the docs again

#

self.iconbitmap(self.icon) --> self.root.iconbitmap(self.icon)

eager beacon
#

don't you need to inherit something?

oak portal
#

So, I remade it without class inheritance

#
from tkinter import *

main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
icon = PhotoImage('ace_of_spades_t.gif')
main.iconbitmap(icon)
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
main.mainloop()
#

If this is better

#

But it returns

_tkinter.TclError: bitmap "ace_of_spades_t.gif" not defined
static cove
#

What happens if you have the file= inside the PhotoImage?

eager beacon
#

is the file in your script directory?

oak portal
#

Ye

eager beacon
#

have you tried using an absolute path?

oak portal
#

What happens if you have the file= inside the PhotoImage?
@static cove

_tkinter.TclError: bitmap "pyimage1" not defined
#

have you tried using an absolute path?
@eager beacon No I have not

#

So I tried an absolute path

#

Same error

eager beacon
#

it needs to be a .ico

#

according to a random website

oak portal
#

I'd normally trust that, but the PhotoImage help file disagrees

static cove
#

one more thing to try:
icon = PhotoImage(master=main, file='ace_of_spades_t.gif')

#

For it to be an .ico you'd need to use PIL/Pillow

oak portal
#
_tkinter.TclError: bitmap "pyimage1" not defined
static cove
#

mmmm... give me one second. I need to test something before I verify that this is what's causing the problem

eager beacon
#

root.iconphoto(False, tk.PhotoImage(file='/path/to/ico/icon.png'))

#

maybe that would work with a .gif

oak portal
#

That returns a completely new error

_tkinter.TclError: wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"
static cove
#

@oak portal so running that code I am not getting an error unless I give it a non-existent file name

eager beacon
#

if you convert your gif to a .ico you don't need the photoImage

static cove
#

So are you sure that .gif file is in the same folder as the script you're running?

eager beacon
#

you just pass the path to iconbitmap

oak portal
#

Quite sure

eager beacon
oak portal
#

Lemme try renaming the file

static cove
#

You mentioned before you were running the wrong file with the same name, is that happening again?

oak portal
#

Not this time

#

@static cove If I enter a non-existent file, it does return a different error, so it is finding the file

eager beacon
#

if you don't have a solid reason to use a .gif then convert it and try again

static cove
#

I only get this error: _tkinter.TclError: bitmap "pyimage1" not defined if I pass it a non-existant file. If I pass in a gif of the proper size it works. If I directly pass in an .ico file to the .iconbitmap() it works

eager beacon
#

do you have more than one Tk() running in that file?

oak portal
#

Nope

#

But I just tried putting an .ico of the image into the thing

#
main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
# icon = PhotoImage(file='ace_of_spades_t.gif')
main.iconbitmap("ace_of_spaces_t.ico")
main.mainloop()

Returns:

_tkinter.TclError: bitmap "ace_of_spaces_t.ico" not defined

And

main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
# icon = PhotoImage(file='ace_of_spades_t.gif')
main.iconphoto("ace_of_spaces_t.ico")
main.mainloop()

Returns:

_tkinter.TclError: wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"
#

This is magical

eager beacon
#

run this in the same file

import os
print(os.listdir())
static cove
#
from tkinter import *

main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
main.iconbitmap('ghost.ico')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
main.mainloop()

This works for me, so I don't know what's happening on your end.

oak portal
#

Returns:

['blackjack.py', 'ace_of_spaces_t.gif', 'ace_of_spades_t.ico']
#

t_T

#

ace_of_spaces

static cove
#

... yeaaaah

unique forge
#

@static cove I know you are helping someone else but I need to get my app finished quickly

eager beacon
#

upload your image to google drive or something and send a link

static cove
#

@unique forge I gave you a suggestion on how I would approach it and didn't see anything else from you

eager beacon
#

otherwise I don't think I have anything else useful to add

unique forge
#

sorry

#

I cant see it

static cove
#

So the code where you use the .ico file, you should change the file name to the correct one >_> @oak portal

oak portal
#
main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
# icon = PhotoImage(file='ace_of_spades_t.gif')
main.iconbitmap("ace_of_spades_t.ico")
main.mainloop()

returns

_tkinter.TclError: wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"
#

And the name file is correct

unique forge
#

I know that @static cove but I dont know QT5 very well so I dont know how to program it

#

if you have a tutorial maybe, that would help

eager beacon
#

print(open('ace_of_spades_t.ico','rb').read())

oak portal
#

A lot of text

#

Lot more than fits into one message

eager beacon
#

are you going to upload your image?

oak portal
#

Upload it here?

#

Or where

#

.ico files don't display

eager beacon
#

upload it somewhere else

#

drive

#

wetransfer

unique forge
#

upload the .png

oak portal
#

I am not sure how that will help

eager beacon
#

we can test to see if the image is the probelm...

oak portal
#

This is the .png

static cove
eager beacon
#

is that only an alpha...

unique forge
#

ok great

static cove
oak portal
#

Sure

#
_tkinter.TclError: bitmap "ghost.ico" not defined
#

And yes, it is in the same directory

#

And it is the correct name

#
main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
# icon = PhotoImage(file='ace_of_spades_t.gif')
main.iconbitmap("ghost.ico")
main.mainloop()
#

This is what I ran

static cove
#

That exact snippet, with that exact .ico file works for me

oak portal
#

. _.

#

Well, this is some unique error to me then?

#

What python version you're running it on?

static cove
#

Tested it on 3.8.6 and 3.9

oak portal
#

Tried it on 3.8.5 and 3.9 and 2.8.7, none work

#

(trying on 2.8.7 is more or less a joke tho GWchadThonkery )

static cove
#

Could you do this one more time at the top of your script? I'm curious about something:

import os
print(os.listdir())
oak portal
#

Whole entire return:

['ghost.ico', 'blackjack.py', 'ace_of_spades_t.gif', 'ace_of_spades_t.ico']
Traceback (most recent call last):
  File "/home/potato/Documents/Blackjack/blackjack.py", line 26, in <module>
    main.iconbitmap("ghost.ico")
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2073, in wm_iconbitmap
    return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "ghost.ico" not defined
#

I usually just sent the last line

#
from tkinter import *

import os
print(os.listdir())

main = Tk(className=' Blackjack ')
main.geometry('300x300+50+50')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')
# icon = PhotoImage(file='ace_of_spades_t.gif')
main.iconbitmap("ghost.ico")
main.mainloop()
#

This is what I ran

static cove
#

What OS are you on?

oak portal
#

Pop OS, Linux

eager beacon
#

dude its the image

static cove
#

They're testing it with an ico that I am also using to test now

eager beacon
#
    import tkinter as tk
    root = tk.Tk()
    root.iconphoto(False, tk.PhotoImage(file='ace_of_spades_t.png'))
    root.mainloop()
#

I tested with the image he uploaded and got the not defined error

#

because it had an alpha

#

when i removed it i got this

oak portal
#

Well...

#

Wait

#

Hold up

#

I just ran what Chris_ sent with the png file in the directory

#

And it works?!?

#

Holy Ravioli Under The Bench?

static cove
#

So for the .ico file issue, apparently on some linux distros it needs to be an .xbm file with a path like this: @/icon.xmb

oak portal
#

Okay, bug the png file suddenly works?

static cove
#

not suddenly, Chris_ had said they removed the alpha on it

eager beacon
#

the png you have works?

#

or the one I sent?

oak portal
#

The one I have

#

With alpha

eager beacon
#

okay well then something changed when you said it didn't work when we suggested it about 30 lines up

oak portal
#

Well, I never tried to use it on the .png

#

Only on the .gif

#

WHICH NOW WORKS TOO?!?

eager beacon
#

yeah...

static cove
#

I wonder if it's the False that was added?

oak portal
#

Someone slap me with a fish because my rumbles are scrumbled.

#

removes False

#
_tkinter.TclError: wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"
#

Well

#

Someone cut off my legs >:[

#

It doesn't work because of that missing thatement?

static cove
#

Apparently

#

fuck if I know the Tcl specifics for that

oak portal
#

Well

#

I found the culprit basically

eager beacon
#

this is why people use pyqt

static cove
#

hard agree on that

oak portal
#

iconphoto's first argument is a truth statement

#

And we we're trying to pass an image into it

#

:[

static cove
#

the heat death of the universe will occur before tkinter gets reasonable docs and a reasonable implementation

oak portal
#

Is this the pain of using default modules

eager beacon
#

just tk

oak portal
#

Well gentlemen, @eager beacon, @static cove. I thank you for your help, and now I'll go take a cold shower while crying at 1 in the morning.

#

Goodnight

uncut pawn
#

How do I create other files in python that connect in Tkinter
so like 2 files, first have a button and a window and that button will send u to another file with another window

lofty wyvern
#

@uncut pawn you need to treat them as an import library and the use a lambda function to call them. I'm not an expert, but this is what I have found to work. Hopefully, someone will correct me if I'm wrong.

digital rose
#

im trying to make my cursor move with my voice and i cannot make my program learn the request to action properly

digital rose
#

is there any async ui module?

digital rose
#

vui with ml

somber halo
#

how to set the height of the headings' row in treeview tkinter????????

eager beacon
#

I'm pretty sure its tied to the row height

somber halo
#

doesn't that change the height of all rows??

eager beacon
#

yes it would

#

im saying I don't think you could change it independently

#

but I don't know loads about tkinter and the first couple of links on google led me to believe that it is tied to all of the rows height

somber halo
#

sad maan..i really needed to reduce the table width in total to adjust a chart beside it

#

i mean i need to wrap the heading texts

#

can any suggest any alternative?

eager beacon
#

use pyqt

#

like I said, i dont know enough about tkinter to give much advice.

#

did you set a breakpoint anywhere?

#

so no

digital rose
#

no haha

eager beacon
#

click in the gutter

#

next to the line numbers

digital rose
#

Code works fine on VSC debugger

eager beacon
digital rose
#

yes

eager beacon
#

now you can debug

digital rose
#

Ah, I should put a red dot next to the lines i want to debug?

eager beacon
#

it will stop on the lines you add breakpoints to

#

correct

digital rose
#

Nicee ty

somber halo
#

is there any way to add xscroll to only treeview and y scroll to both tree view and the cahrt beside it?????

oak portal
#

My Tk window appears without the top bar GWchadThonkery

#
from tkinter import *

main = Tk(className=' Blackjack ')
main.geometry('500x500+50+50')
main_frame = Frame(bg='#303030')
main_frame.pack(expand=1, fill='both')  
main.iconphoto(True, PhotoImage(file="ace_of_spades_t.png"))
main.mainloop()
#

For me, it appears without the top bar

#

Is there some reason why?

#

Because it did appear yesterday

#

Literally void GWchadThonkery

#

Oh, even IDLE appears without it

somber halo
#

Because it did appear yesterday
@oak portal sure u dint make any changes?

oak portal
#

Nope, but after testing it on another pc, the titlebar appears, so it's a local issue

leaden tiger
#

hello, is it possible to assign an object to a button in tkinter and if yes how?

amber roost
#

wdym by assign an object?

leaden tiger
#

variable = object

amber roost
#

yeah i don't get it

#

What do you want the button to do?

leaden tiger
#

i have buttons which loads card images ... and i want after playing out the cards to be compared by its class values

#

i get this error: AttributeError: 'Button' object has no attribute 'colour'

amber roost
leaden tiger
#

yes that is true
i want to create a button and assign a card object with its values from a class and access it afterwards

#

if it helps i can paste code and picture?

amber roost
#

since the buttons are just basic classes, you may be able to add attributes to them

#

cleaner way would be though to subclass buttons and add an additional arg in __init__

leaden tiger
#

do you mean super() the button class and set variables in the init ?

#

inheritance?

amber roost
#

yup

leaden tiger
#
    global playerTwoCard1
    newcard = stack.pop()
    img = Image.open(newcard.bgpath)
    img_resize = img.resize((150,300),Image.ANTIALIAS)
    newimage = ImageTk.PhotoImage(img_resize)
    playerTwoCard1 = MyOwnButton(root,image=newimage,newcard.colour,newcard.value)
    playerTwoCard1.image = newimage
    playerTwoCard1.grid(row=0,column=1)
class MyOwnButton(tkinter.Button):
    def __init__(self,colour,value):
        super()._init__(self,colour,value)
        self.colour = colour
        self.value = value
amber roost
#

The Button still needs to get its other arguments, so you'll need to pass those through using

def __init__(self, colour, value, *args, **kwargs):
    super().__init__(self, *args, **kwargs)
leaden tiger
#
class MyOwnButton(tkinter.Button):
    def __init__(self,colour,value, *args, **kwargs):
        super()._init__(self,*args,**kwargs)
        self.colour = colour
        self.value = value

like this?

#

i get the error: ImportError: cannot import name 'args' from 'code' (/usr/lib64/python3.8/code.py)

#

ok thats possibly because the ide added from code import args ... without it there is no error, but i got a different one:
playerTwoCard1 = MyOwnButton(root,image=newimage,newcard.colour,newcard.value)
^
SyntaxError: positional argument follows keyword argument

#

and

#

AttributeError: module 'tkinter' has no attribute 'MyOwnButton'

amber roost
#

you will need to supply the button with color and value first, or do some ugly keyword manipulation otherwise

#

and since MyOwnButton is not part of the tkinter namespace, you can't prefix it with tkinter. as well

#

it is possible that the wrapper class for Button however overrides the __getattr__ method, in which case this will fail

#

Just checked, they don't

unique forge
#

Hi

#

does anyone know how to store the text of a QLineEdit widget in a variable in QT5

leaden tiger
#

@amber roost ok, i dont understand what i have to do now 🙂

unique forge
#

also does anyone know how to print back text in another QLineEdit widget

eager beacon
#

@unique forge

#

what do you mean print back text

unique forge
#

like it will print text inside a LineEdit widget

#

another LineEdit widget

eager beacon
#

to store text you just say x = self.lineEdit.text()

unique forge
#

ok

eager beacon
#

are you referring to setText('some text')?

#

otherwise I have no idea what you mean

unique forge
#

I think so

#

yes

#

setText

#

Here is my GUI in one LineEdit widget I input the number. And in the second LineEdit it will print the squared number

eager beacon
#

okay that makes sense

#

do you understand how to do it now?

unique forge
#

can you tell me how to use setText

eager beacon
#

you just pass a string into setText

#

self.lineEdit.setText('The Text')

unique forge
#

ok thanks

#

and I replace lineEdit with the name of my widget

eager beacon
#

yes

unique forge
#

when I run it just ends the code

#

---------- FINISHED ----------
exit code: -1073740791 status: 1

leaden tiger
#

@amber roost
do you mean like this

 
    global playerTwoCard1
    newcard = stack.pop()
    img = Image.open(newcard.bgpath)
    img_resize = img.resize((150,300),Image.ANTIALIAS)
    newimage = ImageTk.PhotoImage(img_resize)
    playerTwoCard1 = MyOwnButton(newcard.colour,newcard.value, root,image=newimage)
    playerTwoCard1.image = newimage
    playerTwoCard1.grid(row=0,column=1)

and class

class MyOwnButton(tkinter.Button):
    def __init__(self,colour,value, *args, **kwargs):
        super()._init__(self, colour, value, *args, **kwargs)
        self.colour = colour
        self.value = value
eager beacon
#

post the code famous

unique forge
#

all of it

eager beacon
#

everything you've changed since it stopped working

unique forge
#
def showsqr(self):
        sqr = self.lineEdit.text()
        self.lineEdit_2.setText(sqr)
#

also

#
self.ui.pushButton_10.clicked.connect(self.showsqr)
eager beacon
#

do you mean to call self.ui.lineEdit?

#

because you are doing that with the button

unique forge
#

it works now!

#

silly mistake

eager beacon
#

what was it?

unique forge
#

the missing .ui

eager beacon
#

ah

amber roost
#

@leaden tiger sorry, i was gone there, but yeah, this should work apart from the misspell of __init__/_init__

leaden tiger
#

i still get
AttributeError: module 'tkinter' has no attribute 'MyOwnButton'

amber roost
#

also i don't know if that .image thing is going to work out

#

Then you have tkinter.MyOwnButton somewhere in your code

#

either that or i forgot how super works

#

well turns out i did

#

You don't need self in the __init__ from super()

digital rose
#

Can someone explain me what is parent in tkinter

leaden tiger
#

idk where to write "tkinter.MyOwnButton"

amber roost
#

nowhere

#

because MyOwnButton is a class you defined on your own

leaden tiger
#

idk how to solve the error then 😦

amber roost
#

post the full traceback, including the line where the error comes from

unique forge
#

@eager beacon can I tell self.ui.lineEdit_2.setText(sqr) that the input is an integer/int I want the input of lineEdit to be squared and then printed in lineEdit_2

leaden tiger
#

@amber roost found the error 🙂 ... just a second ... i try out if the values are given to the function

#

Traceback (most recent call last):
File "/usr/lib64/python3.8/tkinter/init.py", line 1883, in call
return self.func(*args)
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 186, in playervscomputer
img = Image.open(newcard.bgpath)
AttributeError: type object 'Image' has no attribute 'open'

eager beacon
#

No, Famous anything in a lineEdit needs to be a string

unique forge
#

oh

eager beacon
#

just square the number before setting the text

unique forge
#

ok

#

so like

eager beacon
#

convert from the first lineEdit to an int

#

then square

unique forge
#
sqrd = sqr * sqr
eager beacon
#

then turn it back to a string

#

then set the text

unique forge
#

and then

#
self.ui.lineEdit_2.setText(sqrd)
eager beacon
#

no

#

like

digital rose
#

Oh nvm guys i figured it out

eager beacon
#
s1 = int(le1.text())
squared = s1*s1
s2 = str(squared)
le2.setText(s2)
unique forge
#

thank you so much

#

it works

eager beacon
#

yep

#

just remember that any values you can see on the screen aside from sliders and spinboxes are going to require text values when setting their data

unique forge
#

ok

leaden tiger
#

@amber roost i did not have that error msg earlier, something is wrong and i dont know what

#

@amber roost i found the error ... its the import tkinter in the class file

#

@amber roost i solved all errors and get this one
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.8/tkinter/init.py", line 1883, in call
return self.func(*args)
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 189, in playervscomputer
playerTwoCard1 = MyOwnButton(newcard.colour,newcard.value,root,image=newimage)
File "/media/linux_d/Python/SchnapsenGUI/Classes.py", line 46, in init
super().init_(colour, value, *args, **kwargs)
AttributeError: 'super' object has no attribute 'init_'

amber roost
#

you have misspelled __init__

leaden tiger
#

oh

#

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.8/tkinter/init.py", line 1883, in call
return self.func(*args)
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 189, in playervscomputer
playerTwoCard1 = MyOwnButton(newcard.colour,newcard.value,root,image=newimage)
File "/media/linux_d/Python/SchnapsenGUI/Classes.py", line 46, in init
super().init(colour, value, *args, **kwargs)
TypeError: init() takes from 1 to 3 positional arguments but 4 were given

amber roost
#

you are supplying the original tkinter button with colour and value as well

#

it needs a parent widget however

leaden tiger
#

isnt "parent" super() ?

amber roost
#

no, i'm talking about the parent widget

leaden tiger
#

is
tkinter.Button.init(colour, value, *args, **kwargs)
or
super().init(colour, value, *args, **kwargs)
correct?

#

because tkinter.Button.init
makes a different error message

amber roost
#

either tkinter.Button.__init__(self, ...) or super().__init__(...)

#

but the Button doesn't need colour or value

#

just a parent widget

leaden tiger
#

i dont understand what you mean

amber roost
#

and the configuration args

#
class ImageButton(tk.Button):
    def __init__(self, parent, color, value, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.color = ...


leaden tiger
#

ahhh, ok

#

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.8/tkinter/init.py", line 1883, in call
return self.func(*args)
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 189, in playervscomputer
playerTwoCard1 = MyOwnButton(newcard.colour,newcard.value,root,image=newimage)
File "/media/linux_d/Python/SchnapsenGUI/Classes.py", line 46, in init
super().init(parent, *args, **kwargs)
File "/usr/lib64/python3.8/tkinter/init.py", line 2645, in init
Widget.init(self, master, 'button', cnf, kw)
File "/usr/lib64/python3.8/tkinter/init.py", line 2561, in init
BaseWidget._setup(self, master, cnf)
File "/usr/lib64/python3.8/tkinter/init.py", line 2530, in _setup
self.tk = master.tk
AttributeError: 'str' object has no attribute 'tk'

amber roost
#

newcard.colour,newcard.value,root,image=newimage

#

your order is wrong

leaden tiger
#

how should the order be?

#

because its colour and then value

amber roost
#

yeah and with that __init__ you'll set parent to newcard.colour and color to newcard.value

leaden tiger
#

playerTwoCard1 = MyOwnButton(newcard.value,newcard.colour,root,image=newimage)
this order?

amber roost
#

now parent is newcard.value and color is newcard.colour

left tulip
#

Is there a way to look at a process's progress? Like if you have a flask app and a script that is a for loop that adds things to a list, can you see what the list looks like through the flask app? While the script is still running?

leaden tiger
#

@amber roost sorry, i dont know which order

#

should i put colour and value at the end of **kwargs and put the order around?

amber roost
#

root, color, value; literally match them up with the order of the constructor arguments

#

kwargs always have to be at the end

leaden tiger
#

@amber roost it worked, you are amazing 🙂

#

i go through the rest of the code now

eager beacon
#

what are you using @digital rose

digital rose
#

ttk

#

tkinter

#

@eager beacon

#

it might be a problem with ttk

#

because normal tkinter works

eager beacon
#

oh

#

i have no idea then

#

sorry

unique forge
#

@eager beacon How do I add a favicon into the corner of my app with QT5

proven basinBOT
#

Hey @unique forge!

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

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

eager beacon
#

app.setWindowIcon(QIcon.fromTheme("Fusion",QIcon(':/Path/To/Image.png')))

unique forge
#

thanks

#

let me try

eager beacon
#

you can just use the icon if you don't want the fusion theme

leaden tiger
#

@amber roost i added another 2 variables to that MyOwnButton Class, because i need to change background image with foreground image as well
it looks like this now:

class MyOwnButton(tkinter.Button):
    def __init__(self,parent,colour,value,fgpath,bgpath,*args,**kwargs):
        super().__init__(parent, *args, **kwargs)
        self.colour = colour
        self.value = value
        self.fgpath = fgpath
        self.bgpath = bgpath
playerTwoCard1 = MyOwnButton(root,newcard.colour,newcard.value,newcard.fgpath,newcard.bgpath,image=newimage)
amber roost
#

yeah, seems good

leaden tiger
#

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.8/tkinter/init.py", line 1883, in call
return self.func(*args)
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 250, in <lambda>
playerOneCard1 = MyOwnButton(root,newcard.colour,newcard.value,newcard.fgpath,newcard.bgpath,image=newimage,command = lambda: player1click(1))
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 52, in player1click
removeCardsAndCreateStacks()
File "/media/linux_d/Python/SchnapsenGUI/Main.py", line 113, in removeCardsAndCreateStacks
player1Stack = MyOwnButton(root,image=newimage)
TypeError: init() missing 4 required positional arguments: 'colour', 'value', 'fgpath', and 'bgpath'

#

the cards are all displayed

#

i did not change the values in a function, sorry for that error msg

#

yep

#

perfect

#

it works

#

thank you very much for your help!!!

unique forge
#

NameError: name 'QIcon' is not defined
@eager beacon I get this when I run

eager beacon
#

import it

unique forge
#

ok

quick parcel
#

Does anyone know of a module that will render a simple webpage on a Tkinter canvas?

unique forge
#

ImportError: cannot import name 'QIcon' @eager beacon

eager beacon
#

bro

#

from PyQt5.QtGui import QIcon

unique forge
#

thanks

#

it worked

#

im not very good at this yet

eager beacon
#

yeah it takes a bit of time to start remembering where everything is imported from

trail venture
#

is there a way to create screen overlays using pyqt5? something equivalent to screendc from wxpython

eager beacon
#

can you post a screenshot of what you're talking about

trail venture
#

I can't really describe it with a screenshot

eager beacon
#

okay

#

use your words

trail venture
#

I just want to be able to display an icon in the corner of my screen, over other applications

eager beacon
#

all of the time?

trail venture
#

not necessarily, it should be an indicator that the program is recording audio from a specific audio device (and then the audio file is saved)

eager beacon
#

well you could use a QWidget and set the windowFlag Qt.FramelessWindowHint and move it with move(x,y) to the bottom corner of your screen then set it to show when you press record and hide when recording stops

#

Frameless window hint is a window without the minimize/close controls

trail venture
#

is it always focused?

eager beacon
#

you can also set it to always stay on top

#

it can lose focus when you click into another window but will remain on top

trail venture
#

does it consume input events and/or mouse clicks?

#

because I'd prefer it to be transparent and still let you click on things underneath it

eager beacon
#

its a QWidget, you can implement an event filter and make it do whatever you like

#

uhh

#

hmm

#

maybe QWidget.setAttribut(Qt.WA_TransparentForMouseEvents)

#

but I don't know for sure. I've never tried

#

i think you may need to set the palette to transparent as well and implement a paint event

#

I can check when I get home

trail venture
#

do you reckon it's better to go with wx instead then?

eager beacon
#

I've never used it before. Personally I'd stick with pyqt but if you know wx has all of the tools you need to build your app and you're familiar with it already then go for it

#

Are you going to be handling the audio through the app or does this app just detect recording and display the indicator?

trail venture
#

I've never used it before. Personally I'd stick with pyqt but if you know wx has all of the tools you need to build your app and you're familiar with it already then go for it
@eager beacon well, I'm not, this is my first project and idk what the options are (only done some quick googling)

unique forge
#

I prefer QT

#

also my first project

#

but QT Designer helped A LOT

trail venture
#

Are you going to be handling the audio through the app or does this app just detect recording and display the indicator?
@eager beacon it'll be linked to a keyboard hotkey that starts and stops the recording

eager beacon
#

Well if it's just the indicator you might as well go with wx if the widget you need is included

unique forge
#

I was doing the function for finding Side A, but when I put in the numbers, the code ends

#
def funca(self):
        b1 = float(self.ui.lineEdit_22.text())
        c2 = float(self.ui.lineEdit_23.text())
        math_a = math.sqrt((c2 * c2) - (b1 * b1))
        sida = str(math_a)
        self.ui.lineEdit_24.setText(sida)
#

@eager beacon

eager beacon
#

whats the value of math_a before you put it in the lineEdit?

unique forge
#

math_a?

eager beacon
#

yes, your variable in the function you're asking about

unique forge
#

math_a is just the equation

#

it has no value until both numbers are put in

eager beacon
#

well, thats when the problem happens

unique forge
#

oh

eager beacon
#

so whats the value of math_a when you put the numbers in

unique forge
#

9

#

I used this triangle for an example

#

I put in 15 and 12

eager beacon
#

there isn't anything in there that should cause a crash unless one of those lineEdits does not exist in the UI file

unique forge
#

hmm

#

let me check

eager beacon
#

is that the only function that runs?

#

i suppose the the function could be misspelled in the connect method also

unique forge
#

there is multiple functions

eager beacon
#

right, but is that the only one that runs after you've entered the numbers?

unique forge
#

yes

eager beacon
#

okay

#

well make sure the line edits exist

unique forge
#

I have double checked

#

they do

#

here is what calls the function

#
self.ui.pushButton_21.clicked.connect(self.funca)
#

and I double checked

#

it is indeed pushButton_21

eager beacon
#

okay well i need to see the rest of the code if i'm going to be any help

unique forge
#

Ill send the files

proven basinBOT
eager beacon
#

cant send python files through here

#

paste them at the link

unique forge
eager beacon
#

okay

#

how do i recreate the error?

unique forge
#

?

#

idk

#

does it work for you

eager beacon
#

bro

#

what button

#

I need reproduction steps

unique forge
#

pushButton_21

#

?

eager beacon
#

fine don't tell me the text I'll look myself

#

so 15 and 12 dont work with finda

#

but 24 and 36 do

#

you can investigate why thats happening, the gui is fine

#

yet 12 and 15 do work