GTK - How to style a button in headerbar? - python

I want to set color like blue and red in a application, is something like
this image.
I imagine that I can do it with css styles, but if is there other way much more simple like set a property or a class.
I use GTK 3.12 and Python, but you can show me examples in other lenguages and I can traduce it.

The correct way to do it is with the suggested-action and destructive-action CSS classes. Here is some documentation. Is there any particular objection that you have against CSS?
Use this code:
button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION)
or
button.get_style_context().add_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
before you add the button to the header bar.

Related

Beautify PyQt GUIs and printing to GUI(textbrowser or some other widget)

I've made a GUI for my application but I've to make it look professional. Currently, I think it's looking casual. Also, I want to print some outputs to the textbrowser widget. How should I do that?
I've tried making some changes to stylesheets of widgets, but the options available are not adequate.
My GUI looks like this
The QTextBrowser class provides a rich text browser with hypertext navigation. It opens a URL to display, not plain text.
Use something like a QPlainTextEdit, or a QTextEdit for doing this.
They have methods like appendText, or appendPlainText.
Alternatively, you could have a website and host your text there, but that seems overly complicated.

How to make height of Gtk.StatusBar smaller in PyGObject (GTK+3)?

Standart StatusBar image
<-- So, here it how it looks in my application now. How can I make the height of it smaller? For e.g. in Google Chrome when you pointing some link it shows in the grey bar at the bottom of the page, I want same size.
Chrome is not using a GtkStatusBar (or any other GTK widgets, for that matter).
If you want to change the appearance of a GTK widgets, you'll have to either tweak the theme or use a custom widget, with your own sizing policy.

Python kivy listview with custom layout?

I'm trying to write application in kivy. I would like it to have listview with custom row layout (label on top, below image scaled to window width and below some images, labels and button - see pic). Is it possible to do that with kivy.uix.listview? Or some other way? I was looking on docs but I couldn't find answer to my question.
Yes, it is written in docs here: Adapter
Use either cls or template property to link a customized widget to a list view.
Here you can see cls bound to ListItemButton. Put your own widget in its place.

How to make an editor using markdowns with Qt4 and Python?

I'd like to make a small desktop editor to take notes, that uses markdowns to format text quickly. The application should transcribe markdowns instantaneously or after clicking on a button.
For this I'd like to use Qt4 and Python.
What, in your opinion, is the most efficient way to proceed?
In the case the rich text is rendered after pressing a button, I suppose I could use QTextEdit widget for the edit-mode, but what to use to display the rich text? I want this to look good. Should I render the text in HTML? Or something else?
Please advise.
You can look at how ReText has done it. Maybe even ReText is the app you want to code :-)
I came here because I'm looking for a solution for the same task.
Here is what I would (or hopefully will) try:
Subclass QTextEdit, which can display both plain and rich text.
supply two string properties, one containing Markdown source, the other generated HTML.
For entering "edit mode" (however your UI will handle this)
self.setText(self.markdown)
self.setReadOnly(False)
For leaving "edit mode":
self.markdown = self.toPlainText()
self.toHtml() # convert self.markdown to self.html
# don't know yet how to achieve that
self.setHtml(self.html)
self.setReadOnly(True)
For displaying the HTML one can use a CSS stylesheet.
As UI interface I could imagine: clicking on the readonly display mode switches to edit mode, [Ctrl]-[Enter] triggers HTML generation.

A SuggestBox for wxPython?

Is there a widget for wxPython like the SuggestBox in Google Web Toolkit? It is basically a magic text box that can invoke some code to come up with suggestions relevant to whatever the user has entered so far. Like the search box on Google's web page.
If such a widget isn't already floating out there, I'd appreciate a sketch of how I might implement it with the existing widgets.
You might want to look at Combo Box that Suggests Options.
I hope this is what you were thinking of.
Few years ago I made a control like this by subclassing TextCtrl. It supports HTML formating for suggestions. Here you go.

Categories

Resources