Skip to content

Commit b635a98

Browse files
committed
v0.0.3
1 parent 7051dfb commit b635a98

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,25 @@ pip install tkinterwidgets
2323

2424
#### Usage
2525
```
26-
tkinterwidgets.Label(parent,OPTIONS)
26+
tkinterwidgets.Label(master, OPTIONS)
2727
```
28-
28+
2929
Options
3030
* All the options of native `tkinter` `Label` except `bg`/`background` since the background is transparent.
3131
* `opacity` - Used to specify the opacity of the contents on a scale of `0` to `1` (where `0` implies transparent and `1` implies opaque). The default is set to `1`.
3232
* `transcolor` - Used to specify the color to be used to create the transparency effect (you can imagine this as a green screen but of the specified color, make sure that the visible contents of the label do not have this color). The default is set to `SystemButtonFace` .
3333

3434
Methods
35-
* `pack` - Same usage as that of the `pack` geometry manager in `tkinter`.
36-
* `config`/`configure` - Set values of one or more options.
35+
* The following have the same use as that of the corresponding methods in native `tkinter` widgets
36+
* `pack`
37+
* `pack_forget`
38+
* `config`/`configure`
39+
* `destroy`
3740

3841
#### Current Limitations / Issues
3942
* Only `pack` geometry manager can be used.
4043
* Can not be treated as a `window` in `Canvas.create_window()` or `Text.window_create()` or any similar usage.
41-
* In some cases, the label remains outside the window when the size of the window is reduced.
44+
* Label might move outside the window when resizing past it in some cases.
4245

4346
#### Sample Code
4447
```python

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="tkinterwidgets",
8-
version="0.0.2",
8+
version="0.0.3",
99
author="Aditya Singh Tejas",
1010
author_email="adityasinghtejas03@gmail.com",
1111
description="Tkinter Custom Widgets",

tkinterwidgets/__init__.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ class _Toplevels():
44
def __init__(self):
55
self.toplevels=[]
66

7-
def append(self,toplevel):
8-
self.toplevels.append(toplevel)
9-
107
def lift(self):
118
for top in self.toplevels:
129
top.toplevel.lift()
@@ -32,7 +29,6 @@ def __init__(self,master,opacity=1,transcolor='SystemButtonFace',**kwargs):
3229
if 'bg' in kwargs:
3330
del kwargs['bg']
3431
self.label=internal_tk.Label(self.toplevel,bg=self.transcolor,**kwargs)
35-
toplevels.append(self)
3632
self.change_kwargs=True
3733
self.master.bind('<Configure>',toplevels.position)
3834
self.master.bind('<Map>',self._on_map)
@@ -56,6 +52,7 @@ def position(self):
5652
toplevels.lift()
5753

5854
def pack(self,**kwargs):
55+
toplevels.toplevels.append(self)
5956
if self.change_kwargs:
6057
self.pack_kwargs=kwargs.copy()
6158
self.label.pack(**kwargs)
@@ -89,6 +86,26 @@ def config(self,**kwargs):
8986
self.change_kwargs=False
9087
self.pack(**self.pack_kwargs)
9188

89+
def destroy(self):
90+
self.cover_frame.destroy()
91+
toplevels.toplevels.remove(self)
92+
self.toplevel.destroy()
93+
try:
94+
self.master.deiconify()
95+
except:
96+
pass
97+
toplevels.position(None)
98+
99+
def pack_forget(self):
100+
self.cover_frame.destroy()
101+
toplevels.toplevels.remove(self)
102+
self.toplevel.withdraw()
103+
try:
104+
self.master.deiconify()
105+
except:
106+
pass
107+
toplevels.position(None)
108+
92109
configure=config
93110

94111
toplevels=_Toplevels()

0 commit comments

Comments
 (0)