Without any windows on the screen, I have the beautiful bars (top and bottom) with all the information I need (including the app launcher). I have no idea which bar this is, but I'm guessing the top one is the standard gnome bar.
Once I launch any window, the bars are hidden below the windows.
Is there any way I can fix this? I'd love to have the two bars always visible on the screen.
Here is my xmonad.hs:
import XMonad
import XMonad.Hooks.Script
import XMonad.Util.EZConfig
import XMonad.Layout.NoBorders
import XMonad.Config.Gnome
main = xmonad $ gnomeConfig {
terminal = "gnome-terminal",
modMask = mod4Mask,
layoutHook = smartBorders (layoutHook defaultConfig),
startupHook = do
execScriptHook "startup"
spawn "/usr/bin/xcompmgr"
}
`additionalKeys`
[((mod1Mask, xK_p), spawn "dmenu_run")]
I've added the manage docs extension
import XMonad.Hooks.ManageDocks
and changed the layoutHook line to this:
layoutHook = avoidStruts (Tall 1 (3/100) (1/2) ||| Tall 1 (3/100) (1/2)),
And now it works. The docs are showing and working as intended. I removed the smartBorders because I couldn't get the two to work together (very limited knowledge of Haskell), but it didn't make any difference.
Related
I can't get a Tkinter file dialog box to close. This Tkinter file dialog box closes just fine if there is no input statement downstream. But with it, it does not close, and crashes the app.
Through a process of elimination, it seems input() downstream from the root.destroy() command is interfering with the window closing.
Anyone have a fix?
Here's the code:
import tkinter
from tkinter import filedialog
###### THIS CODE WORKS #########
# Make a top-level instance and hide since it is ugly and big.
root = tkinter.Tk()
root.withdraw()
# Make it almost invisible - no decorations, 0 size, top left corner.
root.overrideredirect(True)
root.geometry('0x0+0+0')
# Show window again and lift it to top so it can get focus,
# otherwise dialogs will end up behind the terminal.
root.deiconify()
root.lift()
root.focus_force()
# get the file path of the trades to load.
new_file_path = filedialog.askopenfilename()
# Get rid of the top-level instance once to make it actually invisible.
root.destroy()
###### WHEN INPUT IS ADDED IT DOESNT WORK######
input('Testing testing testing ')
I've tried adding a time.sleep(1) just after root.destroy.
I've tried the solution here:
Tkinter askopenfilename() won't close
I'm using OSX 10.11.4 with Pycharm.
When I call the basic command:
from tkinter.filedialog import askopenfilename
filename = askopenfilename()
A little window pops up behind the selector screen.
Is there a way to remove this?
It pops up because you need at least a "root" window for each tkinter application. In your case, you aren't creating any root window explicitly, so askopenfilename creates it automatically for you. One solution would be to create the root window explicitly and then hide it, something as follows
from tkinter.filedialog import askopenfilename
from tkinter import Tk
Tk().withdraw()
filename = askopenfilename()
I'm working on a small educational piece of work, I create a window and its supposed to cover the entire monitor. However "special" areas are not being covered as seen in the screnshot at bottom. My window is a solid red with no menu bar scroll bar etc, is there anyway to make this cover the top menu bar and the dock. In my screenshot I am testing on Ubuntu and Mint, this is consistent behavior on Gtk OS's I need to be ablve ot set my window so it covers all things is this possible?
I tried gdk_window_fullscreen but it's not doing anything, not even fullscreen, do you think its because I'm running this function from another thread? How would I know if this function needs to be run from the main thread?
Incomplete coverage on Ubuntu:
Incomplete coverage on Mint:
Code Tried
A frameless window is opened using Firefox code from main thread:
var aEditorDOMWindow = Services.ww.openWindow(null, core.addon.path.content + 'panel.xul', '_blank', 'chrome,width=1,height=1,screenX=0,screenY=0', null);
Now after load of it completes then the GdkWindow* of this window is obtained on the main thread and passed to another thread as a string
The thread now takes the string to GdkWindow* then that to GtkWindow*
var gdkWinPtr = ostypes.TYPE.GdkWindow.ptr(ctypes.UInt64(aHwndStr));
var gtkWinPtr = ostypes.HELPER.gdkWinPtrToGtkWinPtr(gdkWinPtr);
The thread then executes gtk_window_set_keep_above because if there was another app was focused it will focus this guy, and it will keep him on top of existing full screen windows
var rez_topIt = ostypes.API('gtk_window_set_keep_above')(gtkWinPtr, true);
The thread used to then run gtk_window_present but I removed it as I noticed it would crash the app, this was the code:
var rez_focus = ostypes.API('gtk_window_present')(gtkWinPtr);
EXPERIMENTAL STUFF I tried but it didnt work to make the window cover the special UI:
ostypes.API('gdk_window_set_type_hint')(gdkWinPtr, ostypes.CONST.WINDOW_TYPE_HINT_SPLASHSCREEN);
ostypes.API('gtk_window_set_position')(gtkWinPtr, ostypes.CONST.GTK_WIN_POS_NONE);
var geom = ostypes.TYPE.GdkGeometry();
geom.max_width = aOptions.fullWidth;
geom.max_height = aOptions.fullHeight;
var rez_geo = ostypes.API('gtk_window_set_geometry_hints')(gtkWinPtr, null, geom.address(), ostypes.CONST.GDK_HINT_MAX_SIZE);
Now the thread work is done and it goes to main thread. Now the main thread uses firefox javascript to move the window to top left most origin (which i calculated earlier with Gdk calls) and also sets the width and height of this window to that calculated of all the monitors (i did this earlier with other gdk calls)
aEditorDOMWindow.moveTo(collCanMonInfos[0].xTopLeft, collCanMonInfos[0].yTopLeft);
aEditorDOMWindow.resizeTo(collCanMonInfos[0].nWidth, collCanMonInfos[0].nHeight);
This results in the window SOMETIMES covering all monitors, other times just the one it opened on. And it never covers special UI like the taskbar/dock/menubars.
If you can please advise on how to acheive a window that fully covers everything that would be very appreciated, I'm trying to teach some people some stuff and I ran into a mess.
Here is a youtube video of the addon I am making: https://www.youtube.com/watch?v=aJM5NQK67N4
I discontinued using gdk_fullscreen because when it worked intermittently it would not allow the window to expand outside the one monitor.
Panels are usually implemented with struts, and window managers can decide never to allow windows to cover them; that's one of the reasons why the whole idea of "full screen window" was introduced: it gives the window manager a hint that the window that requested to be full screen should cover all other windows; have no decorations; and also cover all eventual "system" components, like panels.
I am trying to create a shell script in which I automatically run a video fullscreen.
It has no way to quit unless I shut down the Raspberry Pi.
What is a small script I can use to bind something like "!" to quit the application?
I searched Google for 'omxplayer exit fullscreen' and found this answer, originally posted by dom on the RaspberryPi forum:
Changing TV modes does lose any content on them (e.g. the console
framebuffer).
You can provoke the console framebuffer to be recreated with: fbset
-depth 8 && fbset -depth 16
Add that to the end of a script that launches omxplayer.
(for extra points read the depth before launching omxplayer and set it
back to original value afterwards)
You might also want to check this issue report on omxplayer's GitHub.
I am not sure if this will work but potentially you could use a tkinter window that you make non visable.
#import the tkinter module for the GUI and input control
try:
# for Python2
import Tkinter as tk
from Tkinter import *
except ImportError:
# for Python3
import tkinter as tk
from tkinter import *
def key(event):
#create a function to control closing the window in this case
if event.keysym == 'Escape':
#this currently closes the window however you could add to root.destroy() with
#the relevant command for closing the video.
root.destroy()
#initiate root window, remove it from view, bind all keys (you could just
#bind '<Escape>' if preffered
root = Tk.tk
root.withdraW()
root.bind_all('<Key>', key)
i am aware this isnt a specific design to your problem however it will let you bind the escape key like you wished. this stopped the whole application in my example however you may have to include extra lines to ensure each part of your application is correctly ended.
How do I change the application title in the Mac menu bar programmatically (after starting the application)?
I know that I can set it before running the program via CFBundleName in the Info.plist file. However, I need to change it after initializing the application. Manipulating my own Info.plist also won't work.
There is no official API to do so, but in this discussion someone hinted that there is a secret function call that changes the bundle name / menubar title:
"There is SPI you can use if you look hard enough around for it, but
I'm not going to point anybody to it unless they can justify why they
need to use it :-)"
I think Java uses something similar, too. So what's the secret API?
OK, I've found a way. This is the code in Python (taken from here). It could use some cleaning and some error handling, but it works. The key is the undocumented CPSSetProcessName from ApplicationServices.
def _osx_set_process_name(app_title):
""" Change OSX application title """
from ctypes import cdll, c_int, pointer, Structure
from ctypes.util import find_library
app_services = cdll.LoadLibrary(find_library("ApplicationServices"))
if app_services.CGMainDisplayID() == 0:
print "cannot run without OS X window manager"
else:
class ProcessSerialNumber(Structure):
_fields_ = [("highLongOfPSN", c_int),
("lowLongOfPSN", c_int)]
psn = ProcessSerialNumber()
psn_p = pointer(psn)
if ( (app_services.GetCurrentProcess(psn_p) < 0) or
(app_services.SetFrontProcess(psn_p) < 0) ):
print "cannot run without OS X gui process"
print "setting process name"
app_services.CPSSetProcessName(psn_p, app_title)
return False
If you call it right away, it changes the process name in the Activity Monitor. I had to call it after a small timeout for some reason to also change the Menubar name:
import gobject
gobject.timeout_add(100, _osx_set_process_name, "MyTitle")
Note that if you combine this with an .app package you can get a really nice system integration of a python app. While you can change the Icon, the Finder display name, ..., all methods I tried leave the CFBundleName (the one in the Menu bar) to "Python". (This answer for example only changes the long name (displayed over dock icons). There are plenty others that almost work.)
While this answer gives the intended result, it's not very elegant. I'd appreciate some insight into why I need the timeout... I think Python or pygtk changes the process name itself when I first import gtk or run the main loop.