python treeview cell/row borders - python

I have a python tk treeview for listing items, what I couldn't find is a way to stilysh a bit the whole list. i've done a massive google search but didn't find a way to add vertical line borders between each item, maybe it's not possible? I don't like the alternate-line-colors style. I tried tag_configure method but as far as i know it only allows font/foreground/background options.
thank you in advance

Related

How to make Tkinter volume slider in a professional way

I'm trying to make a volume controller in python tkinter. But what exactly the problem is that, I want to make it look rich and professional. So when I tried using tkinter scale widget, it worked. But the widget is just a normal one. I wanted to know a way to make it look like the image below I have sent.
My current one's code is this:
def slider(self):
self.scale = scale = ttk.Scale(self.canvas, from_=0, to=100, orient=HORIZONTAL)
print(self.scale.winfo_class())
self.scale.place(x=580,y=455)
self.scale.set(70)
Is there anyway I can make it look better like the one in the Image?
What all things I want is:
A knob like round thing like in the image which is movable
Some color should fill in the area that is already covered.
A pop up or anything to show the current details of the volume.
I'm using pygame to play music in tkinter btw..
If this isn't possible, please suggest me a better way/alternative to do this. Thank you.
As far as I know, there is no existing widget with a look exactly like what you are asking for. However, tkinter provides a way to craft your own widget styles, which might make it possible to do what you want.
Tkinter comes with a module named ttk, which stands for "themed tk". It allows you to define custom styles for individual widgets, and to bundle those styles into a collection known as a theme. If you want to create a widget with a custom look, you can use this module to do so.
Unfortunately, being able to design a custom theme for a widget isn't very well documented. The best documentation I personally know of is on tkdocs.com, in the section Styles and Themes. It gives a pretty good rundown of the terminology and overall description of how themes work. The python documentation for ttk also gives some additional information about creating styles and layouts in a section titled Ttk Styling.
For inspiration, you can check out the code for the ttkthemes project (github, public documentation) which has many different themes that you can examine. I doubt there is one exactly like you want, but you should be able to create your own after looking through the examples.
It is as easy as setting a theme for the TkInter project. Done in Python it looks like that:
s.theme_use('themename')
You might benefit from reading Styles and Themes documentation of TkDocs.

Place a button inside a grid

In a gui I have a grid. In this grid each row represents an order. To the right of each row, I would like to place a 'cancel button'to cancel the order. When new rows are added this should automatically come with a cancel button.
I did some seaching but apart from this FAQ-question which states that you have to design something yourself (did not help me much). Al other material was based on usage of Tkinter which I do not want to do.
So Two questions:
(1) Does anyone know of a way to place a button in a grid cell in wxpython?
(2) If not, does anyone know of a solution for my requirement?
Thanks,
Django
There isn't really a "built-in" way to do this. You would need to create a custom Renderer. According to Robin Dunn (creator of wxPython) in this thread, you could create a button using wx.RendererNative.DrawPushButton.
I would also recommend taking a look at the wxPython demo as it has some other examples of custom renderers too.

Swipe-Layout using PyGTK

I would like to implement a swipe or flipper view (widget) using PyGtk for my Quickly app. There should be a titlebar that contains the title of the currently showed content and the titles of the previous and next entry. To navigate threw the different entries you should be able to click the titles or swipe from left to right or vice versa.
But I do not know where to start.
Which Widget should I extend?
Would the Notebook widget the right choice?
How could I change the style of a Widget?
How do I implement the flip effect?
Do I have to combine different views (widgets) for the content pane and the titlebar?
For a better understanding of my problem view the screenshot below.
Thanks and best regards
Andreas
You might want to take a look at Clutter. Though I think, this kind of UI-Design could be very unintuitive on a desktop machine.

How to display parsed JSON text

Let me start off by saying that I'm starting this project to get familiar with Python. The project is to parse JSON from Reddit.com every 15 minutes and then display it with Tkinter.
Parsing the JSON text wasn't too difficult, but I'm not sure how display the text. I will need to display two things -- the title of the link and the link -- in a column style view. I was also planning on having two columns side by side to take advantage of the horizontal screen width. I've tried starting out with a Listbox, but that seemed to more be used if you want a selectable list. I just want to display the text and be done with it. Is there a different and more appropriate widget I should be using? I looked into the Entry widget a bit and thought that might be getting closer, but that seemed to only be for storing a single entry.
If you are using a sufficiently modern version of python (2.7, 3....something, I forget) you can use the ttk.Treeview widget which is similar to the listbox but supports multiple columns.
A much simpler choice is to use the text widget. You can insert the text followed by a newline. To line thimgs up in columns just insert a tab, and define an appropriate tab stop.
There are plenty of other options, but those two are arguably the best.
If you haven't dicovered it yet, tkdocs.com has a wealth of information about tkinter.

Clear canvas in Tkinter without deleting everything

I'm quite new to tkinter (by new i mean I picked it up 2 hours ago) and so there is probably a really simple solution to this I'm just not seeing. But I want to clear a canvas so that I can redraw it. But I don't want to use delete as I then change the ID# of all the items as I redraw them. Is there a way to clear the canvas that retains the ID# of my items?
Thanks
I'm programing in Python 2.7 on Ubuntu 11.10.
So. It isn't clearing and redrawing that I want. it is the ability to move and configure items. The functions for which are:
Canvas.configureItem(TAGORID,OPTION=VALUE)
and
Canvas.move(TAGORID,distanceToMoveX,distanceToMoveY)
thanks for your insight Bryan. That was just the kick in the right direction I needed to figure it out.
To find out what the options are for configItem, call it with only a tag or an ID, it will return the appropriate options. for example, options for an oval are:
stipple
disabledoutlinestipple
activeoutlinestipple
dash
disabledwidth
dashoffset
activewidth
fill
disabledoutline
offset
disabledfill
disableddash
width
state
outlinestipple
disabledstipple
activedash
tags
activestipple
activeoutline
outlineoffset
activefill
outline

Categories