Remove border from fullscreen floating windows only (XMonad configuration) - haskell

I would like to
remove borders (only) from floating windows covering the full screen (like mplayer), and
use a different border color (normalBorderColor) when there is only one window in a workspace.
Currently, I am using smartBorders from XMonad.Layout.NoBorders to remove the border from mplayer, and to remove the border of a window when that window is the only window in a workspace. However, when I switch between two workspaces which both have a single non-floating window (regardless of mode (tall/mirror/full)), then I see the window (in the workspace I am changing into) "jump" a bit, as its border is drawn, and then removed a brief moment thereafter (the effect is more visible if you set your borderWidth to a large number).
The relevant part of my ~/.xmonad/xmonad.hs is given below.
import XMonad.Hooks.ManageDocks
import XMonad.Layout.NoBorders
myLayout = tiled ||| Mirror tiled ||| Full
where
tiled = Tall 1 (3/100) (3/5)
main = xmonad $ defaultConfig
{ layoutHook = avoidStruts $ smartBorders $ myLayout
, borderWidth = 4
, normalBorderColor = "#000000" -- black
, focusedBorderColor = "#ff3f3f" -- reddish
}
Do you folks know how I achieve this effect? (is part 2. even possible?) Suggestions and pointers to extensions and/or existing configurations that achieve a similar effect greatly appreciated.

I solved pt. 1 using the Ambiguity constructor named OnlyFloat from XMonad.Layout.NoBorders.
import XMonad.Hooks.ManageDocks
import XMonad.Layout.NoBorders
myLayout = tiled ||| Mirror tiled ||| Full
where
tiled = Tall 1 (3/100) (3/5)
main = xmonad $ defaultConfig
{ layoutHook = lessBorders OnlyFloat $ avoidStruts $ myLayout
, borderWidth = 4
, normalBorderColor = "#000000" -- black
, focusedBorderColor = "#ff3f3f" -- reddish
}
I haven't addressed pt. 2. Furthermore, when I switch into a workspace, the border color of the focused window "flickers", since initially, the window is not focused (an thus its border is colored as per normalBorderColor), whereafter the window becomes focused (and thus its border gets the color focusedBorderColor).

Regarding part 2: Version 0.17.0 of the xmonad-contrib package introduced the new XMonad.Layout.VoidBorders layout modifier which removes borders just like XMonad.Layout.NoBorders does, but kind of permanently (the windows will retain their zero-width borders even when moved off of a VoidBorders-controlled workspace). This side-effect may or may not be a deal-breaker but it solves the "jumping" windows issue when switching workspaces.

Related

PyQtGraph How to zoom in using a button

I'm using PyQTGraph along with PyQT5, and I've added a GraphicsLayoutWidget, with mouse events to add markers.
canvas_ruler = pg.GraphicsLayoutWidget()
formLayout.addWidget(self.canvas_ruler)
plot_ruler = canvas_ruler.addPlot(name="Ruler")
plot_ruler.hideAxis('left')
canvas_ruler.scene().sigMouseMoved.connect(self.mouseMoved)
canvas_ruler.scene().sigMouseClicked.connect(self.mouseClicked)
plot_ruler.setMouseEnabled(x=True, y=False)
What I would like to add, are 2 buttons, to zoom in and zoom out, currently the mouse wheel event, does zooming in/out. But I want to disable that and add 2 buttons for it. I probably should:
setMouseEnabled(x=False, y=False)
But I don't know how to trigger the zoom using code, I couldn't find it's APIs, like sigMouseMoved.connect.
The nearest native thing pyqtgraph does that approaches this (AFAIK) is the zoom with the mouse wheel feature. The MouseWheelEvent() function in ViewBox achives this with a call to the ViewBox function scaleBy().
You can see the source for all inputs and more detail but the main one is s (scale) and center (center around which to zoom). Leave center as None to zoom around the center of the plot.
Pass a tuple of x and y zoom scales to the function to zoom, < 1 for in and > 1 for out. e.g.:
def handle_plot_zoom_buttons(self, in_or_out):
"""
see ViewBox.scaleBy()
pyqtgraph wheel zoom is s = ~0.75
"""
s = 0.9
zoom = (s, s) if in_or_out == "in" else (1/s, 1/s)
self.plot.vb.scaleBy(zoom)

Need Checkbutton with no checkmark AND flat border

I need to create a Checkbutton with indicatoron = FALSE (meaning no indicator should be drawn) and relief = FLAT (meaning border should be normal and not standout from its environment. I can't seem to get both working at the same time. Is there any way around this? Example code below:
def create_buttons(self):
self.zerozeroButton = Checkbutton(self.frame_buttons, indicatoron = FALSE, text = "00", command = self.zerozero, relief = FLAT)
Set the borderwidth to zero. Though, if you have no border and no indicator, I'm not sure how the user will know what the state of the widget is.
Or, perhaps you want the relief when selected but flat when deselected. If that is the case, leave the borderwidth and relief alone, but set offrelief to FLAT.

Display number in rectangle

Note that I am using Python3 and Phoenix.
I would like to display a number (double, but that does not matter now) formatted in some way (again, no matter what that way is) within a rectangle: almost a wx.StaticText but not editable by the user. This is to display some data coming from some hardware, such as a temperature.
Is there such a widget?
I tried with using the default wx.StaticText with a style but I must have done something wrong:
hbox = wx.BoxSizer(wx.HORIZONTAL)
title = wx.StaticText(parent, label=label)
title.SetLabelMarkup("<b>{}</b>".format(label))
hbox.Add(title, border=5)
value = wx.StaticText(parent, label="3.141592", style=wx.BORDER_RAISED)
value.SetWindowStyle(wx.BORDER_SIMPLE)
hbox.Add(value, border=5)
title = wx.StaticText(parent, label="\u2103")
hbox.Add(title, border=5)
Shows this on Linux (Fedora 24, GTK):
Wouldn't using a wx.TextCtrl set to read only do the job?
Temp = wx.TextCtrl(panel1, value="3.141592", style=wx.TE_READONLY)
Temp.SetBackgroundColour('green')
The simplest solution is to just use wxStaticText with a border style (e.g. wxBORDER_SIMPLE, ...). If you don't like the appearance this results in, it's pretty simple to make your own widget drawing whatever border you desire: just create a window, define its wxEVT_PAINT handler and draw the (presumably centered) text in it and a border outside of it.

Line numbering from text using gtk2hs

I'm working on a program that contains a text editor on it and will be used for programming (which means that the font is monospaced and has the same size in the entire text). As such, it would be useful if it were possible to see the number of each line (paragraph, not display line) at the side of the TextView widget.
In another question (GTK+ line numbering for Text View), it was said that the SourceView widget does the job, but this widget doesn't seem to exist in gtk2hs, so I'm stuck with TextView.
Does the library offer a simple solution to this problem, or do I have to do it the hard way?
The minimalist code for using a SourceView with numbered lines with Haskell and Gtk2Hs is :
import Graphics.UI.Gtk
import Graphics.UI.Gtk.SourceView
main :: IO ()
main= do
initGUI
window <- windowNew
set window [ windowTitle := "SourceView"
, windowDefaultWidth := 100
, windowDefaultHeight := 100
, windowResizable :=True ]
sview <- sourceViewNew
sourceViewSetShowLineNumbers sview True
containerAdd window sview
onDestroy window mainQuit
widgetShowAll window
mainGUI

h box alignment in gtk

hi every one i am trying to make a gui. in which i have placed a hbox in my window and 2 hboxes (hbox1 ,hbox2) inside the main hbox. but the problem is that the hbox1 and hbox2 share equal space is there a way through which i can give more space to hbox1 and less space to hbox2
here is my code
hbox = gtk_hbox_new(FALSE,1);
hbox1 = gtk_hbox_new(FALSE,1);
hbox2 = gtk_hbox_new(FALSE,1);
gtk_container_add(GTK_CONTAINER(hbox),hbox1);
gtk_container_add(GTK_CONTAINER(hbox),hbox2);
gtk_container_add(GTK_CONTAINER(window), hbox);
thanks
This is all explained in the GTK tutorial, in the "Packing Widgets" section.

Resources