#user-interfaces

1 messages · Page 59 of 1

digital rose
#

thx

#

this is question i was asking it here take a look on it :

delicate tendon
#

but how would I do it for labels and lines

#

?

digital rose
#

the same

#

use .place method

#

then

#

from it

#

call rely=1

#

example: add_btn.place(x=8, rely=1, y=-40) # 40px from the bottom

#

the same this labels and another widgets \👍

delicate tendon
#

where is a good place to make a game manual?

digital rose
sharp remnant
#

hey i was wondering what the best way to get a slider and entry box to both show the same value is

#

so they update live instead of having to press a button to update them

eager beacon
#

@digital rose try setting min-height/width also

outer sand
#

oops

#

So I have some basic Tkinter Code, that displays this here and in that red box there basically I want to display a Chessboard with the pieces overlaying on the Chessboard but however you can click on the pieces that will then show the available moves and i was wondering what would be the best way to display these images without making 64 different variables?

hollow shore
#

hi, can someone help me?

zealous abyss
#

can I get some help with displaying unicode on a curses window? when I try it I get ~V~H instead of the character

rare agate
#

Does anyone know if there is any library that might override, for example, html keyboard shortcuts in a textarea on a webpage and make them behave closer to a python IDE? What this may be called, or perhaps where to find the JS behind something like vscode's python text editing keyboard shortcuts?

#

or jupyter notebook

rare agate
#

I believe codemirror may be an option, for anyone who has this same question

eager beacon
#

@zealous abyss what was the unicode?

zealous abyss
eager beacon
#

hm

#

can you post your code?

#

and have you tried using 32 bit instead?

#

like '\U00002588'

digital rose
tidal loom
#

What would be the best framwork for me if I like to build a cli application that shows streaming data from an API?

eager beacon
#

@tidal loom why don't you just use something like click

#

you don't need a gui for cli

tidal loom
#

@eager beacon I have never had any need to do this before but is click the recommended framework for cli apps? What's the difference between it and ex Rich?

eager beacon
#

I've never used Rich but it looks like Rich doesn't do much other than make it look pretty where as click makes it easier to write the application

tidal loom
#

I think you are right!

#

And I need to find a way to appdste the data

rare narwhal
#

I have an issue with Kivy

#

It is leaving the application as my program tries to scrap data from python

upbeat bison
#

hello

#

what is the command key of a function I can use in python Tkinter to refresh my GUI and allow the user to input another data and run it again,

For example,

I have implemented a Navigation system that find the shortest part, in my GUI, a user can input start and also input End, But i'm stuck at the implementation of refreshing the page and let the user enter new data and run it without running the programme its self.

alpine ember
#

Hey, I need to center two labels in a grid in the same row

#

Any ideas how?

#

Also my frame won’t stay within the confines of my window, even if I make my window stupidly big

sturdy pelican
alpine ember
#

Are you packing the frame into root?

deep granite
#

Hi

sturdy pelican
digital rose
digital rose
#

?

digital rose
vale orchid
#

Hi all. I'm working with Tkinter to develop this simple GUI. I'm having a small issue that I need your help for.

In short, I need to open a second frame when a certain condition is fulfilled. It's a GUI for login, so I have defined the Login function separately and it outputs a messagebox confirming the login. I am unable to redirect the user to the second frame however. I have tried using if statements in the Class part of the code and a 'check' variable with 0, 1 to get the login state, but to no avail. Any help on this would be much appreciated

#

I'm not sure if what I said makes enough sense, I am a beginner to Python and this is my first program with Tkinter. So, perhaps I could share my code or get on a VC channel to seek help?

hollow shore
#

hi, can someone help me pls?

digital rose
#

Hi all guys

hollow shore
#

can you help me pls?

digital rose
digital rose
#

sec & I will be back

hollow shore
#

it is difficult to explain, can I send you a "scheme" of how I want to do the ui?

vale orchid
vale orchid
#

Each frame has all the required widgets and it's function definitions cut out for it

#

But my only hiccup lies in the issue that anyone regardless of logging in correctly or incorrectly can proceed to all 3 frames

#

I'd like only users who have been 'verified' with my login function to be able to proceed to the next 2 frames

hollow shore
#

how can I put section 4 below 3 but at the same time to the right of 2? (with kivy)

digital rose
#

so I'm not good at kivy sorry

hollow shore
#

oh, oke

digital rose
#

are you mean

#

all the users can see the frames

#

but you want to only the verified user ?

vale orchid
#

Yes. Correct

#

The verification is done by a user defined function called 'login' that is implemented when you press submit

digital rose
#

ah nice

#

so

#

you want to make func

#

called load_frames

vale orchid
#

I'm not sure, but I think I want to do a show_frame in a function that's outside the class MainWindow

digital rose
#

yeah

#

any name

#

and pack or gride or place the frames

#

and when

#

it's verified

#

call the func

vale orchid
#

Yes. pack() is what I'm using

#

Yes!

digital rose
#

yes

#

so pack the frames into the func show_frame

vale orchid
#

I've tried to do this for a similar problem I saw on stack overflow, but it didn't work

digital rose
#

sec

#

can you give the link

vale orchid
digital rose
#

i was telling you another thing

vale orchid
#

Yes, go on

digital rose
#

so yeah

#

I was telling another solution

#
from tkinter import *
root = Tk()
frm1 = Frame()
frm2 = Frame()
frm3 = Frame()
def load_frames():
    frm1.pack(side=LEFT)
    frm2.pack(side=BOTTOM)
    frm3.pack(side=RIGHT)

submit_btn = Button(master=root,text="submit",command=load_frames).pack()

root.mainloop()
#

run this out

alpine ember
#

Guys, how do I position two labels in the same grid row center to the frame

#

Also, my frame isn’t confined within the window? Is there a fix for this, it’s too big

vale orchid
#

Okay, I'm still processing the code in my head

#

?

digital rose
#

why you use grid system? @alpine ember

digital rose
alpine ember
#

Cause apparently it’s nicest to use

#

Just laying out buttons n stuff

digital rose
digital rose
#

so I not good at grid sorry

vale orchid
#

Okay, I've run it and I think I understand what you mean. But can you elaborate how this is a fix? I'm still slightly confused

digital rose
#

ah hmm

#

this is defined the frames

#

then

#

pack it when you call the func

vale orchid
#

So, this will clearly be outside the Class right?

#

I want to make sure I understand this correctly

vale orchid
#

Also, is there any way I can just send my current code to you and you can maybe make more sense of it?

digital rose
#

yes

vale orchid
#

In a help channel or a DM? I assume the former?

#

Oh right

#

1 sec, uploading

#

Yup, done

#

So, if you can see here in the class LoginPage

#

I want button1 to be displayed/go to Criteria frame when loginSuccess is True in the login() function

vale orchid
#

@digital rose Are you busy now? Should I message at you at another time perhaps?

alpine ember
#

what's the best method to use for organising widgets

digital rose
#

Is there a function command for tkinter that closes all canvas?

alpine ember
#

What's the best layout/geometry manager? pack, grid or place?

unique forge
#

Depends

#

What are you trying to do

#

@alpine ember

alpine ember
#

I'm trying to make a GUI for running scripts I have

unique forge
#

Of course

alpine ember
#

I have it working and have been using grid

#

But I have widgets like a 'progress bar'

unique forge
#

It really depends on how you want it to be

alpine ember
#

And then I want a label representing the % of that progress bar

#

I don't need the label of % to take up as much space as the progress bar

unique forge
#

Just make it smaller

alpine ember
#

Also there's a big issue I'm having atm

#

Wdym - I have no size set for the label

#

The frame within my window is too big for the window size

#

Yet I'm not setting a frame size anywhere

#

I use the external padding for the pack method I use

#

but the elements inside squish and don't correctly format

unique forge
#

Try all of them out

#

Im not the best at Tkinter

#

Only made a simple calculator, for which I used grid

digital rose
#

because

#

place you can with it place it on spefic place and you can make with it Fixed position plus1 ok_handbutflipped

alpine ember
#

yeah but it doesn't adapt to window resizing

digital rose
#

no he is can

#

with

#

rely and relx

#

take a look at

alpine ember
#

Well I'm using the grid layout system

#

And I have the small issue of the frame not being within the window

#

This is so strange

digital rose
#

sorry im not good at grid

alpine ember
#

Something I've written. Could be helpful, could be utter bollocks - if you think I could add anything, do say

vale orchid
#

Hi, so is any GUI expert around here?

digital rose
#

I have something i would like to make but have no idea how to make,
very simple but to me i cant do it, and if i can get it made all right now
that would mean the world to me, i want to make a A/R transaction GUI with tkinter
i want it to have the following in excel or python file

  1. Customer Number
  2. Customer Name
  3. Invoice Number
  4. Invoice Date
  5. Invoice Amount
vale orchid
digital rose
#

didn't say that at all

#

but that would be a cool trick if i could

vale orchid
#

Also, this GUI seems fairly simple and wouldn't take more than a few hours of learning and a day or two of implementing using only Google and forums

digital rose
#

its more i need help with logic then learning how to do it, what steps to take and what not

#

i can code

proven basinBOT
#

Hey @vale orchid!

It looks like you tried to attach file type(s) that we do not allow (.pdf). 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, .csv.

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

digital rose
#

oop

vale orchid
#

Here's a rather rudimentary guide

digital rose
#

thanks

#

what does invoice mean

vale orchid
#

Cheers man. I'm a beginner too, and I think it would be smarter to ask questions about GUI you don't understand rather than ask someone to teach you from scratch when there are multiple resources out there already

digital rose
#

i kinda need it tonight so i was more hoping for someone who could guide me alittle

#

but no one in any server seems to either know how or something

tawdry idol
digital rose
#

@tawdry idol i have a help ocupied if u dont mind checking out that questio

ebon musk
#

entry. get() doesnt return any string. What might be the error?

vale orchid
#

I need help in updating the GUI that's built in classes with 3 frames. It needs to refresh itself/ update when any variable in a separate function is updated

alpine ember
#

@vale orchid

#

I can help

vale orchid
#

Oh thank you. What can I do for you @alpine ember

alpine ember
#

What are you stuck on

remote ravine
#

anyone knows how to impliment removeRow in QABstractTableModel to be used in QTableView ? PySide2 or pyqt5

vale orchid
#

@alpine ember When would you be free so that I can seek your help?

rough fulcrum
#

anyone knows how to impliment removeRow in QABstractTableModel to be used in QTableView ? PySide2 or pyqt5
@remote ravine

I don't know about qtableview, but I have worked with qtablewidget and it follows the corresponding syntax

qtablewidget_variable.removeRow(index of row you want to remove)```
remote ravine
#

it somehwat works now

#

but its not the same. currently it removes the last row

rough fulcrum
#

it somehwat works now
@remote ravine
Could you provide more clarity on what you want to delete?

remote ravine
#

i need to delete a single row in QTableView that is using QAbstractTableModel

rough fulcrum
#

Which row? The one user clicks on?

remote ravine
#

yes

#

when i click a button

rough fulcrum
#

So in order to get the index of that currently clicked row, you will need to use '.currentIndex().row()' on qtablewidget

rough fulcrum
#

Then input that value in removeRow() function

remote ravine
#

i did ?

hollow shore
#

hello, can someone help me with kivy pls?

remote ravine
#

brb

#

@hollow shore ask the question

hollow shore
#

oke...

#

it is difficult to explain, can I send you a "scheme" of how I want to do the ui?

remote ravine
#

@hollow shore try qt designer

#

its for Qt bit i think its very usefull. no matter the framework you use

hollow shore
#

oke thx 🙂

rough fulcrum
#

Could you describe how to delete row in your code?

#

Like what triggers row deletion?

#

@remote ravine

remote ravine
#

clicked signal (when the button is clicked) is connected to remRow.

#

remRow gets current model index, after that it calls self.model()...

#

self.model() == TableModel

#

so..

#

self.model().removeRow(model_index.row(), QtCore.QModelIndex()) calls removeRow in TableModel

#

also did u check comments in the reddit post ?

#

wrong link

#

it this one it removes the last row

#

if i pass currentIndex() to TableModel().removeRow() it doesn't remove any row

lunar kelp
#

Does anyone know tkinter really well in here? I got a question i just cant solve.

remote ravine
lunar kelp
#

Well then. How do i completely reset a canvas? Cause everything ive tried isnt working. Just trying to keep images centered. But after zooming the images it takes a couple refreshes before it gets back to center again. Dont understand it at all.

median willow
#

hey can someone help in displaying a png file (tkinter) inside a defined function

lunar kelp
rough fulcrum
lunar kelp
#

Sure, one sec. Ill drop my class.

lunar kelp
#

Theres actually 4 extra lines of code in there, was trying to flash reset it by filling the canvas before displaying the correct size

median willow
#

its not working

lunar kelp
median willow
#

let me try again

lunar kelp
#

That link i pasted deals with a way more in depth version of that tiny bit of code

rough fulcrum
# remote ravine if i pass ``currentIndex()`` to ``TableModel().removeRow()`` it doesn't remove ...

Hey, I think the issue lies with qtableview since it controls the model. So when you delete a row, it automatically recalibrates other rows to fit the dataframe. In fact, when you delete the 1st row, the first row is definitely deleted. But now the labels of the 2nd row change to the labels of the first row. So it gives the effect that the last row is deleted instead of the row which was supposed to be deleted

remote ravine
#

it doesn't give the effect because i have values set in each row

median willow
#

its not working even after giving correct path

lunar kelp
#

Maybe its because its not set to a class or global variable and is cleaned from the cache. Set it to self.render or global render

median willow
lunar kelp
#
bg_image = Image.open("password.png") photo=ImageTk.PhotoImage(bg_image) 
bg=Label(root, image=photo)
bg.pack(padx=30, pady=30)
``` @median willow copy exactly that
#

Hold on

#

There copy that

#

Typing on a phone is incredibly difficult

median willow
#

errors

rough fulcrum
lunar kelp
#

Can't without recalling the class. Other could possibly pack_forget, re pack it see if that fixes it. And im not sure what you mean by that last statement

rough fulcrum
#

What do I you call in order to run your application or to make the gui appear?

lunar kelp
#

I call ID = ImageDisplay(widget instance, width of widget, height of widget) then when i display image its ID.open_image(filepath) can link it to a canvas or a label.

rough fulcrum
#

Sorry it's been sometime since I used tkinter, could you say which widget instance should be fed to it?

lunar kelp
#

Ya. So canvas = tk.Canvas(). You pass the variable holding the canvas

#

So itd be ImageDisplay(canvas, canvas.winfo_width(), canvas.winfo_height())

#

Which i suppse could actually be simpler now that i think about it

#

You gonna be on in about 30 minutes? Ill go to an internet cafe and upload my whole program to github. Might make it easier.

rough fulcrum
#

wait up

rough fulcrum
lunar kelp
#

Ok, youll need pillow and send2trash modules if you dont have them

rough fulcrum
#

I have pillow, will need to install other

lunar kelp
remote ravine
#

@rough fulcrum hey

#

i made an "advancment"

rough fulcrum
remote ravine
#

fuck nvm

#

got it

#

1: i fixed a problem with my code when deleting an index from pandas DataFrame

#

2: its a problem with parent

rough fulcrum
#

Does it delete properly now?

remote ravine
#

not really

#

it deletes the last row

#

...

#

idk why

#

this is right ?

#
self.model().removeRow(self.curr_index_model.row(), self.curr_index_model.parent())
#
def removeRow(self, row, parent):
    self.beginRemoveRows(parent, row, row)
    self.data_frame.index.drop(row)
    self.endRemoveRows()
#

0, 0 replace with row, row

#

it has to be a problem with parent since it has index -1, -1 so basically last row

#

hmmm. let me test something

rough fulcrum
#

I will check it out and let you know

remote ravine
#

i am gonna create an index

#

because it doesn't give a shit if i pass the parent of QModelIndex or QModelIndex()

#

it doesn't delete anything...

lunar kelp
#

alright @rough fulcrum im headed home. im exhausted. but you have the full program now, so ill check back

rough fulcrum
#

Definitely

remote ravine
#

i still don't fully understand what parent is

rough fulcrum
#

parent is the widget which you are inheriting from

remote ravine
#

u sure thats the same for models ?

#

if its the same it makes much more sense

#

but still doesnt explain the issue

rough fulcrum
#

I guess it is the same. Because everything inherits from something. Every derived class inherits from the parent(base class).

#

I don't think that the solution to your issue should be much complex

#

There could be case that the widget might not have a parent at all

remote ravine
#

i am so sonfused rn

#

what would be a parent be of a QModelIndex be ?

#

a row or a column ?

rough fulcrum
#

None of that actually. Lets take an example, you used QtableView to derive TableView class. So the parent of TableView class is QTableView

#

So I think QModelIndex doesn't have a parent

remote ravine
#

still doesn't explain why it would delete the last row

rigid ledge
#

hi

remote ravine
#

hi

unique forge
#

Hi

lunar kelp
#

@rough fulcrum you should also note, that program can be placed anywhere. You can navigate to your image directory inside the program. Its starting point though is os.getcwd()

#

And yes, i hand drew all the little icons. Thats how bored i get lol

rough fulcrum
#

Yes thanks @lunar kelp the program seems really big. Seems like you are developing some software

#

If you have Paint 3d on your setup, you could design the icons on it

rough fulcrum
lunar kelp
#

Lmao it is software. Just as functional if not more useful then the built in image viewer on windows. Cause you can navigate all the files on your pc while doing it.

rough fulcrum
# remote ravine still doesn't explain why it would delete the last row

hey if you py print(self.data_frame), you will see that nothing is getting deleted. What I interpret from that is that the program is deleting rows from the GUI, but nothing is getting deleted from the data_frame. Which points out that everytime you click the button, you are deleting a row from the GUI, but since the dataframe is same, it is only showing a shrunken list of numbers

remote ravine
#

let me test again

rough fulcrum
remote ravine
#

ya i just noticed

rough fulcrum
#

Forgot to mention that I was trying in the range of 50 to 100

remote ravine
#

fixed it

#

i can finally delete yo my hearts desire. lmao

#

and pandas is so cool

rough fulcrum
#

What did you do?

#

I need to know man

#

@remote ravine

remote ravine
#

self.data_frame = self.data_frame.drop(self.data_frame.index[row])

#

bruh

#

and my day is ruined. i wasted more than 10 hours on this problem

#

idk if i should laugh of cry

rough fulcrum
#

ah, I tried py self.data_frame = self.data_frame.index.delete(row) and it was returning a blank object

#

🤣

remote ravine
#

lmao

#

at least it works now

#

i am making a gui for liqudictl btw

#

making it display a graph will take less time than making it display some data correctly

rough fulcrum
remote ravine
#

yea ik

#

but know i know why

#

.index returns the "index"

#

.drop() takes that index as an argument

rough fulcrum
remote ravine
#

yea i have a week to spare now

#

we have something called "practice" which has a different meaning in my language. basically u go to "work" to a company for 2 weeks

rough fulcrum
remote ravine
#

well at least i learned something

rough fulcrum
remote ravine
#

training

#

if u dont do it u fail the (class)year/grade

rough fulcrum
#

That's nice. Are you in school?

remote ravine
#

rn ? no

rough fulcrum
#

or graduate school?

remote ravine
#

highschool

#

by EU standards

rough fulcrum
#

USA?

#

oh europe

remote ravine
#

holy shit how many ppl are in vc

rough fulcrum
#

vc?

remote ravine
#

voice-chat

rough fulcrum
#

How many are you hearing?

remote ravine
#

not in

#

neither i want to join

rough fulcrum
#

Lmao

remote ravine
#

its quite quiet

rough fulcrum
#

In which year of highschool are you in?

remote ravine
#

second

rough fulcrum
#

I guess the highschool concept in my country is different from yours

#

what's the structure there?

remote ravine
#

lets go to dm

rough fulcrum
#

ah yeah

remote ravine
#

i dont want to spam this channel when ppl need help

rough fulcrum
#

you are right

digital rose
#

hI

#

Guys my big problem it's who to delete background of a widget 😩

#

I know I can't do it but is there anyway right left ?😭

rough fulcrum
#

delete background or change it?

#

@digital rose

rough fulcrum
digital rose
#

already did a big chunk of it

#

almost done actually, i just have a dumb syntax error

#

i would use help channels to get it fixed but no one answers mine

rough fulcrum
#

If it is user interface related, you could ask here

digital rose
#
  c.execute('INSERT INTO transactions VALUES (:Customer_Numb, Customer_N, Invoice_Numb, Invoice_D,Invoice_Am)',
        {
            'Customer_Numb': Customer_Numb.get(),
            'Customer_N': Customer_N.get(),
            'Invoice_Numb': Invoice_Numb.get(),
            'Invoice_D': Invoice_D.get(),
            'Invoice_Am': Invoice_Am.get()
        }

    #commit changes
    base.commit()
  File "class.py", line 43
    base.commit()
    ^
SyntaxError: invalid syntax```
#

idk where the syntax error probably really simple

rough fulcrum
#

Wait, let me dm you if that's okay since this issue is not related to GUI

digital rose
#

oh ok sure and thanks

green wind
#

Hello there friendos

#

I am using tkinter at the moment,

#
Hello = Tk()
Hello.title('Hello!')
Hello.geometry('300x125')
box = Entry(text = 0)
name = Label(text = 'Enter name')
button = Button(text = 'Enter')
box.place(x =75, y =10, width =200, height =20)
name.place(x =10, y =10, width =60, height =20)
button.place(x =75, y =35, width =60, height =20)
Hello.mainloop()```
is it possible to make this look
#

less ugly

unique forge
#

@green wind you might be able to store dimensions in a variable

green wind
#

Oh

#

Good idea

digital rose
#

Is there a way to make 2 windows open for one python script, for example im trying to have a menu on one then it opens up and has logs on the other all in one file

static cove
#

@green wind any specific reason why you're using place as opposed to grid or pack?

green wind
#

The guide I'm using uses place

static cove
#

@digital rose when you say windows, what do you mean? Explorer window? GUI window? Web broswer?

#

@green wind ah, okay. I do recommend you check our grid and pack at some point later

green wind
#

Does that come with tkinter

#

They sound smoother

#

Think you can give me a bit of a rundown on the commands? :) @static cove

static cove
#

So tkinter has 3 different ways you can organize the placement of objects, they're called grid managers:

  1. .place() - you give it an exact x, y, width, and height. It's easy to use but doesn't work if you want to resize or have something dynamically scale.
  2. .place() - This sort of does the work for you and assumes you either want things side by side or above/below. It's simple, but if you're looking for something quick for small projects, it's great
  3. .grid() - You specify a row and a column. You can get a lot of customization out of this since you can specify that an object span multiple rows and columns. It sometimes has odd behavior, but overall it's my favorite of the three.

.grid() + .place() can be used together and so can .pack() and .place(). BUT .grid() and .pack() CANNOT be used together in the same frame/window. You can use different frames to overcome that but that's getting a bit advanced.

green wind
#

Thank you!

#

I think grid would be better for me

#

For my use

trail meteor
#
class NumInput(TextInput):

    def set_layout(self, layout):
        kb = Window.request_keyboard(
            self._keyboard_close, self)
        if kb.widget:
            vkeyboard = self._keyboard.widget
            vkeyboard.layout = 'numeric.json'

    def _keyboard_close(self, *args):
        """ The active keyboard is being closed. """
        if self._keyboard:
            self._keyboard.unbind(on_key_down=self.key_down)
            self._keyboard.unbind(on_key_up=self.key_up)
            self._keyboard = None
#

Hello, I am a newbie in Kivy and trying to make a numerical input field, yet the called keyboard is still the default one, even though I am calling the 'numeric.json' as it is specified in the documentation.

#

Can anybody provide insight as to why? The json file is located in the folder with my main.py file

tawny terrace
#

you guys know a DomainUpDown equivalent in PyQt5?

#

like this, you have a couple of String options to choose from and it drops down like that

#

nvm figured it out its QComboBox

tribal path
#

How/where are you calling set_layout?

trail meteor
#

Oh.

#

OH

#

I am not

#

So theoretically I can now create a method for _on_focus event, that would call set_layout

#

Thx @tribal path

digital rose
#

what is everyone's preferred GUI lib ?

#

im trying to start making GUi apps but dont know which lib to use

whole crest
#

html

#

or tkinter

trail meteor
#

Hmm, thought this would work, but it doesn't, but I can feel Im on the right way

whole crest
#

or pyqt5

trail meteor
#
class NumInput(TextInput):

    def set_layout(self, layout):
        kb = Window.request_keyboard(
            self._keyboard_close, self)
        if kb.widget:
            vkeyboard = self._keyboard.widget
            vkeyboard.layout = layout

    def on_focus(self, instance, value):
        if value:
            vkeyboard = self._keyboard.widget
            partial(self.set_layout, 'numeric.json')
        else:
            pass

    def _keyboard_close(self, *args):
        """ The active keyboard is being closed. """
        if self._keyboard:
            self._keyboard.unbind(on_key_down=self.key_down)
            self._keyboard.unbind(on_key_up=self.key_up)
            self._keyboard = None
whole crest
#

not

digital rose
#

no i think i will use html for python GUI

whole crest
#

it won't work

digital rose
#

is that the right choice?

#

@trail meteor do you think so?

#

?

#

?

trail meteor
#

I am a newbie my friend

digital rose
#

oh ok haha

#

me too lol

trail meteor
#

karim, would you mind providing me info as to where im not assigning the layout right?

digital rose
#

are you using kivy?

trail meteor
#

I feel like thats the issue, that I am clearly missing a point where Im supposed to bind the layout, but I dont know enough to pinpoint it

#

yes

digital rose
#

i dont knwo much about kivy sorry i cant help you 😦

trail meteor
#

google doesnt help with vkeyboard too, theres basically only the official documentation, which is way too much info for me to understand how it works, without seeing a complex example other than "Heres a screen with keyboards"

#

making two types of vkeyboard inputs, one for text values like login and pass, other for numerical purposes + reading serial ports and appending a complex C library and my GUI would be done

#

Im stuck at the keyboard one atm

trail meteor
#

Alright, managed to unscramble some bits and figured out how using partial, wasnt doing anything for me

#

now I can call the numerical keyboard, but the layout remain set globally, so I have to figure out now for optimization'S sake if its easier to create a new textinput class which will call the default keyboard or if its just simpler to reset the layout somehow

#

here's the semi-working code, if anybody is interested

#
class NumInput(TextInput):
    vkeyboard = None
    def __init__(self, **kwargs):
        super(NumInput, self).__init__(**kwargs)

    def set_layout(self, layout):
        kb = Window.request_keyboard(
            self._keyboard_close, self)
        if kb.widget:
            vkeyboard = kb.widget
            vkeyboard.layout = layout

    def on_focus(self, instance, value):
        if value:
            self.set_layout('numeric.json')
        else:
            pass

    def _keyboard_close(self, *args):
        """ The active keyboard is being closed. """
        if self._keyboard:
            self._keyboard.unbind(on_key_down=self.key_down)
            self._keyboard.unbind(on_key_up=self.key_up)
            self._keyboard = None
analog prairie
#

How can I add a date and time input widget in tkinter?

keen path
#

wdym

#

entries ?

#

@analog prairie ?

analog prairie
#

Yup as in the entry

keen path
#

what do u exactly want @analog prairie

#

like can u giv a precise description ?

analog prairie
#

I want the entry field to be a calender pop up from which the user can select a date

keen path
#

oh

analog prairie
#

Similarly for time

keen path
#

i get it

#

u dont need an entry for that

#

u need a

#

lemme remember what its named

analog prairie
#

I tried tkcalender

keen path
#

a

#

its a listbox

#

like this ?

analog prairie
#

Not exactly, like a literal calender and selection

keen path
#

yeah ok

analog prairie
keen path
#

i dont know if there is a widget that looks like that

analog prairie
#

There is but I can't seem to install the pip 😂

#

Any other suggestions?

keen path
#

nop

analog prairie
#

😂👍🏻 no worries mate

keen path
#

can't it just be an entry

#

where user can write the actual day

#

c'mon make it a bit harder for them

#

they're litterally hooked telling devs they want everything that ez

#

for them

analog prairie
#

Nah 😂 it's for a uni assignment

keen path
#

oh

#

ok

#

well idk anything further

#

sorry

analog prairie
#

No worries mate

keen path
#

ok

lunar kelp
#

How clean does that look?

keen path
#

4/10 ngl

#

or 5/10 at the maximum level of judging

digital rose
#

i know there is away to turn windows form app i into tkinter but i cant find out how

#

i did it before using an app, i had visual studios and opened a windows form app, and the gui made in windows form app could be turned into code for tkinter

distant sand
#

hihi

#

can someone suggest a "ui" editor which allows me to upload my html files and edit it like wix??

karmic star
#

PySimpleGUI is cool not gonna lie

#

Would use it over tkinter any day

digital rose
#

Guys, is there any way in tkinter, to make an Entry text box such that a function is run whenever any change is made to the text inside it?

trail meteor
#

Is there anybody who could explain to me why TextInput in Kivy is delaying transitions and changing colors on the following screen? (moving from textinput screen to screen without it)

digital rose
#

ok

keen path
#
# first make a function that takes the components of the entry and puts it in a variable
def function1():
  global var1
  var1 = entry.get()
#now put a mainloop
bool1 = True
while bool1:
  var2 = entry.get()
  if var2 =! var1:
    print ("a change has been made to the entry")
#

this should work

#

but im not sure

digital rose
#

let me try

keen path
#

wait

#

you'll get a syntax error

#

there

#

now the code above should work

digital rose
#

but where do I add the code after or before "root.mainloop()"

keen path
#

before

#

wait send your code

digital rose
#
from tkinter import *


root = Tk()
root.title("Ratio helper!!!") 


D2 = Entry(root)
D2.pack()

root.mainloop()

Example code, not mine

keen path
#

why u cant send yours

digital rose
#

You will get confused, its too messy and too many things are there

keen path
#

ill read it carefully

#

well anyway

#

did the piece of code work

#

@digital rose

digital rose
#

no

#

nothing really happens, no errors

keen path
#

ok

#

and

#

u get the print statement ?

digital rose
#

nothing happens, but text editor gives a warning, "var1 is unbound"

keen path
#

wot

#

wait

#

@digital rose show me the whole error

digital rose
#

see, code is like this:

from tkinter import *


root = Tk()
root.title("Ratio helper!!!") 


D2 = Entry(root)
D2.pack()


# first make a function that takes the components of the entry and puts it in a variable
def function1():
  global var1
  var1 = D2.get()
#now put a mainloop
bool1 = True
while bool1:
    function1()
    var2 = D2.get()
    if var2 != var1:
        print ("a change has been made to the entry")
    function1()

root.mainloop()

Actually, nothing happens, no window shows up, I have to quit it by pressing Ctrl+C

keen path
#

k but

#

k

#

im waiting for it to run

#

does it launches the tkinter window

digital rose
#

no

keen path
#

oh

#

and did it launch before

digital rose
#

yes

keen path
#

i get it

#

i can't put a while loop

digital rose
#

it gets stuck in while true loop

keen path
#

yeah

#

idk

#

idk how to do it

digital rose
#

ok

regal berry
#

I would use recursion as you can use the root.after() method

digital rose
#

Ok, it works

regal berry
alpine ember
#

Guys

#

How would I be able to run functions via tkinter gui and NOT have my damn gui freeze up until function is complete

amber roost
#

But it seems to be starting a thread that then prints instead of interacting with the interface further, I don't think it's that easy getting past threads

alpine ember
#

What's asyncio

amber roost
#

yeah good question, i'd describe it as a python library that allows for the parallel execution of IO-bound tasks

#

What are you doing to cause your UI to freeze?

#

Are you writing to a database or downloading something or is it a long running calculation?

weak trout
#

Hello 👋. Is the Kivy package aimed to mobile app development? Or can I use Kivy to develop a desktop application with all possibilities (for Windows, Mac, Linux)

#

Because most titles I read are "Kivy for mobile development"

unique forge
#

Bith @weak trout

#

Both

#

You can use Kivy for mobile and desktop

weak trout
#

😄 good. Thank you @unique forge

somber zinc
#

hey is there a way to "hide window when not focused" on qt?

meager ravine
#

Hello! Having an error im unsure about with this part of the script im making.

    if pyautogui.locateOnScreen('crate1.png' or 'crate2.png' or 'crate3.png' or 'crate4.png', grayscale=True, confidence=0.6) ==None:    
            pyautogui.keyDown('down')
            time.sleep(np.random.uniform(0.005,0.01))
            pyautogui.keyUp('down')

    #if there's a gift available then sift thru the row
    if pyautogui.locateOnScreen('man.png', grayscale=True, confidence=0.6) !=None: 
        pyautogui.click('crate1.png' or 'crate2.png' or 'crate3.png' or 'crate4.png')   

elder plinth
#

Hello, I am trying to iterate through widgets using a the keys from a dictionary. I have a dictionary with the widget names and I am trying to do a .config() to change the fg and bg color

#

it gives me an error with the following

#

def change_all_colors():
for key, val in set_color.items():
set_color[key] = FastLED_color
key.lower().widget.config(bg=FastLED_color, fg=FastLED_color)
print(key.lower() + ' : ' + FastLED_color)

#

the error is: AttributeError: 'str' object has no attribute 'widget'

meager ravine
#

I have a very basic bot script, however i feel like it's lacking speed. Could someone review it and let me know what i can do to make the process go faster?

Currently it does down 1 layer in this clicker game, checks if there's a present and goes down again

https://pastebin.com/Qet6kCXL

tribal path
#

key is just the name. Is val the widget?

elder plinth
#

the key is the widget. the val is the color value I am sending to the led. but the import is the key

#

key.lower() converts the uppercase key in the list to a lowercase which the widgets are. For example the list shows LED0, LED1 and the widget names are led0, led1, there are 453 of these widgets.

tribal path
#

key is just a string though, is there another dict with the widgets or is it just them defined globally there...
In your snippet you are reassigning the value before even using it, is it being used/read elsewhere?

elder plinth
#

the widgets are defined globally

tribal path
#

Ideally you could/should store them in a list/dict, would seem to make more sense than storing (just) the names.

In the interim you can get the widget from the string via globals()["key"]

digital rose
#

so whenever i open qt designer an setup error opens. what happened?

unique forge
#

Google it @digital rose I had the exact same error

#

I forgot what I did though

mighty gale
#

getting this error with setting an ico file as the favicon of the tkinter window, only happening on my laptop and not on my main pc. was working yesterday on laptop as well but suddenly not working. ico file EXISTS on laptop and PC

#

help

honest walrus
#

someone come from Indonesia?

keen path
#

not me at least

uncut pawn
#

I am trying to connect them together but it does not work

unique forge
#

@digital rose I reccomend PyQT

#

Also PyQT has a tool called qt designer, which is a drag and drop intergace to create a Python UI

uncut pawn
#

@unique forge

#

DO u know how to solve this problem

unique forge
#

Yes

#

DM me

teal hearth
#

I am having trouble with intergrating my Pyside2 UI I created with QTdesigner to run insider blender. anyone who has experience in this ? or would like to take a look and help me out ? I'd be forever grateful. The problem is with some multiple file reading and I cannot figure that part out

vernal dock
#

Hey anyone moderately experienced in PyQT?

#

I want to make a context menu in pyQt application's status icon get keystrokes. Like keyboard shorcuts

#

I know we can put those from qt designer in menustrip, but I need to make it on context menu

digital rose
#

hey

#

how can i convert this to tkinter

proven basinBOT
lucid trench
#

from tkinter import filedialog, Text
import os

root = tk.Tk()
apps = []

if os.path.isfile('save.txt'):
with open('save.txt','r') as f:
tempApps = f.read()
tempApps = tempApps.split(',')
apps =[x for x in tempApps if x.strip()]
print(apps)
def addApp():

for widjet in frame.winfo_children():
    widjet.destroy()

filename = filedialog.askopenfilename(initialdir = "/", title= "Select File",
filetypes=(("executables","*.exe"),("all files","*.*")))

apps.append(filename)
print(filename)
for app in apps :
    label = tk.Label(frame, text =  app, bg ="gray")
    label.pack()

def runApps():
for app in apps:
os.startfile(app)
canvas = tk.Canvas(root,height = 700, width = 700 , bg="#263D42")
canvas.pack()

frame = tk.Frame(root , bg="white")
frame.place(relwidth=0.8,relheight=0.8 , relx=0.1 , rely=0.1)

openFile = tk.Button(root , text = "Open File" , padx=10,
pady=5, fg="white", bg="#263D42" ,command=addApp)
openFile.pack()

runApps = tk.Button(root , text = "Run Apps" , padx=10,
pady=5, fg="white", bg="#263D42", command=runApps)
runApps.pack()

for app in apps :
label = tk.Label(frame, text=app)
label.pack()
root.mainloop()

with open("save.txt","w")as f:
for app in apps:
f.write(app + ',')

#

mY NEW GUI CODE PLS CHECK

teal hearth
#

I have this UI code and the blender addon also created. functionality wise it runs properly through blender but the UI doesnt show up properly. can someone help me on this please. blender doesnt ship with Pyside2 so you need PySide2 and Shiboken2 modules in your blender site packages,

robust oak
#

You can embed matplotlib pyplot figures into tkinter windows, however I can only set the Figure size using inches and DPI, does that mean my window will appear differently depending on the monitor / screen size?

oblique steeple
#

Hello guys! I would like to read some data from excel sheets and do some basic calculations. Dependent of the results, I would like to extract informations from another sheet and show the results in a spreadsheet like GUI. how can i do that in the easiest way?

#

Basically a GUI that almost looks like excel and maybe has some filtering function.

oblique steeple
#

or is VBA just easier?

echo junco
#

@oblique steeple its never wrong to use what you are used to using. VBA has tight integration into the Microsoft. Writing your own "excel" in Python is going to be a bunch of work.

digital rose
#

hey guys

#

I was wondering if any of you knew how to draw a weekly course schedule with python

#

or if you guys knew of any apis that might help

digital rose
signal belfry
#

it seems pretty cool

#

which library is used?

#

feel free to ping me

hidden dock
#

hi, I need some help with PyQt5

whole dagger
#

What do you need help with?

hidden dock
#

Now I want when user selects one of the radio buttons, the current window should close and the corresponding window should open

#

`
class PdfApp(main.Ui_Dialog):
def init(self, MainWindow):
super().setupUi(MainWindow)
MainWindow.setWindowFlags(QtCore.Qt.WindowCloseButtonHint
| QtCore.Qt.WindowMinimizeButtonHint)
MainWindow.show()
self.radioButton.setChecked(False)
self.radioButton_2.setChecked(False)
self.radioButton.toggled.connect(self.radioSelect)
self.radioButton_2.toggled.connect(self.radioSelect)

def radioSelect(self):
    pass

`

digital rose
#

Hello anyone here

#

I made a button which shows cards , but I want that it should show card after 2 seconds from clicking the button

#

How should I do this

oak flame
#

from time import sleep
And where in the code you want it to wait, you type:
sleep(2)

#

@digital rose

modern marsh
#

eh

#

i might be wrong

#

but using sleep for longer intervals of time is not advised

#

cuz you cant multitask if sleep is used

digital rose
#

i have another issue here

oak flame
#

Yes?

digital rose
#

it says Image has no attribute named open

#

i imported Image from PIL

#

Because i want it in my GUI

#

should i send the code

#

?

oak flame
#

Um sure

digital rose
#
from PIL import Image,ImageTk
root=Tk()
img=ImageTk.PhotoImage(Image.open("space.jpg"))
l1=Label(root,image=img)
l1.pack()
root.mainloop()
oak flame
#

Hmmmm

#

Remove .open

#

Try again

#

Did it work?

digital rose
#

module object not callable

oak flame
#

Idk man my thing is web development and game dev

#

Along with databases

meager pilot
#

How do I use a image as a button in Tkinter?

viscid sluice
#

hello iam new hier

weary raven
#

hellow , i am designing a gui with pyqt5,and i want to set a image as a button ,How do i do that?

torpid vessel
#

Hi, I'm making a program that copies files and I want a progressbar, how can I do that?

viscid sluice
#

damn

#

ther is 2 more question

unique forge
#

@viscid sluice ask

#

This channel is for multiple questions

viscid sluice
#

ok

#

so iam new to phyton and iam using tkinter .what iam asking is can you use .pack and .grid in 1 window

#

and if i cannot how iam can use thos to thing at the same time ,or ther is another way

modern marsh
#
from tkinter import ttk
ttk.Progressbar()
#

and then see the docs related to it

torpid vessel
#

Yes, I know how to add the progress bar, but I do not know how to report back progress from the copying process and add to the progress bar

amber roost
#

@torpid vessel You'd need some sort of parallel execution for that, otherwise the copying process will just hang the UI while it's running so the progress bar becomes useless

torpid vessel
#

so like async?

amber roost
#

Basically, but asyncio and tkinter don't play well with eachother

#

The way I've been doing this stuff boils down to a thread, a queue and a tkinter after routine that calls iself, checks the queue and if the thread isn't done yet, calls itself again

torpid vessel
#

oh sweet thanks!

digital rose
#

i tweaked it a bit

#

@signal belfry

signal belfry
#

k

#

looks OP

digital rose
#

thanks

#

even idk the meaning of op 😆

keen path
#

yes i clarify

#

id say the opposite

digital rose
#

but ik that they use it for smth cool prolly

keen path
#

ir means original poster

digital rose
#

i am bad at abbrevations

#

i failed my test on abbrevations when i was in 4th grade

signal belfry
#

@digital rose OP here means Over Powered ||Sorry for the ping though||

digital rose
#

nvm

hexed solar
#

Is there any channel/ server for Tkinter??

#

is this that one??

meager ravine
#

If anyone can explain/assist me how this isn't working that'd be awesome! Just trying to make a simple clicker for a game to select multiple types of rocks in as short as lines as possible preferably

    if pyautogui.locateOnScreen('rock1.png' or 'rock2.png' or 'rock3.png' or 'rock4.png', grayscale=True, confidence=0.8, region=(161,174, 1300, 840)) !=None:
        ore = pyautogui.locateCenterOnScreen('rock1.png' or 'rock2.png' or 'rock3.png' or 'rock4.png', grayscale=True, confidence=0.8, region=(161,174, 1300, 840)) 
        print("I can see ore!")
        pyautogui.click(ore)
        time.sleep(.05)
        pyautogui.click(ore)
        time.sleep(.05)
        pyautogui.click(ore)
        time.sleep(.05)
        pyautogui.click(ore)
        time.sleep(.05)
        pyautogui.click(ore)
        time.sleep(.05)```
#

please ping me if you do know 🙂

grand mason
#

Anyone familiar with wxpython?

unique forge
#

just ask @grand mason

grand mason
#

wait a minute

modern marsh
#

this one

meager pilot
#
import numpy
import random
from tkinter import *
import keyboard
from PIL import Image, ImageTk

def roll():    
    chance=(1,2,3,4,5,6)
    probability=(0.05,0.15,0.3,0.3,0.15,0.05)
    result=str((random.choices(chance,probability)))
    result=result[1:-1]
    if result=='1':
        dice_pic=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\one.png')
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=50,y=35)
        print("1")
    elif result=='2':
        dice_pic=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\two.png')
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=50,y=35)
        print("2")
    elif result=='3':
        dice_pic=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\three.png')
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=50,y=35)
        print("3")
    elif result=='4':
        dice_pic=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\four.png')
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=50,y=35)
        print("4")
    elif result=='5':
        dice_pic=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\five.png')
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=50,y=35)
        print("5")
    elif result=='6':
        dice_pic=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\six.png')
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=50,y=35)
        print("6")

root=Tk()
root.geometry("640x640")
root.title("Dice Rolling Simulator")
root.iconbitmap(root,r'C:\Users\amrik\Desktop\Dice Simulator\Dice\icon.ico')
roll_button=Button(root,text="Roll",font=('Arial',16,('bold')),height=2,width=10,command=roll)
roll_button.place(x=240,y=520)
root.mainloop()```
keen path
#

k so

meager pilot
#

yup

keen path
#

LOOK

#

the error is just jumping to my eyes

meager pilot
keen path
#

you are modifiying dice_pic 6 times

#

so actually, dice_pic is equal to the 6th image

meager pilot
keen path
#

yeah

meager pilot
#

But it is displaying nothing

keen path
#

well can u send me an image of ur code

#

cuz it lost indentation in discord

meager pilot
keen path
#

ah better

meager pilot
keen path
#

even better

meager pilot
#

lol

keen path
#

so first

#

ur only displaying the button

#

but you’re not displaying the label

#

also can you use .pack() instead cuz you’re just showing 2 widgets

#

@meager pilot

meager pilot
keen path
#

it’ll be displayed in the center no ?

meager pilot
keen path
#

hello

digital rose
#

oui

keen path
#

ah

meager pilot
#

This is how it looks like

keen path
#

k use .place() instead

meager pilot
#

yup

keen path
#

also

#

viper

meager pilot
#

hm

keen path
#

put :

labelphoto.place(x,y)

put it in the last line of roll()

#

and run your code

#

( and giv feedback ofc )

meager pilot
#

Its working

#

TypeError: place_configure() takes from 1 to 2 positional arguments but 3 were given

#

But I am given this error

keen path
#

where did u use place_configure()

meager pilot
#

I didn't

keen path
#

what

#

can u send a pic

meager pilot
keen path
#

yes well cuz

#

labelphoto.place(x=150,y=20)

#

not labelphoto.place(150,20)

#

did it work now

meager pilot
#

For some reason, it stopped displaying the images

keen path
#

what

#

is there any error

meager pilot
#

no error

keen path
#

k can u take another pic of the code

#

sorry but i have to see the code to guess the problem

meager pilot
#

Well its showing the error now... wait

keen path
#

which error

meager pilot
#

nevermind... I forgot to save the code

#

when I directly put the values instead of x and y, the images are being shown

#

I dont understand why

keen path
#

oh ok

#

so the image is showing now ?

meager pilot
#

nope

keen path
#

k so

#

in line 42

#

put a line before it and write : global labelphoto

#

did it work

meager pilot
#

SyntaxError: name 'labelphoto' is used prior to global declaration

keen path
#

ah k

meager pilot
#

I should define it at the top of the function roll()

#

I think

keen path
#

no dont

#

just put it after the imports

meager pilot
#

ok

keen path
#

it should work this thing out

meager pilot
#

It still isn't showing the images

#

And its showing that its unbound by pylance

keen path
#

can u put global labelphoto in the function

#

at the top pf roll()

#

i think u were right

#

if it still doesnt work

#

we will try something different

meager pilot
#

Nope, didn't work

keen path
#

argh also something

#

why are u placing labelphoto many times

meager pilot
#

Which one should I remove?

#

at line 42 or within the if-else?

keen path
#

if else

meager pilot
#

Did

#

Still not working

keen path
#

can u send me ur code

#

ill try it myself

#

or wait

#

i cant have the images

meager pilot
#

?

keen path
#

nothing

#

wait i think it”s

#

well instead of

#

putting an image

#

can u change the label’s content to some text

#

which is 1,2,3,4,5,6

#

just to see

meager pilot
#

ok wait

keen path
#

done ?

meager pilot
#

When I try to declare a new label, my IDE says that it is not accessed by pylance

keen path
#

so basically if the numbers are being shown to the label, means the problem is with the image

meager pilot
#

It sort of means that "that line of code will not get executed'

keen path
#

why

meager pilot
#

IDK

keen path
#

oh wait

#

can u send me ur code fast

#

i think i’ve got a solution

meager pilot
keen path
#

nah the code

#

like here

#

ill copy it

#

and paste it in my ide

meager pilot
#
import numpy
import random
from tkinter import *
import keyboard
from PIL import Image, ImageTk

def roll():  
    global labelphoto 
    chance=(1,2,3,4,5,6)
    probability=(0.05,0.15,0.3,0.3,0.15,0.05)
    result=str((random.choices(chance,probability)))
    result=result[1:-1]
    if result=='1':
        #dice_pic1=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\one.png')
        #labelphoto= Label(root,image=dice_pic1)
        txtlabel=Label(root,text="1")
        #labelphoto.place(x=50,y=35)
        #print("1")
    elif result=='2':
        dice_pic2=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\two.png')
        labelphoto= Label(root,image=dice_pic2)
        #labelphoto.place(x=50,y=35)
        print("2")
    elif result=='3':
        dice_pic3=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\three.png')
        labelphoto= Label(root,image=dice_pic3)
        #labelphoto.place(x=50,y=35)
        print("3")
    elif result=='4':
        dice_pic4=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\four.png')
        labelphoto= Label(root,image=dice_pic4)
        #labelphoto.place(x=50,y=35)
        print("4")
    elif result=='5':
        dice_pic5=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\five.png')
        labelphoto= Label(root,image=dice_pic5)
        #labelphoto.place(x=50,y=35)
        print("5")
    elif result=='6':
        dice_pic6=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\six.png')
        labelphoto= Label(root,image=dice_pic6)
        #labelphoto.place(x=50,y=35)
        print("6")
    labelphoto.place(x=150,y=20)
root=Tk()
root.geometry("640x640")
root.title("Dice Rolling Simulator")
root.iconbitmap(root,r'C:\Users\amrik\Desktop\Dice Simulator\Dice\icon.ico')
roll_button=Button(root,text="Roll",font=('Arial',16,('bold')),height=2,width=10,command=roll)
roll_button.place(x=240,y=520)
root.mainloop()```
keen path
#

@meager pilot are u here

meager pilot
#

yup

keen path
#

im still with ur code

#

and dont know

#

well im on mobile rn

#

and

meager pilot
#

and?

keen path
#

my ide cant display gui

#

and repl.it is failing in importing packages

meager pilot
#

😦

split ferry
#

Just a note: The global variable has not been defined before being used in the roll function

keen path
#

u mean after the imports or after setting the Tk()

split ferry
#

I don't know if I can help you, but can you post your full code? Let me have a look.

keen path
#
import numpy
import random
from tkinter import *
import keyboard
from PIL import Image, ImageTk

def roll():  
    global labelphoto 
    chance=(1,2,3,4,5,6)
    probability=(0.05,0.15,0.3,0.3,0.15,0.05)
    result=str((random.choices(chance,probability)))
    result=result[1:-1]
    if result=='1':
        #dice_pic1=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\one.png')
        #labelphoto= Label(root,image=dice_pic1)
        txtlabel=Label(root,text="1")
        #labelphoto.place(x=50,y=35)
        #print("1")
    elif result=='2':
        dice_pic2=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\two.png')
        labelphoto= Label(root,image=dice_pic2)
        #labelphoto.place(x=50,y=35)
        print("2")
    elif result=='3':
        dice_pic3=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\three.png')
        labelphoto= Label(root,image=dice_pic3)
        #labelphoto.place(x=50,y=35)
        print("3")
    elif result=='4':
        dice_pic4=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\four.png')
        labelphoto= Label(root,image=dice_pic4)
        #labelphoto.place(x=50,y=35)
        print("4")
    elif result=='5':
        dice_pic5=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\five.png')
        labelphoto= Label(root,image=dice_pic5)
        #labelphoto.place(x=50,y=35)
        print("5")
    elif result=='6':
        dice_pic6=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\six.png')
        labelphoto= Label(root,image=dice_pic6)
        #labelphoto.place(x=50,y=35)
        print("6")
    labelphoto.place(x=150,y=20)
root=Tk()
root.geometry("640x640")
root.title("Dice Rolling Simulator")
root.iconbitmap(root,r'C:\Users\amrik\Desktop\Dice Simulator\Dice\icon.ico')
roll_button=Button(root,text="Roll",font=('Arial',16,('bold')),height=2,width=10,command=roll)
roll_button.place(x=240,y=520)
root.mainloop()
#

@meager pilot why are u importing keyboard,numpy, and ImageTk

#

if they arent needed

meager pilot
#

Oh yeah... I imported keyboard bcoz I thought I would require it and about ImageTk, I sort of was looking for a fix for the image thing... I removed them now

keen path
#

k

split ferry
#

Is there no image for 1?

meager pilot
#

There is

#

I was just debugging with @keen path

split ferry
#

Okay

meager pilot
#
import numpy
import random
from tkinter import *

def roll():  
    global labelphoto 
    chance=(1,2,3,4,5,6)
    probability=(0.05,0.15,0.3,0.3,0.15,0.05)
    result=str((random.choices(chance,probability)))
    result=result[1:-1]
    if result=='1':
        dice_pic1=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\one.png')
        labelphoto= Label(root,image=dice_pic1)
        labelphoto.place(x=50,y=35)
        print("1")
    elif result=='2':
        dice_pic2=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\two.png')
        labelphoto= Label(root,image=dice_pic2)
        labelphoto.place(x=50,y=35)
        print("2")
    elif result=='3':
        dice_pic3=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\three.png')
        labelphoto= Label(root,image=dice_pic3)
        labelphoto.place(x=50,y=35)
        print("3")
    elif result=='4':
        dice_pic4=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\four.png')
        labelphoto= Label(root,image=dice_pic4)
        labelphoto.place(x=50,y=35)
        print("4")
    elif result=='5':
        dice_pic5=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\five.png')
        labelphoto= Label(root,image=dice_pic5)
        labelphoto.place(x=50,y=35)
        print("5")
    elif result=='6':
        dice_pic6=PhotoImage(file=r'C:\Users\amrik\Desktop\Dice Simulator\Dice\six.png')
        labelphoto= Label(root,image=dice_pic6)
        labelphoto.place(x=50,y=35)
        print("6")
    labelphoto.place(x=150,y=20)
root=Tk()
root.geometry("640x640")
root.title("Dice Rolling Simulator")
root.iconbitmap(root,r'C:\Users\amrik\Desktop\Dice Simulator\Dice\icon.ico')
roll_button=Button(root,text="Roll",font=('Arial',16,('bold')),height=2,width=10,command=roll)
roll_button.place(x=240,y=520)
root.mainloop()```
#

This is the actual code

keen path
#

well i dont rlly know where to place labelphoto.place()

#

by being aware that it needs to be constantly updated @split ferry

split ferry
#

Your suggestion is fine. Since it gets updates only once in the roll function, all you need to do is define it after all the changes are made

keen path
#

?

#

so just at the end of roll()

#

?

split ferry
#

Yea

keen path
#

or within the tk window declaration

#

k

meager pilot
#

We tried it

keen path
#

but it’s already done no ?

meager pilot
#

Yeah, it didnt work

split ferry
#

I'll go over the code. The problem might be something else

keen path
#

line 42

split ferry
#

Yea, that is alright

keen path
#

@meager pilot wait was it showing the text

meager pilot
keen path
#

on labels

#

oh ok

meager pilot
#

Due to the pylance thing

keen path
#

pylance blabla

#

k @meager pilot

#

im on keyboard

#

the label is working

#

the problem is with the images

#

@meager pilot

split ferry
#

The problem is with the images. They don't load inside the roll function

#

Just to define a label outside the roll function and insert an image.

#

It works fine. But it acts up when inside the roll function.

split ferry
#

Also, try using the PIL library. It's more consistent, I guess

keen path
#

k

#

im trying with images

#

btw

split ferry
#

Cool

keen path
#

@split ferry means that

#

the labels are constantly changing

#

the real problem is just displaying images

split ferry
#

I solved it, but it's rather a tedious solution

keen path
#

what was the problem

#

ive used those images

#

it didnt work

split ferry
#

Firstly I used, PIL library. And secondly, I defined all the global variables and updated them inside the roll function

#

I'll share the code

keen path
#

k

#

code ?

split ferry
#

import numpy
import random
from tkinter import *
from PIL import Image,ImageTk

def roll():
global pilimage, dice_pic1, labelphoto
pilimage=Image.open("image name")
dice_pic1= ImageTk.PhotoImage(pilimage)
labelphoto= Label(root,image=dice_pic1)
labelphoto.place(x=0,y=0,)
print("1")

root=Tk()
root.geometry("640x640")
root.title("Dice Rolling Simulator")
#root.iconbitmap(root,r'C:\Users\amrik\Desktop\Dice Simulator\Dice\icon.ico')
roll_button=Button(root,text="Roll",font=('Arial',16,('bold')),height=2,width=10,command=roll)
roll_button.place(x=240,y=520)
pilimage=Image.open("image name")
dice_pic1= ImageTk.PhotoImage(pilimage)
labelphoto= Label(root,image=dice_pic1)
labelphoto.place(x=50,y=35)
print("1")
root.mainloop()

keen path
#

copy paste vanished from ur

#

oh ok

split ferry
#

This is entirely my version of the code. Use the same logic and you should be fine

keen path
#

where are the if statements

#

k

split ferry
#

This is just a logic

#

If you want i can type out the whole code and then share it

keen path
#

i get it

#

his real problem was bringing images

#

@meager pilot

#

there u go'

meager pilot
keen path
#

k look

#

ill be sending u ur code

meager pilot
#

ok

keen path
#

wait im just fixing it

#

k ima send it

#

but dont copy it

#

ill just fix directories

meager pilot
#

yeah yeah

keen path
#

wait

proven basinBOT
#

Hey @keen path!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

keen path
#

!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.

keen path
#

there @meager pilot

#

i fixed it to fit your image directories

#

tell me if there is any error with it

meager pilot
#

It is working fine

#

Thank you

keen path
#

np

#

can u show me a pic

#

just curious to see what ur pics look like

proven basinBOT
meager pilot
keen path
#

ok

#

ima go finish my meme

meager pilot
#

Whats this?

keen path
#

look at the buttons

#

well its vsc

#

but im just using it as an example

#

well you will understand the joke

#

when i finish

#

it

meager pilot
#

ok

#

Hey

#

What if I want to send my code to my friend?

#

Where the directories will vary?

keen path
#

he needs to change the directories

#

so the code can find the images where they have to be

meager pilot
#

I want to adjust such that he doesnt need to

#

I mean I have a folder named Dice Simulator where all the files are store..

#

Cant I made changes such that the code will check the folder whereever it is?

keen path
#

yes

#

its very possible

#

give me ur code

#

@meager pilot

meager pilot
keen path
#

can u give me ur code

#

ill add the simple and powerful lines'

#

to do so

meager pilot
#
def roll():
    global pilimage, dice_pic, labelphoto
    chance=(1,2,3,4,5,6)
    probability=(0.05,0.15,0.3,0.3,0.15,0.05)
    result=str((random.choices(chance,probability)))
    result=result[1:-1]
    if result == "1":
        pilimage=Image.open(r"C:\Users\amrik\Desktop\Dice Simulator\Dice\one.png")
        dice_pic= ImageTk.PhotoImage(pilimage)
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=270,y=70,)
        print("1")
    if result == "2":
        pilimage=Image.open(r"C:\Users\amrik\Desktop\Dice Simulator\Dice\two.png")
        dice_pic= ImageTk.PhotoImage(pilimage)
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=270,y=70,)
        print("2")
    if result == "3":
        pilimage=Image.open(r"C:\Users\amrik\Desktop\Dice Simulator\Dice\three.png")
        dice_pic= ImageTk.PhotoImage(pilimage)
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=270,y=70,)
        print("3")
    if result == "4":
        pilimage=Image.open(r"C:\Users\amrik\Desktop\Dice Simulator\Dice\four.png")
        dice_pic= ImageTk.PhotoImage(pilimage)
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=270,y=70,)
        print("4")
    if result == "5":
        pilimage=Image.open(r"C:\Users\amrik\Desktop\Dice Simulator\Dice\five.png")
        dice_pic= ImageTk.PhotoImage(pilimage)
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=270,y=70,)
        print("5")
    if result == "6":
        pilimage=Image.open(r"C:\Users\amrik\Desktop\Dice Simulator\Dice\six.png")
        dice_pic= ImageTk.PhotoImage(pilimage)
        labelphoto= Label(root,image=dice_pic)
        labelphoto.place(x=270,y=70,)
        print("6")```
keen path
#

and if those lines are put

#

you'll just have to send the folder to someone

#

and itll automatically work

#

no the whole code

#

or wait

#

ill just take the one i sent you

meager pilot
#

yeah, i will send the whole folder

keen path
#

but before

#

can u show me a pic of the folder

#

or

#

is it

#

roll.py
assets folder --------- pic1.png
pic2.png
pic3.png
pic4.png
pic5.png
pic6.png

#

is it like this ^^^

meager pilot
keen path
#

ok it's that

meager pilot
#

hm

keen path
#

what are the images called

#

oh yeah its one.png

meager pilot
#

one.png

keen path
#

k

meager pilot
#

yeah

keen path
#

btw

#

in

#
root.iconbitmap(root,r'C:\Users\amrik\Desktop\Dice Simulator\Dice\icon.ico')
#

why did u put root