Comments (9)
I'm currently not able to implement it, but I think it's a good starting point for you.
It's basically just adding a font
parameter to the __init__
, and a key to _keys
, and Tukaans' widget API does the rest for you.
You can see, how other parameters are implemented in label.py
, and textbox.py
specifically for font attributes.
from tukaan.
I'm currently not able to implement it, but I think it's a good starting point for you.
It's basically just adding a
font
parameter to the__init__
, and a key to_keys
, and Tukaans' widget API does the rest for you. You can see, how other parameters are implemented inlabel.py
, andtextbox.py
specifically for font attributes.
@rdbende I added it as:
"font": tuple,
...
font: tuple | None = None,
...
font=font,
But this gives the error:
File "/Users/Moosems/Desktop/tukaan/tukaan/widgets/button.py", line 44, in __init__
BaseWidget.__init__(
File "/Users/Moosems/Desktop/tukaan/tukaan/widgets/_base.py", line 316, in __init__
Tcl.call(None, self._tcl_class, self._name, *Tcl.to_tcl_args(**kwargs))
File "/Users/Moosems/Desktop/tukaan/tukaan/_tcl.py", line 174, in call
raise TclError(msg) from None
tukaan.exceptions.TclError: unknown option "-font"
from tukaan.
tukaan.exceptions.TclError: unknown option "-font"
Nah, that is odd. I have to figure out why that happens, the manual page says that it works with Tk 8.5 and eith 8.6 as weel, so it shouldn't be an unknown option.
"font": tuple,
...
font: tuple | None = None,
...
font=font,
In my opinion, managing fonts in Tkinter is kinda inconvenient. You have to create tuples with some random str values, and just in the right order, and if you want to skip a property from that order, you have to use Tcl-like kwargs, and whatnot. Again, since explicit is better than implicit, Tukaan has a function, that generates this tuple for you, so you can simply use keyword arguments, and it will return a Tcl-compatible tuple. Its full signature is this: tuple[str | int | bool, ...]
.
The other thing that Tukaan has, is Font objects, that can be changed dinamically, so you can do
some_widget.font.bold = True
and it will change every associated widget's font to bold immediately. It's also possible to load a font from file woth them, so it gives you a lotta power.
As for _keys
for the TextBox
widget I defined the type as Font
(the font object), but I forgot about the possibility to use the font()
function. When using it, there's no Font
object associated with the widget, so it can't really use that. Now I need to figure out, what should be that type, but you have to wait for that 😕.
{"font": ????}
...
font: Font | tuple[str | int | bool, ...] | None = None, # You'll have to 'from tukaan.fonts import Font' first
...
font=font
from tukaan.
Personally I really love the way that tkinter handles fonts for the user but I would like it if you didn't always have to give a size value. Tkinter is super flexible when it comes to fonts but I would also love it where it sturdy. I honestly really dislike making font objects and normally use
normal_font=("Courier New bold", 15)
from tukaan.
@rdbende Any updates? I'm still hoping to fix this
from tukaan.
@rdbende I added it as:
"font": tuple, ... font: tuple | None = None, ... font=font,But this gives the error:
File "/Users/Moosems/Desktop/tukaan/tukaan/widgets/button.py", line 44, in __init__ BaseWidget.__init__( File "/Users/Moosems/Desktop/tukaan/tukaan/widgets/_base.py", line 316, in __init__ Tcl.call(None, self._tcl_class, self._name, *Tcl.to_tcl_args(**kwargs)) File "/Users/Moosems/Desktop/tukaan/tukaan/_tcl.py", line 174, in call raise TclError(msg) from None tukaan.exceptions.TclError: unknown option "-font"
Actually, I successfully implemented this today in the same way, so Idk what was the problem.
from tukaan.
Can you create a release for me to test it with?
from tukaan.
Soon!
from tukaan.
😀
from tukaan.
Related Issues (20)
- Upload to pypi soon HOT 3
- `ButtonGroup` widget
- `LabeledView` widget
- Add DBus API HOT 1
- There are too many files HOT 1
- `tkinter` widget support HOT 3
- Add a better color module HOT 2
- Docstrings explaining widget HOT 3
- Make Combobox and Spinbox generic HOT 5
- Window not shown HOT 5
- Make `main` branch the main HOT 3
- How can I apply mica effect to the tukaan window? HOT 1
- `.size()` method crashes application HOT 2
- KolorScheme on Mac breaks tooltips HOT 2
- Delay first update until `run()` HOT 1
- Builtin required size getters
- `enabled` property on `Tab` doesn't work
- `TabView` makes some binds that are never saved HOT 1
- `TabView.enable_tab_dragging()` is broken
- Tooltip delay argument HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tukaan.