How to set the size of tk_messageBox? - tcl

I am using a tk_messageBox with a lage message, so I would like to configure the layout of that message dialog.
I am using tk_messageBox like this:
set status [tk_messageBox -type yesno -icon warning -message "Here goes a text with 50 words"]
How can I set the width and height of tk_messageBox here?
Maybe there are some better alternatives for tk_messageBox?

You can't set the size of a tk_messageBox (that's functionality which doesn't fit with the way those dialogs work on Windows and OSX). You can try putting some of the message into the -detail option, which usually uses a smaller font.
Or you can try looking in the file msgbox.tcl of your Tk installation for the Tcl code that implements the message box dialog on Unix/X11. Hint: on that platform only, tk_messageBox is really an alias for ::tk::MessageBox. The name of the widget created by that script depends on the -parent option, but if that's absent, it's .__tk__messagebox. Knowing that, you should be able to use clever event handling to configure the toplevel widget in question. But this is not a nice solution, and won't work on either Windows or OSX (when build for Aqua instead of X11).

Is this what you had in mind?
import Tkinter
import tkMessageBox
window = Tkinter.Tk()
window.option_add('*Dialog.msg.width', 50)
tkMessageBox.showinfo("header", "Hello, World!")

.option_add may only work for linux operating systems, but you can control font, where the lines wrap, and the width of the box:
root.option_add('*Dialog.msg.font', 'Helvetica 24')
root.master.option_add('*Dialog.msg.width', 34)
root.master.option_add("*Dialog.msg.wrapLength", "6i")
(where "6i" is the length of the line in inches)

I use these settings, but haven't tested on other platforms beside X11
option add *Dialog.msg.wrapLength 10c
option add *Dialog.dtl.wrapLength 10c
Of course you can try other sizes than 10c (which stands for 10 centimeters).

Related

Increase text size in mars 4.5?

Im using the MIPs Mars 4.5 and Im trying to find out how to increase the size of text such as the menu bar etc.. Not the editor but the program itself.
Thanks
While there's no way within Mars to explicitly set the scaling, if you have a high dpi display and have everything in Windows scaled up, Windows' built-in compatibility can fix this.
The runMARS.bat calls javaw.exe -jar Mars4_5.jar
Assuming you've got java in your PATH...
Navigate to C:\ProgramData\Oracle\Java\javapath
Right click on javaw.exe, -> Properties
In the Compatibility tab, check Override high DPI scaling behavior
Select System for Scaling performed by
Now, running Mars with runMARS.bat will start it with proper scaling.
If java isn't in your path, do the above steps for whichever executable Mars4_5.jar is using. If you're not sure, the which javaw command might come in handy.
Also, Java9 properly supports hidpi screens, so this won't be a problem.
open mars,
1.click on settings -> editor...
2.select the font-size that you want
3.click on apply

How to properly insert windbg breakpoints on mshtml and MS IE 11?

I'm digging into MS Internet explorer 11 and mshtml.dll, lets be fast & clear : I'm investigating the "CTitleElement" class of "mshtml.dll" on windows 8.1, I want to set breakpoints on some functions in "CTitleElement" class to see what's going on inside this class (e.g : creating title element, getting title, setting title, getting title's length, etc ...)
I used windbg to attach the IE process, and here's what I did to set breakpoints :
0:013> bp MSHTML!CTitleElement::GetTitle
0:013> bp MSHTML!CTitleElement::SetTitle
0:013> bp MSHTML!CTitleElement::s_StringTable
0:013> bp MSHTML!CTitleElement::CreateElement
0:013> bp MSHTML!CTitleElement::TitleLength
and then running into IE with "g" command & opening the following simple html file :
<html>
<title>Hello There!</title>
</html>
but unfortunately, I did not get the desirable result, the debugger did not hit the breakpoints .
As I noticed, it's an unstable situation, because : "sometimes it got hit & sometimes not!"
I was think of ASLR and the type of breakpoint I just set ("bp"), disabled ASLR by installing EMET & disabling all memory protections, but I still unable to get the result in a reliable manner .
Any suggestion to solve this problem?
regards.
I don't think ASLR has got anything to do here. You are setting the break points using function names and not addresses. The addresses can change but the function names would still remain the same :)
to ensure that you do not miss out because of the child processes created by IE (as mentioned by Sesa)
Launch windbg.
From the file menu choose "Open Executable" OR Ctrl+E.
give the path of iexplorer.
make sure you have option "Debug Child Processes also" checked.
make sure you have the symbols correctly loaded.
To ensure your break-points persist across debugging sessions use "bu" instead of bp.
check that all break-points show up everytime using "bl"
I'm just speculating what is going on. Perhaps when you first load the page in IE it fully renders it. Next time, the page may not be fully rendered because the result of previous run used and an other code path is executed that doesn't hit your breakpoint.
Did you try force refresh Ctrl+F5?

define hotkeys minimize Windows on the sublime text 2

I want to create a hotkey to minimize and restore the sublime but even the Main.sublime-menu is undefined !
{
"keys": ["ctrl+shift+w"], "command": "toggle_minimize_restore_window"
}
I apologize if there is a mistake in the text, because my English is not good too :)
Toggling the state of Sublime Text windows is not something that is possible to do at the moment - you can not maximize, minimize, restore, or resize a Sublime Text window using Sublime Text commands. There have been feature requests for this but you can not do it at present.
If you are using Linux, you might be able to achieve this functionality by writing a shell script which uses wmctrl to achieve that functionality and then assign the script to a global hotkey. No doubt there are ways of doing the same thing with OS X and Windows but I do not know what the equivalents would be.
You can try using the built-in window's keystrokes in order to minimize and maximize.
windows key + down (arrow) = minimize the window.
windows key + up (arrow) = maximize the window.
You can try with Mac with Command.
If you want to minimize for a customized position, you can detach the tab adjust it as you wish. Next time you minimize the window, it will appear in this last position you set.

How to make ruler always be shown in Sublime text 2?

I use Sublime Text 2 and want a Ruler to be shown in every file with specific line-height. But I have to show it manually in every file.
Go to Sublime Text > Preferences > Settings - User
Add a "rulers" setting with the lines you want for the ruler:
// Adds a single vertical ruler at column 80
"rulers": [80],
If you want multiple rulers, separate the values with a comma:
// Adds two vertical rulers: one at column 80 and one at column 120
"rulers": [80, 120],
Rulers not showing? Rulers are only shown when using a monospace font, which is the default font for Sublime Text. Ensure you are using a monospace font if the settings above don't work for you.
Edit the "rulers" value in the default settings to contain the column number you want the ruler to be displayed on, and it will persist.
Never edit Settings - Default; edit Settings - User instead. If you upgrade your SublimeText version you will lose all of your settings because Settings - Default will be overwritten.
In the Packages folders the 'User/' folder will be ignored between upgrades of SublimeText, the settings here will be persistent.
To enable the persistent rulers in any document, add the settings in Defaults - User:
{
"rulers": [75, 80, 85]
}
This example will display 3 rulers, at 75, 80 and 85 chars length.
As others have stated before me, select Preferences -> Settings-User and change
"rulers": [],
to
"rulers": [80],
in order to display one ruler at column 80.
Now for the rub, it seems that one must use a monospaced font in order to display rulers so you'll also need to change
"font_face": "",
to
"font_face": "Monospace",
or any other monospaced font.
Thinking about it, this makes sense. If different characters have different widths, then the ruler could potentially not be a single line, but a bunch of annoying line segments. I noticed this while using the default font and my column numbers were not the same for the same vertical position. At the same time, my fancy ruler was specified but not displayed. Changing the font to Monospace solved both problems.
While the answer by Ross Allen is great, it isn't the most convenient if you find yourself wanting to toggle the rulers on and off or change the width at various points while using Sublime.
Luckily, someone made a Package that allows you to do this.
https://packagecontrol.io/packages/QuickRulers
The package works in both Sublime Text 2 and 3.
Install Instructions:
Install PackageControl
Open PackageControll (e.g. via ⌘ + SHIFT + P)
Type "Install" and select "Package Control: Install Package"
Type "QuickRulers" and hit Enter to install the QuickRulers package.
You can access the command (quick_rulers) through several different means, but by default it is loaded in Omnisearch via "QuickRulers: Open Panel". (i.e., Hit ⌘ + SHIFT + P and type "QuickRulers: Open Panel")
If you change font, ruler will not be displayed. E.g. I set "font_face": "Lucida Grande", and ruler disappeared.
I just had this problem and noticed that the my ruler was only showing up when I was slightly scrolled to the right horizontally. Turns out the reason it was disappearing was because I was slightly zoomed in. Press Cmd+0 to make sure you are zoomed to the default 100% size before trying other things in case this is also your issue.
(I am using Sublime Text 3)
"editor.rulers" worked for me:
{
"editor.rulers": [72, 80]
}
instead of
{
"rulers": [72, 80]
}
Posting here so that it may help for some peoples.
P.S. I am using vscode on Macbook.

How can I embed TkCon (or other Tk console) as a widget?

I want to make a Tcl/Tk application that is--mostly--a conventional menus-and-buttons direct manipulation tool, where most of the interaction is through a graphical interface implemented in Tcl/Tk.
However, for certain advanced uses (and debugging), I'd like to have a widget (subwindow) within the main window that contains a Tk console where I can type commands, see output, and otherwise control the application.
It seems easy enough to start TkCon (or wish) and get one top-level window, then create my application interface in a separate top-level window. The application will work fine that way, but I'd like the two windowso be part of the same layout, to move together, to support resizing, etc.
Is there an easy way to do this with TkCon?
I'd also like the TkCon window to be able to display messages that bubble up from within my application (e.g., debug output). Some messages would be generated by Tcl code; others by C code that makes up part of my application. I don't need to capture stdout as such--I'm willing to call a special-purpose function to deliver the messages--but it's not clear what's the most effective way to to get them to display like that.
For tkcon specifically see Donal's answer. I will add however that you can embed the Tk built-in console that is used on Windows. This script is available on non-Windows and can be made to embed into a tabbed notebook page for example.
See tkchat_console.tcl for an example of this - the file loads the Tk console.tcl file and the ::tkchat::EmbeddedConsoleDemo function at the bottom shows how you might use this.
The following code works for me:
set f [labelframe $p.console -text "Interactive:"]
frame $f.test -container 1
namespace eval ::tkcon {
set OPT(exec) {}
set PRIV(root) .tkcon
set embed_args {}
}
option add *tkcon.Use [winfo id $f.test] interactive
package require tkcon
tkcon::Init
This code addse -use option to tkcon toplevel via "X11 options". ::tkcon::embed_args is also vital.
Reading the documentation I only see ways to make it work officially as its own toplevel window. (In particular, tkcon new doesn't take any arguments…) So we're talking a hack to get what you want.
If you've got Tk 8.6 and aren't on OSX (or are using an X11-based build on that platform), you can morph the toplevel into a frame with wm forget and embed that way, but I don't know if the lack of control over the widget name in that case will hurt.
Otherwise, if you've got BLT available I believe that has the ability to reparent widgets. I've never tried doing that so this is hearsay, but it might be able to put a toplevel inside another widget.
Getting more hacky, you could edit the tkcon sources so that you can specify the -use option to the toplevel it creates. That would let you place it in another widget (a frame with the -container option turned on; you'd have to piece things together with winfo id too) but again, it's a bit complex and I don't know what the consequences of doing this are on your platform. This should work on older versions of Tk (it was the foundation of how the Tcl/Tk browser plugin functioned).