I saw a recipe in here regarding the use of PIL/Pillow on Tkinter. The examples used were for labels.
I was wondering and would like to know if it can be done on a text widget so that we could use a external font instead of what is available in the user's machine.
EDIT 1: I seen a way to make it possible using this posted by Bryan Oakley regarding line numbers (although the project I'm working does not have line numbers) but I can't seem to get a grip on how to add the custom font code in the recipe
Related
Here is my problem. I developed a tkinter GUI for my project. However I am stuck with tkinter limitations. I developed python gui to create a virtual view for a red table as below. The window does not have any border or title. It is just put on the a picture background which is outside of the code.
However as you can see it is not lively enough for me. I want it to look like this:
Is there a way to do this in tkinter? I tried transparent backgrounds, however in Ubuntu transparent background with visible object is not possible. Also You cannot make different window shapes other than rectangle. What is your suggestions? Should I use another library. I really need an expert opinion about this.
Transparent background reference
Different window shape other than rectangle
My environment : Ubuntu 16.04 Python 3.5.2
You can't specifically change the shape of a Tkinter Window, but you can create a canvas and design your own shape (then add your buttons and labels on this canvas if needed).
You can also take a look at PyQt or Kivy, but if you are confortable with Tkinter go with Canvas.
So to solve my issue I found a python library wxPython:
You can check this link it creates Wx non rectangular shape
It creates the the window using inheritence. I tried selected answer and It solved my question.
Btw I tried QTPython, Kivy, tkinter. Non of them had straight example such wxPython.
This line works fine for my Windows program.
When i run this same file on the Mac OS X, I get a blank page instead of my icon.
Here is the windows line:
self.iconbitmap("Boss.ico")
I have searched relentlusly for an answer I want this icon to work on both platforms. self is the root Tk window if your wondering if it's root or not.
Note: I have tried using icns, .xbm , .gif by loading a photo image and setting thru window attributes all produce the same blank page on the mac.
After 5 days of searching, and this post having been viewed at least 15 times I went directly to the tk/tcl documentation. If I understand this correctly, apparently there is no way to properly set the icon for mac OS X without using special library or other sort of hacks. It would be nice if there were a mac specific documentation for the tkinter library but alas there isn't that I have found. here is the part of the documentation I found:
wm iconphoto window ?-default? image1 ?image2 ...? Sets the titlebar
icon for window based on the named photo images. If -default is
specified, this is applied to all future created toplevels as well.
The data in the images is taken as a snapshot at the time of
invocation. If the images are later changed, this is not reflected to
the titlebar icons. Multiple images are accepted to allow different
images sizes (e.g., 16x16 and 32x32) to be provided. The window
manager may scale provided icons to an appropriate size. On Windows,
the images are packed into a Windows icon structure. This will
override an ico specified to wm iconbitmap, and vice versa.
On X, the images are arranged into the _NET_WM_ICON X property, which
most modern window managers support. A wm iconbitmap may exist
simultaneously. It is recommended to use not more than 2 icons,
placing the larger icon first.
On Macintosh, this currently does nothing.
if anyone has a working solution please post this. I want to accomplish this so that any system can open a freshly installed python and run my application without installing any additional library.
#GarryHurst This is not a solution but I sort of get the idea now:
On Mac, TK decided that the icon will never appear on the window title bar.
Instead, it shows up as the app's Dock icon.
It's most probably a by-design or won't fix issue on their side.
It is showing the icon of the file you are putting in the directory so setting the file to be an app will set the window icon to be the icon of that app.
for example:
root.iconbitmap("/Users/homedir./Desktop/Test apps/Clicker.app")
tk window with icon
I have a coup. Why not change mind, like this.
The emoji library is enough to choose a good-looking icon.
We can do that.:-D
Code
Effect
When using tkinter to create a more modern looking application, I looked to MS Word to inspire my design. Then I noticed that only when I'm using the application on a High DPI device that it looks so terrible.
Is there a way to compensate and make it look just as crisp?
NOTE: "Don't use tkinter" is not on the table.
The best solution I have found for this is to create a custom widget using the WCK (Widget Construction Kit). Text displayed using this is automatically Anti-Aliased.
Try typing this at the beginning of your code
try:
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1)
except:
pass
I think this will solve your problem.
The icon I am looking for is pretty unique, so I think I'm going to have to create my own. (I'm looking for an icon of a closed door) I found a PNG file similar to what I need, but I need to figure out a way to integrate it with the material ui font icon.
Is there a way to create the js file for it, similar to the ones that exist? Like this one: https://github.com/callemall/material-ui/blob/master/src/svg-icons/action/accessibility.js
I don't know where the "path" comes from, does anyone know?
Thanks in advance!
Those were created using design tools specifically created for this purpose. Creating path based SVG Icons will take a bit more time if you're unexperienced in the field, however it is most likely you can create your own with some free online tools and a bit of patience.
Once you did (the data doesn't necessarily have to be in path format for the SVG, you can create any valid SVG using the available syntax and attributes which you can find info about right here), you can simply replicate one of those JS files and import / export them wherever applicable and use it in a similar fashion as you would any Material UI one.
Such an online tool could be this one for creating what you need:
http://editor.method.ac/
I'm using gtkdialog in shell script but I got stuck.I tried "use-markup" to format the font,however it appears does not work.Is not there anything like ?
And if the program has several widgets the layout always be disorderly...
Is there a solution?Or a good tutorial on gtkdialog?(I searched but could not find one besides the user-manual).
EDIT:I'm trying to change the font ,color it.The problem with desordely layout I've solved.
use-markup means that text will be styled using the Pango Text Attribute Markup Language. You'll have to markup your text accordingly to get the desired font/style/color/etc.