How to change the defaults alignment to left in pygtk? - windows

Every program that I'm making using pygtk is right-alignment by default (maybe because my default language is right to left language?)
How can I change it?

The orientation of the widgets in a container depends on the locale. You can change the locale settings on Windows by setting the LANG environment variable.
set LANG=en_US
something.py
On Linux you can do the same with the following commands
export LANGUAGE=en_US
something.py
or simply
LANGUAGE=en_US something.py

And if you want to adjust direction of widgets inside a widget (for example a window), regardless of system locale:
widget.set_direction(gtk.TEXT_DIR_LTR)
And to change default direction for everything inside your app:
gtk.widget_get_default_direction(gtk.TEXT_DIR_LTR)
Or gtk.TEXT_DIR_RTL instead of LTR

Related

What color should i change to make powerlevel9k visible

I have following prompt
~/repos/go/src/github.com/xyz/xyz-project > <branch_changed_icon> GG-000
Whenever i make the code change in the directory, the last part which is <branch_changed_icon> GG-000 goes dark black or gray. Which is is not visible on my extended monitor (monitor is shitty). If i make the commit/add, this prompt turns to green which is perfectly visible.
I was looking at powerlevel9k.zsh-theme file but couldn't figure out what change i have to make so that i can make this last part more visible.
The VCS segment is a stateful one and has the state included in the variable name.
So you have to write your Variables for the VCS segment like this: POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red' in your ~/.zshrc.
Have a look at the P9K wiki for further informations.
Note that these variables will change, once the development branch will be stable.
And in general, if your colors are very dark, you should consider installing a color scheme for your terminal. If you use iTerm2, you can choose one here. That affects all of your Terminal, not just single segments. A popular scheme is "Solarized Dark".

Programatically change font size in a linux terminal using python

In Ubuntu gnome-terminal it can be done by doing Ctrl + or Ctrl -
Is there a way to write a python script that when executed would resize the font size of the terminal it is executed from?
I need this in order to display images in terminal with high resolution using timg.
Checking the source (vte and gnome-terminal), looks like there's no way to do this. Other terminals (e.g., xterm) can do this using escape sequences. See XTerm Control Sequences:
OSC Ps ; Pt ST
Set Text Parameters. For colors and font, if Pt is a "?", the
control sequence elicits a response which consists of the con-
trol sequence which would set the corresponding value. The
dtterm control sequences allow you to determine the icon name
and window title.
...
Ps = 5 0 -> Set Font to Pt. These controls may be disabled
using the allowFontOps resource. If Pt begins with a "#",
index in the font menu, relative (if the next character is a
plus or minus sign) or absolute. A number is expected but not
required after the sign (the default is the current entry for
relative, zero for absolute indexing).
vte recognizes the 50, but that (like a lot of other xterm features) is just a stub that doesn't do anything. The xterm sources include a 20-year old script which demonstrates the feature (see fonts.sh).
Rather than using an escape sequence, you might be able to use the wmctrl tool (which could ask the window manager to negotiate with the terminal). Some have done that with other terminals, e.g, terminology (but ultimately using an escape sequence).
vte does have some code which might be accessible from a python script, using g_signal_connect to associate decrease-font-size and increase-font-size signal (see source code). The signal code is what you're using with the keyboard. But how you might determine the object pointer from a script starting outside the terminal emulator isn't clear.
There is no easy way to do this across terminals. Terminals support so called control sequences, which can set a bunch of options, like text color and others, but there is no control sequence for setting the font size. See for example https://en.wikipedia.org/wiki/ANSI_escape_code and https://invisible-island.net/xterm/ctlseqs/ctlseqs.html for what kind of actions are supported.

Windows10: _gvimrc guifont settings not taking effect

I'm using windows 10. I've been trying to change my font and font size to be easier on the eyes for gvim, and all my settings (syntax, ruler, numbers) work normally from my _vimrc file. I currently have
set guifont=Consolas:h12:cANSI
set guifont=Consolas\ 12
in both my _vimrc and _gvimrc files (both in $HOME). When I load :scriptnames, it shows that ~/_vimrc is loaded first and ~/_gvimrc loaded last. I have also tried
set guifont=Consolas:h12
instead of
set guifont=Consolas:h12:cANSI
Still, everytime I open vim or gvim everything is displayed in that horrid size 7 Fixedsys font. Only when I manually go to Edit->Select Font... can I actually effect a change on the font, but the next time I open vim/gvim the changes are not saved. The funny thing is when I enter :set guifont? it tells me that
guifont=Consolas 12
but the font is definitely still at Fixedsys 7. What is going on?
What worked for me is embedded in #nperson325681's answer but not made explicit. In W10 the correct font setting turns out to be your first instruction
set guifont=Consolas:h12:cANSI
but not
set guifont=Consolas\ 12
(although the latter works for me in Linux, and is what I've seen in Vim documentation and help files). So, as #nperson325681 implicitly suggests, take out the second set guifont in your _vimrc. What your set guifont? shows does correctly reflect what your _vimrc has instructed; it simply isn't what works in W10. What I ended up doing is:
if has('win32') || has('win64')
set guifont=Consolas:h10:cANSI:qDRAFT
else
set guifont=Consolas\ 10
endif
Hope that helps.
If you have two set guifont lines in your rc, the last will win. Try with the first line only.
After you have selected a font using the dialog, you can copy-paste the exact and correct line to your gvimrc by typing in insert-mode <C-r>=&guifont<CR>

Changing keyboard layout from terminal on opensuse

I am trying to bind shortcuts for keyboard layouts.
For example:
Shift+Alt+1 - change to US layout
Shift+Alt+2 - change to UA layout
Shift+Alt+3 - change to RU layout
instead of change it with Super+Space.
In Ubuntu I used to bind such shortcut to gsettings set org.gnome.desktop.input-sources current 1, but in opensuse it doesn't work.
It is possible to do somehow?
I have solved it with little trick.
I created script with such content (for each keyboard layout):
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'ru')]" &&
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'ru'), ('xkb', 'ua')]"
And bind custom shortcut that run this script.
This script changes list of layouts, left there only one layout, because of it system change layout, and then I change list of layout to initial state.

Change Color of Text Being Currently Used (Terminal - OSX)

For reference purposes: I am using a Macbook Pro Retina (2014) and all software is up to date as of the time I am posting this question. (Using OSX 10.10.2 Yosemite)
I have been struggling for the past few days as I attempted to customized the Terminal window. Everything was going fine... until I decided I only wanted to change the color for the text that you are currently typing (text input) which will then be executed.
I have no problems getting into my .bash_profile and adjusting anything. I simply cannot seem to grasp the color concept well enough such that it only does this one thing for me. Currently my .bash_profile looks like this:
export PS1="\n\n\njboned$ "
export PATH="/usr/local/mysql/bin:$PATH"
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
Any assistance would be greatly appreciated. As a sidenote: I understand the 8-bit snippets used to represent the individual colors, however it seems I cannot figure out how to use them to address only the text input only.
To do what you are asking, these steps would be needed:
at the end of the prompt, turn on the text color which you want to show
when you press return (to complete editing) turn the text-color off.
bash does not reset attributes while you edit, so the color "should" work — while editing. As you edit, bash is likely to use escape sequences which clear the current line (which may fill it with whatever background color you have selected).
The real problem is how to reset the colors when you press Enter. That does not appear to have a straightforward solution: I do not see a way to rebind the Enter key to add features—no distinction is made between levels of interpretation, and you may not find it possible to enhance the Enter key. The key binding feature in bash talks mainly to the readline library; leftovers are sent to bash. In a binding you may be able to do these things:
send the name of a macro to bash, or a full echo command which resets colors (since readline has no echo of its own, it seems)
the Enter key (i.e., ^M), and
to readline directly, the accept-line function
Alternatively, what you could do is bind another key, say control/L to do the bash accept-line function as well as resetting color. Here are a couple of links which you would find useful to investigate how to do this:
how to bind the 'Enter key'
Complex keybinding in bash
In bash, how do I bind a function key to a command?
Smart preparsing with the bash shell

Resources