Saturday, 15 February 2014

tcl - Display the tail of a filename in an entry box -


I type the dialog box using ttk :: entry widgets to promptly point to myself for the file name I am I save the user's last input in such a dialog and after displaying it, it displays it as default.

When I am longer than the full filename entry box, display some of the left-hand letters that are usually a less interesting part of the file name and I display the correct letter.

I found that attempts to use $ entryWidget xview did not work very well immediately - it was nothing, which I believe is due to some race - So I have taken it for writing

  $ $ $ Visit after the entry xView moveto 1.0   

Is there a better way, and if not, So what's the best option for N? I do not like the number of magic and as far as I remember, <0> after 0 did not work properly and neither after being inactive

Here's an example showing the problem

  package is required [ttk :: entry .ent] Pack $ ent-fill both -expand yes $ ent inserted "quick brown fox on lazy dog Jumps "after 1000 $ env xView moveto 1.0 set BTN [TTK :: button .btn -text dismissed -armand] pack $ btn-fill file N- expand Yes   

without There are no errors after 1000 line 5 (?), And has no effect. If I try after 10 there is no effect if I leave after n and update idletasks; $ Ent xview moveto 1.0 has no effect.

"No effect" means that the dialog box shows "Quick Brown Fox Jump", the remaining remaining strings are hidden, with the above code, it shows that initially, but each other That is, in fact, coded as expected), it displays "hidden jumps on the dog" with the hidden rest, to be able to see the unsuswed text to the user, but it is undesirable. Can not work to avoid any other way by choosing a magical number of milliseconds to test.

This is a very difficult problem, it seems more than ever. The point is that instead of processing the end of the data, to understand the content enough, many unnecessary events (which take the amount of uncertain but non-zero time) process, and it is processed <( & Lt; map & gt; and configure & gt; ) P> [edit] : It has come to know what you need to do, in the drawing process actually late & lt; Expose & gt; Postponement is to postpone the adjustment> View of the event where the window system actually asks for things to appear on the screen. (There is a complex series of events that are actually directed to give a window to the screen, indicating that the window is visible, & lt ; Configure & gt; is being informed about the change in window size, and is actually a request to draw something. )

  set Ent [ttk:: entry .ent] Pack $ FF to fill -Expand Yes $ Ent Daw "The quick brown fox jumps on the lazy dogs" at the end of the lane "$ INF < Expose & gt; {# Must! Unregister this event handler! Bind% w & lt; Expose & gt; {} # Content% w xview [% w index end]} set btn [ttik :: button. BTN -Text "Dismiss" -Amand Exit] $$ Btn on Pack -File to Fill - Yes Yes   

The difficulty is that we only ago and event (as much as is given on the life of one application, at the lower level of the implementation of this program, an underlying handler for this event Too, which actually draws Double Bufber). This means that we need to include a D-registration (otherwise the window will be kept in a tap till the end).

This code only works for the content, time has shown a window. Then, to move it, call ttk :: entry :: $ ent end (which is the use of ttk :: entry for that purpose).

No comments:

Post a Comment