|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uchicago.src.sim.gui.AbstractGraphLayout uchicago.src.sim.gui.LayoutWithDisplay uchicago.src.sim.gui.FruchGraphLayout
public class FruchGraphLayout
Positions nodes in layout according to iterations of an
implementation of the Fruchmen-Reingold graph layout
algorithm. See the docs to updateLayout
for the details.
The FruchGraphLayout implements the ActionListener interface to interrupt the layout. This breaks out of the algorithm implementation as soon as possible, but will rescale the display if appropriate. You can have the FruchGraphLayout listener for RePast toolbar button presses by including something like the following code inside your model class.
This will cause the FruchGraphLayout graphLayout to interrupt its layout
whenever stop, pause, or exit is pressed.
graphLayout = new FruchGraphLayout(...);
Controller c = (Controller)getController();
c.addStopListener(graphLayout);
c.addPauseListener(graphLayout);
c.addExitListener(graphLayout);
Note The FruchGraphLayout is not particularly fast, although it is faster than the KamadaGraphLayout. It is not meant as a "true" visualization tool, but rather is intended only to provide the modeler with "sense" of the network. Real analysis and visualization should be done in a tool like Pajek.
| Field Summary |
|---|
| Fields inherited from class uchicago.src.sim.gui.LayoutWithDisplay |
|---|
display, isEventThread |
| Fields inherited from class uchicago.src.sim.gui.AbstractGraphLayout |
|---|
height, nodeList, update, width |
| Constructor Summary | |
|---|---|
FruchGraphLayout(int width,
int height)
Constructs new FruchGraphLayout. |
|
FruchGraphLayout(java.util.List nodes,
int width,
int height)
Constructs new FruchGraphLayout. |
|
FruchGraphLayout(java.util.List nodes,
int width,
int height,
DisplaySurface surface,
int updateEveryN)
Constructs new FruchGraphLayout. |
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent evt)
Implements the ActionListener interface. |
void |
randomizeLayout()
Randomly positions nodes on layout. |
void |
setAnimateTransitions(boolean animateTrans)
Sets whether the completed layout (and each component as it is finished) will smoothly transition to its new location. |
void |
setPad(int p)
Sets the number of pixels to shrink radius by. |
void |
setRandomSeed(int seed)
Sets the Random seed used in the intial random placement of the nodes. |
void |
setRescaleLayout(boolean rescale)
Sets whether the completed layout will be resized to exactly fill the display window. |
void |
setUpdateEveryN(int updateEveryN)
If the layout has been passed a display to update, and updateEveryN is greater than 0, the layout will update the display after every Nth pass through the algorithm. |
void |
updateLayout()
Positions nodes in layout according to a modified implementation of the Fruchterman-Reingold graph layout algorithm. |
| Methods inherited from class uchicago.src.sim.gui.LayoutWithDisplay |
|---|
setDisplay, updateDisplay |
| Methods inherited from class uchicago.src.sim.gui.AbstractGraphLayout |
|---|
appendToList, appendToList, getHeight, getNodeList, getUpdate, getWidth, setList, setUpdate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FruchGraphLayout(int width, int height)
width
- the width of the display in pixelsheight
- the height of the display in pixelspublic FruchGraphLayout(java.util.List nodes, int width, int height)
nodes
- the list of nodes to be optimisedwidth
- the width of the display in pixelsheight
- the height of the display in pixelspublic FruchGraphLayout(java.util.List nodes, int width, int height, DisplaySurface surface, int updateEveryN)
surface
- the display surface to updateupdateEveryN
- how often to update the displaynodes
- the list of nodes to be optimisedwidth
- the width of the display in pixelsheight
- the height of the display in pixels| Method Detail |
|---|
public void setPad(int p)
p
- the number of pixels to shrink bypublic void setUpdateEveryN(int updateEveryN)
updateEveryN
- how often to update the displaypublic void setRescaleLayout(boolean rescale)
rescale
- sets if layout will be rescaledpublic void setAnimateTransitions(boolean animateTrans)
animateTrans
- sets if transitions will be animatedpublic void setRandomSeed(int seed)
seed
- the random seed for the initial random placement of the nodespublic void randomizeLayout()
public void updateLayout()
setRandomSeed
method. The random stream for this initial
layout is separate from RePast's default random stream.See, Fruchterman, T.M.J and Reingold, E.M. (1991) "Graph Drawing by Force-directed Placement" in Software-Practice and Experience, Vol 21(11), 1129-1164 Modified for code optimization. (Skye Bender-deMoll) Note at this point, this implementation does not take into account edge strengths
pseudo code of implementation of Furchterman-Reingold Algorithm
-----------------------------------------
As implemented in Pajek, the algorithm makes initialIter (10) through
the algorithm before starting the cooling function. If this is the
first layout, each nodes is given a random initial position.
while temp > 0.5 and passes < maxIterations (500)
//calculate repulsive forces between each node
for v = 0 to numberOfNodes
for u = v+1 to numberOfNodes
calculate the distance vector between the positions of v and u
calculate a displacement displaceVec = (distVec/|distVec|)
* repulsion(|distVec|)
add displaceVec vector to v's displacement vector
subtract displaceVec from u's displacement vector
end
end
//calculate attractive forces
for e = 0 to numberOfEdges
get the nodes attached to the edge (v and u)
calculate the distance vector between the positions of v and u
calculate a displacement displaceVec = (distVec/|distVec|) * attraction(|distVec|)
subtract displaceVec vector from v's displacement vector
add displaceVec to u's displacement vector
end
calculate each nodes's displacement, but limit max displacement to temp
//decrease temperature parameter
coolTemp()
if this is an Nth pass, update the layout on screen
at the end, go over all the nodes to find the max and min of the coords,
rescale all coords so that network will fill the display
end while
//repulsion function
repulsion(distance) = (distance^2)/optimalDistance
//attraction function attraction(distance) =
(optimalDistance^2)/distance^2 (formula used in pajek)
//cooling function
coolTemp(temp) = unchanged for initialIter iterations, temp/1.1
//optimal distance optimalDistance = 0.46*Math.sqrt(((width *
height) / (nodeList.size()+1)))
Additional comments: Because the original algorithm repositions the nodes in a deterministic order, highly structured / regular networks may exhibit rotations drift during the layout.
updateLayout
in interface GraphLayout
updateLayout
in class AbstractGraphLayout
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
actionPerformed
in class AbstractGraphLayout
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


| 009:031 Khan | : |
They (Jews and Christians) took their rabbis and their monks to be their lords besides Allah (by obeying them in things which they made lawful or unlawful according to their own desires without being ordered by Allah), and (they also took as their Lord) Messiah, son of Maryam (Mary), while they (Jews and Christians) were commanded [in the Taurat (Torah) and the Injeel (Gospel)) to worship none but One Ilah (God - Allah) La ilaha illa Huwa (none has the right to be worshipped but He). Praise and glory be to Him, (far above is He) from having the partners they associate (with Him)." |
| 009:031 Maulana | : |
They take their doctors of law and their monks for Lords besides Allah, and (also) the Messiah, son of Mary. And they were enjoined that they should serve one God only -- there is no god but He. Be He glorified from what they set up (with Him)! |
| 009:031 Pickthal | : |
They have taken as lords beside Allah their rabbis and their monks and the Messiah son of Mary, when they were bidden to worship only One Allah. There is no Allah save Him. Be He Glorified from all that they ascribe as partner (unto Him)! |
| 009:031 Rashad | : |
They have set up their religious leaders and scholars as lords, instead of GOD. Others deified the Messiah, son of Mary. They were all commanded to worship only one god. There is no god except He. Be He glorified, high above having any partners. |
| 009:031 Sarwar | : |
They (unconditionally) obeyed the rabbis and the monks and worshipped the Messiah, son of Mary, as they should have obeyed God. They were commanded to worship no one besides God who is the only God and who is too exalted to be considered equal to any idols. |
| 009:031 Shakir | : |
They have taken their doctors of law and their monks for lords besides Allah, and (also) the Messiah son of Marium and they were enjoined that they should serve one Allah only, there is no god but He; far from His glory be what they set up (with Him). |
| 009:031 Sherali | : |
They have taken their priest and their monks for lords besides ALLAH. And so have they taken the Messiah, son of Mary. And they were not commanded but to worship the One God. There is no God but HE. Holy is HE far above what they associate with Him ! |
| 009:031 Yusufali | : |
They take their priests and their anchorites to be their lords in derogation of Allah, and (they take as their Lord) Christ the son of Mary; yet they were commanded to worship but One Allah: there is no god but He. Praise and glory to Him: (Far is He) from having the partners they associate (with Him). |
Concepts/Themes Covered: الديانات > بنو إسرائيل > أحبارهم Religions>Children of Israel>Their Priests الديانات > بنو إسرائيل > أقوالهم و جرأتهم على الله و الأنبياء Religions>Children of Israel> Their Saying and their Daring against Allah and the Prophets الديانات > النصارى > أقوالهم وجرأتهم على الله Religions>The Christians>Their Sayings and their Daring against Allah الديانات > النصارى > الرهبان Religions>The Christians>The Priests
This tool uses eight English parallel translations for the Holy Quran imported from Mr. Clay Smith. You can also visit Qurany Concepts for browsing the Quran themes or topics. If you want to search the Holy Quran for keywords, please visit Qurany Keywords.


Legal Resource Registry
— Courts, Tribunals, and their Publishing Channels —
Home
Jurisdictions
Updating a Jurisdiction
Developers
Denmark
Viborg
Landsret
Aalborg
Aarhus
Grenaa
Haderslev
Herning
Hjørring
Hobro
Holstebro
Horsens
Randers
Sønderborg
Thisted
Tønder
Viborg


Hello there! I am Suyash Awasthi. I am a student living in Pune,India. My hometown is Lucknow, India where I did my early studies.
I am a full-stack enthusiast paving my way to excellence in the field. My other interests are writing poems and stories, reading novels, singing and sketching.
I am a Full-stack enthusiast. I have interest in animation also both with coding and software. I have made some animations with javascript and some with software. Both are available on my github profile My Profile
I have a knowledge of HTML5, CSS3, Bootstrap 4, SQL, PHP, JavaScript, ECMAScript, Jquery, AngularJs and various other javascript libraries. My main strength is JavaScript which I love to explore.


This page displays various statistics based off analysis which was performed upon a dataset filled with Reddit comments. Below you will find the users who left the most comments in the dataset, the proportion of Negative/Neutral/Positive comments within the dataset, a ranking of the most Positive and Negative subreddits and the most frequent words throughout.
| Top 5 Positive Subreddits: | Top 5 Negative Subreddits: |
|---|---|
| /r/{{ item }} | {% endfor %}


Custom Control Panel (explanation) |
|
| Description | This example demonstrates, in the most basic way, the ability to control the starting and stopping of playback using HTML elements in a Web page, rather than the actual player control panel. |
| Methods Used | magicEmbed, onPause, onPlay, onStop, pause, play, setVolume, stop |
| Skill Level | Beginner |
| Start... |


Preparation time
overnight
Cooking time
30 mins to 1 hour
Serves
Makes 18-20 fritters
These tasty salt cod nuggets are hugely popular in Portugal. Try them with a glass of white wine.
Soak the salt cod in cold water for 24 hours, changing the water three or four times.
Rinse the salt cod, put it in a saucepan, cover with the milk and bring to the boil. Turn down to a simmer and cook for 15 minutes, or until tender.
Meanwhile, boil the potatoes for 15–20 minutes, or until tender. Drain and cool a little before slipping off the skins, then mash until fluffy.
Remove the cod from the milk and leave to cool. Remove any skin and bones and put the fish in a food processor. Add the oil, onion and garlic and pulse to a paste.
Put the paste in a large bowl and mix with the mashed potato, herbs, pepper and egg. The mixture should be quite stiff. Shape the mixture into rugby-ball shapes and set aside, you can do this with your hands or using two dessertspoons to quenelle the mixture.
Heat the sunflower oil in a large, heavy pan to 165C, using a temperature probe or sugar thermometer to check (CAUTION: hot oil can be dangerous. Do not over-fill the pan or leave unattended).
Fry the fritters in small batches for 2–3 minutes, until rich golden-brown. Remove and drain on kitchen paper. Serve immediately with lemon wedges and olives.


please wait...
The NDA Generator has been installed successfully!
You can access the files in the Automated NDA Generator folder created in your Drive
Error on install the NDA Generator


--- layout: page title: Frequently Asked Questions permalink: '/faq/' --- {% for faq in site.faqs %} {% assign anchor = faq.path | replace: '_faqs/', '' | replace: '.md', '' %}


Time To Find Out Our Akan Names
Start by clicking The Guide Button.
The FindOut App is a multipage website consisiting of; the landing page, the App page and the Guide page. It is a project that manipulates birthdates to output suitable Akan names. The project has a guide page to aid and enhance clients’ experience with the app. Furthermore, this project is not limited to specific dates or centuries as it is capable of calculating anyone’s Akan name. Akan names are derived from Ghanaian naming culture, therefore, this app enables you to know your supposed Ghanaian name.


Draw an alphabet or a digit in the left box. The predicition and its probability will be shown in the the right box.
This is a very basic end-to-end Machine Learning application. Hereunder a non-exhaustive list of functionalities that could be added.


@apartment.location, @apartment.address
@apartment.title
| Apartman: | @apartment.name |
| Ulica: | @apartment.address |
| Cijena: | @apartment.price |
| Broj osoba: | @apartment.capacity |
| Broj kreveta: | @apartment.beds |
| Kvadratura: | @apartment.area m2 |
| Sprat | @apartment.floor |
Mapa
Slicni apartmani
@apartment.capacity Osoba
@apartment.rooms Sobe


kthoom is an open source project. There is no legal entity (company) associated with this project, only developers who donate their time.
This project does not collect any information about our users or anything they read with kthoom. Since we do not track our users, to follow any privacy changes to kthoom you can follow this Atom feed for changes. Basic app activity is tracked as noted below via Google Analytics.
This project does not use browser cookies. It uses Browser Local Storage to Save your settings.
kthoom consists solely of client-side code (a HTML page, its stylesheet, and associated JavaScript files). kthoom does not talk to a server except as described below:
If you are uncomfortable with kthoom using Google Analytics or accessing servers over the network, it is totally within your rights to clone the github repository, remove the GA code from the HTML, and then run a local web server to host your own copy to read comic books on your local hard drive.


Preparation time
less than 30 mins
Cooking time
30 mins to 1 hour
Serves
Serves 6
Simon Rimmer's Spanish style one-pot supper is full of flavour and quick to prepare.
Heat half of the vegetable oil in a large pan. Add the chicken thighs and fry, turning frequently, until lightly browned all over. Remove from the pan and keep warm.
Add a little more oil to the pan, then add the onion, garlic, carrots, celery and chilli and cook for five minutes. Add a splash of red wine and simmer until reduced by half.
In another pan, heat the remaining oil and fry the chorizo for 2-3 minutes. Add the sherry and cook until the chorizo is crisp. Set aside.
Add the can of chopped tomatoes to the pan with the vegetables and bring to the boil. Cook for five minutes, then add the stock and bring back to the boil.
Add the browned chicken, the chickpeas and crisp chorizo and simmer for 20-25 minutes, or until the chicken is completely cooked through. Season, to taste, with salt and freshly ground black pepper.
Sprinkle with chopped parsley and serve with crusty bread.


KnowRe web development curriculum for noobs
- 26 commits
- 2 Branches
- 0 Releases
- 1 Contributor
| Part0. git/Quest 0. Hello, got | Quest 0. Added checklist | 19 hours |
| old | New curriculum 2016 - started | 5 days ago |
| License | New curriculum 2016 - started | 5 days ago |
| README | ... | 19 hours |


[Life Update] A New Direction With Halo Platform
Wait What? You’re Leaving AFCU?
Yes, after five wonderful years I am moving to a new company to work full time. I have truly valued my time at AFCU (Arkansas Federal Credit Union) and wouldn’t trade it for anything. The friends and colleagues I have met, made, and continue to connect with are invaluable. Thanks to AFCU I have become a stronger and better prepared developer to take my next step.
The decision to leave wasn’t easy, and I didn’t do it lightly. If you are considering a change in careers/jobs/anything make sure you consider everything that it will affect.
Change is scary. Some people think I’m crazy to walk away from a very secure job to a job in crypto currencies when it is so new and still very miss understood. I’ll admit that I was hesitant, but the opportunity is one that I just couldn’t pass up. I’m going to be helping to create something new that the world has never seen before. That is awesome, and worth it.
Ok So What Is Halo Platform?
I’m glad you asked, and actually everyone has been asking me that. It’s true that you most likely have not heard of them before, and don’t feel bad. Unless you are involved in crypto currencies you wouldn’t have seen them.
Halo Platform is a new crypto currency, a new trading platform, a new chat room system, a new multi-wallet, a new almost everything that you would need to control and manage your crypto currency sphere of influence. We will be creating some amazing tools to be used by heavy investors, veterans, and new beginners alike. Some of the things we are doing include but are not limited to the following:
Decentralized Data: Sending and receiving data in real time through a peer to peer decentralized distributed database system.
Injecting JS API’s: Taking normal websites and injecting our own custom JavaScript API’s to allow objects in that webpage to interact with our ecosystem.
Next Level Encryption Algorithms: We are building encryption systems that are blazing fast (milliseconds), quantum resistant, and incorporate interchanging and rotating keys.
Fastest Exchange Of Your Life: In addition to a decentralized exchange we are actively working on creating the worlds first professional grade high speed Crypto Currency Exchange that will actually scale correctly. We are talking lighting fast. It’s gonna be HUGE!
Tooling: Developers need love too, and we are going to be giving back to the community. Giving them the tools and services that we use to build next generation applications with.
And So Much More: The list goes on, and unfortunately I have to stop writing an article and get back to actual work on the Platform.
That Sounds Pretty Cool Right?
It does. It’s really cool. In fact it is so cool it’s sub-artic! We (Halo Platform Team) are getting together in the near future to do a week long hackathon. We are talking code and sleep, code and sleep.
I’m excited to bring my financial sector background to the Halo Team, and help them build the future of the crypto sphere. Here’s to a fun time!


| I l@ve RuBoard |
6.4 Climbing the GUI Learning CurveOn to the details. Let's start out by quickly stepping through a few small examples that illustrate basic concepts, and show the windows they create on the screen. The examples will become more sophisticated as we move along. 6.4.1 "Hello World" in Four Lines (or Less)The usual first example for GUI systems is to show how to display a "Hello World" message in a window. As coded in Example 6-1, it's just four lines in Python. Example 6-1. PP2E\Gui\Intro\gui1.pyfrom Tkinter import Label # get a widget object widget = Label(None, text='Hello GUI world!') # make one widget.pack() # arrange it widget.mainloop() # start event loop This is a complete Python Tkinter GUI program. When this script is run, we get a simple window with a label in the middle; it looks like Figure 6-1 on Windows. Figure 6-1. "Hello World" (gui1) on WindowsThis isn't much to write home about yet; but notice that this is a completely functional, independent window on the computer's display. It can be maximized to take up the entire screen, minimized to hide it in the system bar, and resized. Click on the window's "X" box in the top right to kill the window and exit the program. The script that builds this window is also fully portable -- when this same file is run on Linux it produces a similar window, but it behaves according to the underlying Linux window manager. For instance, Figures Figure 6-2 and Figure 6-3 show this simple script in action on the Linux X Windows system, under the KDE and Gnome window managers, respectively. Even on the same operating system, the same Python code yields a different look and feel for different window systems. Figure 6-2. "Hello World" on Linux with KDEFigure 6-3. "Hello World" on Linux with GnomeThe same script file would look different still when run on Macintosh and other Unix-like window managers. On all platforms, though, its basic functional behavior will be the same. 6.4.2 Tkinter Coding BasicsThe gui1 script is a trivial example, but it illustrates steps common to most Tkinter programs. This Python code:
The mainloop method called last puts the label on the screen and enters a Tkinter wait state, which watches for user-generated GUI events. Within the mainloop function, Tkinter internally monitors things like the keyboard and mouse, to detect user-generated events. Because of this model, the mainloop call here never returns to our script while the GUI is displayed on-screen.[6] As we'll see when we reach larger scripts, the only way we can get anything done after calling mainloop is to register callback handlers to respond to events.
Note that you really need both steps 3 and 4 to open this script's GUI. To display a GUI's window at all, you need to call mainloop; to display widgets within the window they must be packed (or otherwise arranged) so that the Tkinter geometry manager knows about them. In fact, if you call either mainloop or pack without calling the other, your window won't show up as expected: a mainloop without a pack shows an empty window, and a pack without a mainloop in a script shows nothing since the script never enters an event wait state (try it). Since the concepts illustrated by this simple script are at the core of most Tkinter programs, let's take a deeper look a some of them before moving on. <IP_ADDRESS> Making widgetsWhen widgets are constructed in Tkinter, we can specify how they should be configured. The gui1 script passes two arguments to the Label class constructor:
As we'll see, the parent-widget argument is the hook we use to build-up complex GUIs as widget trees. Tkinter works on a "what-you-build-is-what-you-get" principle: we construct widget object trees as models of what we want to see on the screen, and then ask the tree to display itself by calling mainloop. <IP_ADDRESS> Geometry managersThe pack widget method called by the gui1 script invokes the packer geometry manager -- one of three ways to control how widgets are arranged in a window. Tkinter geometry managers simply arrange one or more widgets within a container (sometimes called a parent, or master). Both top-level windows and frames (a special kind of widget we'll meet later) can serve as containers, and containers may be nested inside other containers to build hierarchical displays. The packer geometry manager uses constraint option settings to automatically position widgets in a window. Scripts supply higher-level instructions (e.g., "attach this widget to the top of its container, and stretch it to fill its space vertically"), not absolute pixel coordinates. Because such constraints are so abstract, the packer provides a powerful and easy-to-use layout system. In fact, you don't even have to specify constraints -- if you don't pass any arguments to pack, you get default packing, which attaches the widget to side top. We'll visit the packer repeatedly in this chapter, and use it in many of the examples in this book. In Chapter 8 we will also meet an alternative grid geometry manager and layout system that arranges widgets within a container in tabular form (i.e., by rows and columns). A third alternative, the placer geometry manager system, is described in Tk documentation, but not in this book; it's less popular than the pack and grid managers, and can be difficult to use for larger GUIs. <IP_ADDRESS> Running GUI programsLike all Python code, the module in Example 6-1 can be started in a number of ways: by running it as a top-level program file: C:\...\PP2E\Gui\Intro>python gui1.py by importing it from a Python session or another module file: >>> import gui1 by running it as a Unix executable, if we add the special #! line at the top: % gui1.py & and in any other way that Python programs can be launched on your platform. For instance, the script can also be run by clicking on the file's name in a Windows file explorer, and its code can be typed interactively at the >>> prompt. It can even be run from a C program, by calling the appropriate embedding API function (see Chapter 20, for details). In other words, there really are no special rules to follow when running GUI Python code. The Tkinter interface (and Tk itself) are linked into the Python interpreter. When a Python program calls GUI functions, they're simply passed to the embedded GUI system behind the scenes. That makes it easy to write command-line tools that pop up windows; they are run the same way as the purely text-based scripts we studied in the prior part of this book. <IP_ADDRESS> Avoiding DOS consoles on WindowsEarlier in this book we learned that if a program's name ends in a .pyw extension instead of .py, the Windows Python port does not pop up a DOS console box to serve as its standard streams when the file is launched by clicking its filename icon. Now that we've finally started making windows of our own, that filename trick will start to become even more useful. If you just want to see the windows that your script makes no matter how it is launched, be sure to name your GUI scripts with a .pyw if they might be run on Windows. For instance, clicking on the file in Example 6-2 in a Windows explorer creates just the window in Figure 6-1. Example 6-2. PP2E\Gui\Intro\gui1.pyw...same as gui1.py... You can also avoid the DOS popup on Windows by running the program with the pythonw.exe executable, not python.exe (in fact, .pyw files are simply registered to be opened by pythonw). On Linux, the .pyw doesn't hurt, but isn't necessary -- there is no notion of a streams popup on Unix-like machines. On the other hand, if your GUI scripts might run on Windows in the future, adding an extra "w" at the end of their names now might save porting effort later. In this book, .py filenames are still sometimes used to pop up console windows for viewing printed messages on Windows. 6.4.3 Tkinter Coding AlternativesAs you might expect, there are a variety of ways to code the gui1 example. For instance, if you want to make all your Tkinter imports more explicit in your script, grab the whole module and prefix all its names with the module's name, as in Example 6-3. Example 6-3. PP2E\Gui\Intro\gui1b.py - import versus fromimport Tkinter widget = Tkinter.Label(None, text='Hello GUI world!') widget.pack() widget.mainloop() That will probably get tedious in realistic examples, though -- Tkinter exports dozens of widget classes and constants that show up all over Python GUI scripts. In fact, it is usually easier to use a * to import everything from the Tkinter module by name in one shot. This is demonstrated in Example 6-4. Example 6-4. PP2E\Gui\Intro\gui1c.py - roots, sides, pack in-placefrom Tkinter import * root = Tk() Label(root, text='Hello GUI world!').pack(side=TOP) root.mainloop() The Tkinter module goes out of its way to only export things that we really need, so it's one of the few for which the * import form is relatively safe to apply.[7] The TOP constant in the pack call here, for instance, is one of those many names exported by the Tkinter module. It's simply a variable name (TOP="top") preassigned in Tkconstants, a module automatically loaded by Tkinter.
When widgets are packed, we can specify which side of their parent they should be attached to -- TOP, BOTTOM, LEFT, or RIGHT. If no side option is sent to pack (as in prior examples), a widget is attached to its parent's TOP by default. In general, larger Tkinter GUIs can be constructed as sets of rectangles, attached to the appropriate sides of other, enclosing rectangles. As we'll see later, Tkinter arranges widgets in a rectangle according to both their packing order and their side attachment options. When widgets are gridded, they are assigned row and column numbers instead. None of this will become very meaningful, though, until we have more than one widget in a window, so let's move on. Notice that this version calls the pack method right away after creating the label, without assigning it a variable. If we don't need to save a widget, we can pack it in place like this to eliminate a statement. We'll use this form when a widget is attached to a larger structure and never again referenced. This can be tricky if you assign the pack result, though, but I'll postpone an explanation of why until we've covered a few more basics. We also use a Tk widget class instance as the parent here, instead of None. Tk represents the main ("root") window of the program -- the one that starts when the program does. Tk is also used as the default parent widget, both when we don't pass any parent to other widget calls, and when we pass the parent as None. In other words, widgets are simply attached to the main program window by default. This script just makes this default behavior explicit, by making and passing the Tk object itself. In Chapter 7, we'll see that Toplevel widgets are typically used to generate new pop-up windows that operate independently of the program's main window. In Tkinter, some widget methods are exported as functions too, and this lets us shave Example 6-5 to just three lines of code. Example 6-5. PP2E\Gui\Intro\gui1d.py - a minimal versionfrom Tkinter import * Label(text='Hello GUI world!').pack() mainloop() The Tkinter mainloop can be called with or without a widget (i.e., as a function or method). We didn't pass Label a parent argument in this version either: it simply defaults to None when omitted (which in turn defaults to Tk). But relying on that default is less useful once we start building larger displays -- things like labels are more typically attached to other widget containers. <IP_ADDRESS> Widget resizing basicsTop-level windows, like the one all of the coding variants seen thus far build, can normally be resized by the user -- simply drag out the window with your mouse. Figure 6-4 shows how our window looks when it is expanded. Figure 6-4. Expanding gui1This isn't very good -- the label stays attached to the top of the parent window instead of staying in the middle on expansion -- but it's easy to improve on this with a pair of pack options, demonstrated in Example 6-6. Example 6-6. PP2E\Gui\Intro\gui1e.py - expansionfrom Tkinter import * Label(text='Hello GUI world!').pack(expand=YES, fill=BOTH) mainloop() When widgets are packed, we can specify whether a widget should expand to take up all available space, and if so, how it should stretch to fill that space. By default, widget are not expanded when their parent is. But in this script, names YES and BOTH (imported from the Tkinter module) specify that the label should grow along with its parent, the main window. It does, in Figure 6-5. Figure 6-5. gui1e with widget resizingTechnically, the packer geometry manager assigns a size to each widget in a display, based on what it contains (text string lengths, etc.). By default, a widget only can occupy its allocated space, and is no bigger than its assigned size. The expand and fill options let us be more specific about such things:
Combinations of these two options produce different layout and resizing effects, some of which only become meaningful when there are multiple widgets in a window. For example, using expand without fill centers the widget in the expanded space, and the fill option can specify vertical stretching only (fill=Y), horizontal stretching only (fill=X), or both (fill=BOTH). By providing these constraints and attachment sides for all widgets in a GUI, we can control the layout in fairly precise terms. In later chapters, we'll find that the grid geometry manager uses a different resizing protocol entirely. This all can be confusing the first time you hear it, and we'll return to this later. But if you're not sure what an expand and fill combination will do, simply try it out -- this is Python after all. For now, remember that the combination of expand=YES and fill=BOTH is perhaps the most common setting; it means "expand my space allocation to occupy all available space, and stretch me to fill the expanded space in both directions." For our "Hello World" example, the net result is that label grows as the window is expanded, and so is always centered. <IP_ADDRESS> Configuring widget options and window titlesSo far, we've been telling Tkinter what to display on our label by passing its text as a keyword argument in label constructor calls. It turns out that there are two other ways to specify widget configuration options. In Example 6-7, the text option of the label is set after it is constructed, by assigning to the widget's text key -- widget objects overload index operations such that options are also available as mapping keys, much like a dictionary. Example 6-7. PP2E\Gui\Intro\guif.py - option keysfrom Tkinter import * widget = Label() widget['text'] = 'Hello GUI world!' widget.pack(side=TOP) mainloop() More commonly, widget options can be set after construction by calling the widget config method, as in Example 6-8. Example 6-8. PP2E\Gui\Intro\gui1g.py - config and titlesfrom Tkinter import * root = Tk() widget = Label(root) widget.config(text='Hello GUI world!') widget.pack(side=TOP, expand=YES, fill=BOTH) root.title('gui1g.py') root.mainloop() The config method (which can also be called by its synonym, configure) can be called at any time after construction to change the appearance of a widget on the fly. For instance, we could call this label's config method again later in the script to change the text that it displays; watch for such dynamic reconfigurations in later examples in this part of the book. Notice that this version also calls a root.title method -- this call sets the label that appears at the top of the window, as pictured in Figure 6-6. In general terms, top-level windows like the Tk root here export window-manager interfaces: things that have to do with the border around the window, not its contents. Figure 6-6. gui1g with expansion and a window titleJust for fun, this version also centers the label on resizes by setting the expand and fill pack options too. In fact, this version makes just about everything explicit, and is more representative of how labels are often coded in full-blown interfaces -- their parents, expansion policies, and attachments are usually all spelled out, rather than defaulted. <IP_ADDRESS> One more for old times' sakeFinally, if you are both a minimalist and nostalgic for old Python code, you can also program this "Hello World" example as in Example 6-9. Example 6-9. PP2E\Gui\Intro\gui1-old.py - dictionary callsfrom Tkinter import * Label(None, {'text': 'Hello GUI world!', Pack: {'side': 'top'}}).mainloop() This makes the window in just two lines -- albeit gruesome ones! This scheme relies on an old coding style that was widely used until Python 1.3 that passed configuration options in a dictionary instead of keyword arguments.[8] In this scheme, packer options can be sent as values of the key Pack (a class in the Tkinter module).
The dictionary call scheme still works, and you may see it in old Python code, but please don't do this -- use keywords to pass options, and explicit pack method calls in your Tkinter scripts instead. In fact, the only reason I didn't cut this example completely is that dictionaries can still be useful if you want to compute and pass a set of options dynamically. On the other hand, the built-in apply function now also allows you to pass an explicit dictionary of keyword arguments in its third argument slot, so there's no compelling reason to ever use the pre-1.3 Tkinter dictionary call form at all. <IP_ADDRESS> Packing widgets without saving themIn gui1c.py (shown in Example 6-4), I started packing labels without assigning them to names. This works, and is an entirely valid coding style; but because it tends to confuse beginners at first glance, I need to explain why it works in more detail here. In Tkinter, Python class objects correspond to real objects displayed on a screen; we make the Python object to make a screen object, and call the Python object's methods to configure that screen object. Because of this correspondence, the lifetime of the Python object must generally correspond to the lifetime of the corresponding object on the screen. Luckily, Python scripts don't usually need to care about managing object lifetimes. In fact, they do not normally need to maintain a reference to widget objects created along the way at all, unless they plan to reconfigure those objects later. For instance, it's common in Tkinter programming to pack a widget immediately after creating it, if no further reference to the widget is required: Label(text='hi').pack() # okay This expression is evaluated left to right as usual -- it creates a new label, and then immediately calls the new object's pack method, to arrange it in the display. Notice, though, that the Python Label object is temporary in this expression; because it is not assigned to a name, it would normally be garbage collected (destroyed and reclaimed) by Python immediately after running its pack method. However, because Tkinter emits Tk calls when objects are constructed, the label will be drawn on the display as expected, even though we haven't held on to the corresponding Python object in our script. In fact, Tkinter internally cross-links widget objects into a long-lived tree used to represent the display, so the Label object made during this statement really is retained, even if not by our code.[9]
In other words, your scripts don't generally need to care about widget object lifetimes, and it's okay to make widgets and pack them right away in the same statement. But that does not mean that it's okay to say something like this: widget = Label(text='hi').pack() # wrong! ...use widget... This statement almost seems like it should assign a newly packed label to name widget, but it does not. In fact, it's really a notorious Tkinter beginner's mistake. The widget pack method packs the widget but does not return the widget thus packed. Really, pack returns the Python object None; after such a statement, widget will be a reference to None, and any further widget operations through that name will fail. For instance, the following fails too, for the same reason: Label(text='hi').pack().mainloop() # wrong! Since pack returns None, asking for its mainloop attribute generates an exception (as it should). If you really want to both pack a widget and retain a reference to it, say this instead: widget = Label(text='hi') # okay too widget.pack() ...use widget... This form is a bit more verbose, but is less tricky than packing a widget in the same statement that creates it, and allows you to hold onto the widget for later processing. On the other hand, scripts that compose layouts often add widgets once and for all when they are created, and never need to reconfigure them later; assigning to long-lived names in such program is pointless and unnecessary.[10]
6.4.4 Adding Buttons and CallbacksSo far, we've learned how to display messages in labels, and met Tkinter core concepts along the way. Labels are nice for teaching the basics, but user interfaces usually need to do a bit more -- like actually responding to users. The program in Example 6-10 creates the window in Figure 6-7. Example 6-10. PP2E\Gui\Intro\gui2.pyimport sys from Tkinter import * widget = Button(None, text='Hello widget world', command=sys.exit) widget.pack() widget.mainloop() Figure 6-7. A button on the topHere, instead of making a label, we create an instance of the Tkinter Button class. It's attached to the default top-level as before, on the default TOP packing side. But the main thing to notice here is the button's configuration arguments: we set an option called command to the sys.exit function. For buttons, the command option is the place where we specify a callback handler function to be run when the button is later pressed. In effect, we use command to register an action for Tkinter to call when a widget's event occurs. The callback handler used here isn't very interesting: as we learned in an earlier chapter, the built-in sys.exit function simply shuts down the calling program. Here, that means pressing this button makes the window go away. Just as for labels, there are other ways to code buttons. Example 6-11 is a version that packs the button in place without assigning it to a name, attaches it to the LEFT side of its parent window explicitly, and specifies root.quit as the callback handler -- a standard Tk object method that shuts down the GUI, and so ends the program (really, it ends the current mainloop event loop call). Example 6-11. PP2E\Gui\Intro\gui2b.pyfrom Tkinter import * root = Tk() Button(root, text='press', command=root.quit).pack(side=LEFT) root.mainloop() This version produces the window in Figure 6-8. Because we didn't tell the button to expand into all available space, it does not. Figure 6-8. A button on the leftIn both of the last two examples, pressing the button makes the GUI program exit. In older Tkinter code, you may sometimes see the string "exit" assigned to the command option to make the GUI go away when pressed. This exploits a tool in the underlying Tk library, and is less Pythonic than sys.exit or root.quit. <IP_ADDRESS> Widget resizing revisited: expansionEven with a GUI this simple, there are many ways to lay out its appearance with Tkinter's constraint-based pack geometry manager. For example, to center the button in its window, add an expand=YES option to the button's pack method call, and generate a window like Figure 6-9. This makes the packer allocate all available space to the button, but does not stretch the button to fill that space. Figure 6-9. side=LEFT, expand=YESIf you want the button to be given all available space, and to stretch to fill all of its assigned space horizontally, add expand=YES and fill=X keyword arguments to the pack call, and create the scene in Figure 6-10. Figure 6-10. side=LEFT, expand=YES, fill=XThis makes the button fill the whole window initially (its allocation is expanded, and it is stretched to fill that allocation). It also makes the button grow as the parent window is resized. As shown in Figure 6-11, the button in this window does expand when its parent expands, but only along the X horizontal axis. Figure 6-11. Resizing with expand=YES, fill=XTo make the button grow in both directions, specify both expand=YES and fill=BOTH in the pack call; now, resizing the window makes the button grow in general, as shown in Figure 6-12. In fact, for a good time, maximize this window to fill the entire screen; you'll get one very big Tkinter button indeed. Figure 6-12. Resizing with expand=YES, fill=BOTHIn more complex displays, such a button will only expand if all of the widgets it is contained by are set to expand too. Here, the button's only parent is the Tk root window of the program, so parent expandability isn't yet an issue. We will revisit the packer geometry manager when we meet multiple-widget displays later in this tutorial, and again when we study the alternative grid call in Chapter 8. 6.4.5 Adding User-Defined Callback HandlersIn the simple button examples in the previous section, the callback handler was simply an existing function that killed the GUI program. It's not much more work to register callback handlers that do something a bit more useful. Example 6-12 defines a callback handler of its own in Python. Example 6-12. PP2E\Gui\Intro\gui3.pyfrom Tkinter import * def quit(): # a custom callback handler print 'Hello, I must be going...' # kill windows and process import sys; sys.exit() widget = Button(None, text='Hello event world', command=quit) widget.pack() widget.mainloop() The window created by this script is shown in Figure 6-13. This script and its GUI are almost identical to the last example. But here, the command option specifies a function we've defined locally. When the button is pressed, Tkinter calls the quit function in this file to handle the event. Inside quit, the print statement types a message on the program's stdout stream, and the GUI process exits as before. Figure 6-13. A button that runs a Python functionAs usual, stdout is normally the window that the program was started from, unless it's been redirected to a file. It's a pop-up DOS console if you run this program by clicking it on Windows -- add a raw_input call before sys.exit if you have trouble seeing the message before the pop-up disappears. Here's what the printed output looks like back in standard stream world when the button is pressed; it is generated by a Python function called automatically by Tkinter: C:\...\PP2E\Gui\Intro>python gui3.py Hello, I must be going... C:\...\PP2E\Gui\Intro> Normally, such messages would be displayed in another window, but we haven't gotten far enough to know how just yet. Callback functions usually do more, of course (and may even pop up new windows altogether), but this example illustrates the basics. In general, callback handlers can be any callable object: functions, anonymous functions generated with lambda expressions, bound methods of class or type instances, or class instances that inherit a __call__ operator overload method. For Button press callbacks, callback handlers always receive no arguments (other than a self, for bound-methods). <IP_ADDRESS> Lambda callback handlersTo make the last paragraph a bit more concrete, let's take a quick look at some other ways to code the callback handler in this example. Recall that the Python lambda expression generates a new, unnamed function object when run. If we need extra data passed in to the handler function, we can register lambda expressions with default argument values to specify the extra data needed. We'll see how this can be useful later in this part of the book, but to illustrate the basic idea, Example 6-13 shows what this example looks like when recoded to use a lambda instead of a def. Example 6-13. PP2E\Gui\Intro\gui3b.pyfrom Tkinter import * from sys import stdout, exit # lambda generates a function widget = Button(None, # but contains just an expression text='Hello event world', command=(lambda: stdout.write('Hello lambda world\n') or exit()) ) widget.pack() widget.mainloop() This code is a bit tricky because lambdas can only contain an expression; to emulate the original script, this version uses an or operator to force two expressions to be run, and writes to stdout to mimic a print. More typically, lambdas are used to pass along extra data to a callback handler using defaults: def handler(X, Y): # would normallly be called with no args use original X and Y here... X = something here... Y = something else here... Button(text='ni', command=(lambda save1=X, save2=Y: handler(save1, save2)) ) Although Tkinter invokes command callbacks with no arguments, such a lambda can be used to provide an indirect anonymous function that wraps the real handler call, and passes along information that existed when the GUI was first constructed. Since default arguments are evaluated and saved when the lambda runs (not when its result is later called), they are a way to remember objects that must be accessed again later, during event processing. We'll see this put to more concrete use later. If its syntax confuses you, remember that a lambda expression like the one in the preceding code can usually be coded as a simple nested def statement instead: X = something here... Y = something else here... def func(save1=X, save2=Y): handler(save1, save2) Button(text='ni', command=func) <IP_ADDRESS> Bound method callback handlersClass bound methods work particularly well as callback handlers too: they record both an instance to send the event to, and an associated method to call. As a preview, Example 6-14 shows Example 6-12 rewritten to register a bound class method, instead of a function or lambda result. Example 6-14. PP2E\Gui\Intro\gui3c.pyfrom Tkinter import * class HelloClass: def __init__(self): widget = Button(None, text='Hello event world', command=self.quit) widget.pack() def quit(self): print 'Hello class method world' # self.quit is a bound method import sys; sys.exit() # retains the self+quit pair HelloClass() mainloop() On a button press, Tkinter calls this class's quit method with no arguments as usual. But really, is does receive one argument -- the original self object -- even though Tkinter doesn't pass it explicitly. Because the self.quit bound method retains both self and quit, it's compatible with a simple function call; Python automatically passes the self argument along to the method function. Conversely, registering an unbound method like HelloClass.quit won't work, because there is no self object to pass along when the event later occurs. Later, we'll see that class callback handler coding schemes provide a natural place to remember information for use on events too: simply assign it to self instance attributes: class someGuiClass: def __init__(self): self.X = something here... self.Y = something else here... Button(text='Hi', command=self.handler ) def handler(self): use self.X, self.Y here... Because the event will be dispatched to this class's method with a reference to the original instance object, self gives access to attributes that retain original data. <IP_ADDRESS> Callable class object callback handlersBecause Python class instance objects can also be called if they inherit a __call__ method to intercept the operation, we can pass one of these to serve as a callback handler too, as in Example 6-15. Example 6-15. PP2E\Gui\Intro\gui3d.pyfrom Tkinter import * class HelloCallable: def __init__(self): # __init__ run on object creation self.msg = 'Hello __call__ world' def __call__(self): print self.msg # __call__ run later when called import sys; sys.exit() # class object looks like a function widget = Button(None, text='Hello event world', command=HelloCallable()) widget.pack() widget.mainloop() Here, the HelloCallable instance registered with command can be called like a normal function too -- Python invokes its __call__ method to handle the call operation made in Tkinter on the button press. Notice that self.msg is used to retain information for use on events here; self is the original instance when the special __call__ method is automatically invoked. All four gui3 variants create the same GUI window, but print different messages to stdout when their button is pressed: C:\...\PP2E\Gui\Intro>python gui3.py Hello, I must be going... C:\...\PP2E\Gui\Intro>python gui3b.py Hello lambda world C:\...\PP2E\Gui\Intro>python gui3c.py Hello class method world C:\...\PP2E\Gui\Intro>python gui3d.py Hello __call__ world There are good reasons for each callback coding scheme (function, lambda, class method, callable class), but we need to move on to larger examples to uncover them in less theoretical terms. <IP_ADDRESS> Other Tkinter callback protocolsFor future reference, also keep in mind that using command options to intercept user-generated button press events is just one way to register callbacks in Tkinter. In fact, there are a variety of ways for Tkinter scripts to catch events:
<IP_ADDRESS> Binding eventsOf all these, bind is the most general, but also perhaps the most complex. We'll study it in more detail later, but to let you sample its flavor now, Example 6-16 uses bind,not command, to catch button presses. Example 6-16. PP2E\Gui\Intro\gui3e.pyfrom Tkinter import * def hello(event): print 'Press twice to exit' # on single-left click def quit(event): # on double-left click print 'Hello, I must be going...' # event gives widget, x/y, etc. import sys; sys.exit() widget = Button(None, text='Hello event world') widget.pack() widget.bind('<Button-1>', hello) # bind left mouse clicks widget.bind('<Double-1>', quit) # bind double-left clicks widget.mainloop() In fact, this version doesn't specify a command option for the button at all. Instead, it binds lower-level callback handlers for both left mouseclicks (<Button-1>) and double-left mouseclicks (<Double-1>) within the button's display area. The bind method accepts a large set of such event identifiers in a variety of formats, which we'll meet in Chapter 7. When run, this script makes the same window again (see Figure 6-13). Clicking on the button once prints a message but doesn't exit; you need to double-click on the button now to exit as before. Here is the output after clicking twice and double-clicking once (a double-click fires the single-click callback first): C:\...\PP2E\Gui\Intro>python gui3e.py Press twice to exit Press twice to exit Press twice to exit Hello, I must be going... Although this script intercepts button clicks manually, the end result is roughly the same; widget-specific protocols like button command options are really just higher-level interfaces to events you can also catch with bind. We'll meet bind and all of the other Tkinter event callback handler hooks again in more detail later in this book. First, though, let's focus on building GUIs larger than a single button, and other ways to use classes in GUI work. 6.4.6 Adding Multiple WidgetsIt's time to start building user interfaces with more than one widget. Example 6-17 makes the window shown in Figure 6-14. Example 6-17. PP2E\Gui\Intro\gui4.pyfrom Tkinter import * def greeting(): print 'Hello stdout world!...' win = Frame() win.pack() Label(win, text='Hello container world').pack(side=TOP) Button(win, text='Hello', command=greeting).pack(side=LEFT) Button(win, text='Quit', command=win.quit).pack(side=RIGHT) win.mainloop() Figure 6-14. A multiple-widget windowThis example makes a Frame widget (another Tkinter class), and attaches three other widget objects to it, a Label and two Buttons, by passing the Frame as their first argument. In Tkinter terms, we say that the Frame becomes a parent to the other three widgets. Both buttons on this display trigger callbacks:
Here is the stdout text that shows up on Hello button presses, wherever this script's standard streams may be: C:\...\PP2E\Gui\Intro>python gui4.py Hello stdout world!... Hello stdout world!... Hello stdout world!... Hello stdout world!... The notion of attaching widgets to containers turns out to be at the core of layouts in Tkinter. Before we go into more detail on that topic, though, let's get small. <IP_ADDRESS> Widget resizing revisited: clippingEarlier, we saw how to make widgets expand along with their parent window, by passing expand and fill options to the pack geometry manager. Now that we have a window with more than one widget, I can let you in on one of the more useful secrets in the packer. As a rule, widgets packed first are clipped last, when a window is shrunk. That is, the order in which you pack items determines which will be cut out of the display if it is made too small -- widgets packed later are cut out first. For example, Figure 6-15 shows what happens when the gui4 window is shrunk interactively. Figure 6-15. gui4 gets smallTry reordering the label and button lines in the script and see what happens when the window shrinks; the first packed is always the last to go away. For instance, if the label is packed last, Figure 6-16 shows that it is clipped first even though it is attached to the top: side attachments and packing order both impact the overall layout, but only packing order matters when windows shrink. Figure 6-16. Label packed last, clipped firstTkinter keeps track of the packing order internally to make this work. Scripts can plan ahead for shrinkage by calling pack methods of more important widgets first. For instance, on the upcoming Tkinter tour we'll meet code that builds menus and toolbars at the top and bottom of the window; to make sure these are lost last as a window is shrunk, they are packed first, before the application components in the middle. Similarly, displays that include scrollbars normally pack them before the items they scroll (e.g., text, lists), so that the scrollbars remain as the window shrinks. <IP_ADDRESS> Attaching widgets to framesIn larger terms, the critical innovation in this example is its use of frames: Frame widgets are just containers for other widgets, and so give rise to the notion of GUIs as widget hierarchies, or trees. Here, win serves as an enclosing window for the other three widgets. In general, though, by attaching widgets to frames, and frames to other frames, we can build up arbitrary GUI layouts. Simply divide the user interface into a set of increasingly smaller rectangles, implement each as a Tkinter Frame, and attach basic widgets to the frame in the desired screen position. In this script, by specifying win in the first argument to the Label and Button constructors, they are attached to the Frame by Tkinter (they become children of the win parent). win itself is attached to the default top-level window, since we didn't pass a parent to the Frame constructor. When we ask win to run itself (by calling mainloop), Tkinter draws all the widgets in the tree we've built. The three child widgets also provide pack options now: the side arguments tell which part of the containing frame (i.e., win) to attach the new widget to. The label hooks onto the top, and the buttons attach to the sides. TOP, LEFT, and RIGHT are all preassigned string variables imported from Tkinter. Arranging widgets is a bit more subtle than simply giving a side, though, but we need to take a quick detour into packer geometry management details to see why. <IP_ADDRESS> Packing order and side attachmentsWhen a widget tree is displayed, child widgets appear inside their parents, and are arranged according to their order of packing and their packing options. Because of this, the order in which widgets are packed not only gives their clipping order, it also determines how their side settings play out in the generated display. Here's how the packer's layout system works:
For instance, if you recode the gui4 child widget creation logic like this: Button(win, text='Hello', command=greeting).pack(side=LEFT) Label(win, text='Hello container world').pack(side=TOP) Button(win, text='Quit', command=win.quit).pack(side=RIGHT) You will wind up with the very different display in Figure 6-17, even though you've only moved the label code one line down in the source file (contrast with Figure 6-14). Figure 6-17. Packing the label secondDespite its side setting, the label does not get the entire top of the window now, and you have to think in terms of shrinking cavities to understand why. Because the Hello button is packed first, it is given the entire LEFT side of the Frame. Next, the label is given the entire TOP side of what is left. Finally, the Quit button gets the RIGHT side of the remainder -- a rectangle to the right of the Hello button and under the label. When this window shrinks, widgets are clipped in reverse order of their packing: the Quit button disappears first, followed by the label.[11] In the original version of this example, the label spans the entire top side just because it is the first packed, not because of its side option.
<IP_ADDRESS> The packer's expand and fill revisitedBeyond all this, the fill option we met earlier can be used to stretch the widget to occupy all the space in the cavity side it has been given, and any cavity space left after all packing is evenly allocated among widgets with the expand=YES we saw before. For example, coding this way makes the window in Figure 6-18: Button(win, text='Hello', command=greeting).pack(side=LEFT, fill=Y) Label(win, text='Hello container world').pack(side=TOP) Button(win, text='Quit', command=win.quit).pack(side=RIGHT, expand=YES, fill=X) Figure 6-18. Packing with expand and fill optionsTo make these all grow along with their window, though, we also need to make the container frame expandable -- widgets only expand beyond their initial packer arrangement if all of their parents expand too: win = Frame() win.pack(side=TOP, expand=YES, fill=BOTH) Button(win, text='Hello', command=greeting).pack(side=LEFT, fill=Y) Label(win, text='Hello container world').pack(side=TOP) Button(win, text='Quit', command=win.quit).pack(side=RIGHT, expand=YES,fill=X) When this code runs, the Frame is assigned the entire top side of its parent as before (that is, the top parcel of the root window); but because it is now marked to expand into unused space in its parent and fill that space both ways, it and all its attached children expand along with the window. Figure 6-19 shows how. Figure 6-19. gui4 gets big with an expandable frame<IP_ADDRESS> Using anchor to position instead of stretchAnd as if that isn't flexible enough, packer also allows widgets to be positioned within their allocated space with an anchor option, instead of filling that space with a fill. The anchor option accepts Tkinter constants identifying all eight points of the compass (N, NE, NW, S, etc.) and CENTER as its value (e.g., anchor=NW). It instructs the packer to position the widget at the desired position within its allocated space, if the space allocated for the widget is larger than the space needed to display the widget. The default anchor is CENTER, so widgets show up in the middle of their space (the cavity side they were given) unless they are positioned with anchor, or stretched with fill. To demonstrate, change gui4 to use this sort of code: Button(win, text='Hello', command=greeting).pack(side=LEFT, anchor=N) Label(win, text='Hello container world').pack(side=TOP) Button(win, text='Quit', command=win.quit).pack(side=RIGHT) The only thing new here is that the Hello button is anchored to the north side of its space allocation. Because this button was packed first, it got the entire left side of the parent frame -- more space than needed to show the button, so it shows up in the middle of that side by default as in Figure 6-17 (i.e., anchored to the center). Setting the anchor to N moves it to the top of its side, as shown in Figure 6-20. Figure 6-20. Anchoring a button to the northKeep in mind that fill and anchor are applied after a widget has been allocated cavity side space by its side, packing order, and expand extra space request. By playing with packing orders, sides, fills, and anchors, you can generate lots of layout and clipping effects, and you should take a few moments to experiment with alternatives if you haven't already. In the original version of this example, for instance, the label spans the entire top side just because it is the first packed. As we'll see later, frames can be nested in other frames too, to make more complex layouts. In fact, because each parent container is a distinct space cavity, this provides a sort of escape mechanism for the packer cavity algorithm: to better control where a set of widgets show up, simply pack them within a nested subframe, and attach the frame as a package to a larger container. A row of pushbuttons, for example, might be easier laid out in a frame of its own than mixed with other widgets in the display directly. Finally, also keep in mind that the widget tree created by these examples is really an implicit one; Tkinter internally records the relationships implied by passed parent widget arguments. In OOP terms, this is a composition relationship -- the Frame contains a Label and Buttons; let's look at inheritance relationships next. 6.4.7 Customizing Widgets with ClassesYou don't have to use OOP in Tkinter scripts, but it can definitely help. As we just saw, Tkinter GUIs are built up as class-instance object trees. Here's another way Python's OOP features can be applied to GUI models: specializing widgets by inheritance. Example 6-18 builds the window in Figure 6-21. Example 6-18. PP2E\Gui\Intro\gui5.pyfrom Tkinter import * class HelloButton(Button): def __init__(self, parent=None, **config): # add callback method Button.__init__(self, parent, config) # and pack myself self.pack() self.config(command=self.callback) def callback(self): # default press action print 'Goodbye world...' # replace in subclasses self.quit() if __name__ == '__main__': HelloButton(text='Hello subclass world').mainloop() Figure 6-21. A button subclass in actionThis example isn't anything special to look at: it just displays a single button that prints a message and exits when pressed. But this time, it is a button widget we created on our own. The HelloButton class inherits everything from the Tkinter Button class, but adds a callback method and constructor logic to set the command option to self.callback, a bound method of the instance. When the button is pressed this time, the new widget class's callback method is invoked, not a simple function. The **config argument here is assigned unmatched keyword arguments; they're passed along to the Button constructor. We met the config widget method called in HelloButton's constructor earlier; it is just an alternative way to pass configuration options after the fact (instead of passing constructor arguments). So what's the point of subclassing widgets like this? It allows widgets to be configured by subclassing, instead of passing in options. HelloButton is a true button; we pass in configuration options as usual when one is made. But we can also specify callback handlers by overriding the callback method in subclasses, as shown in Example 6-19. Example 6-19. PP2E\Gui\Intro\gui5b.pyfrom gui5 import HelloButton class MyButton(HelloButton): # subclass HelloButton def callback(self): # redefine press-handler method print "Ignoring press!..." if __name__ == '__main__': MyButton(None, text='Hello subclass world').mainloop() Instead of exiting, this MyButton button prints to stdout and stays up when pressed. Here is its standard output after being pressed a few times: C:\PP2ndEd\examples\PP2E\Gui\Intro>python gui5b.py Ignoring press!... Ignoring press!... Ignoring press!... Ignoring press!... Whether it's simpler to customize widgets by subclassing or passing in options is probably a matter of taste. But the point to notice is that Tk becomes truly object-oriented in Python, just because Python is object-oriented: we can specialize widget classes using normal class-based OO techniques. The next example provides yet another way to arrange for specialization. 6.4.8 Reusable GUI Components with ClassesLarger GUI interfaces are often built up as subclasses of Frame, with callback handlers implemented as methods. This structure gives us a natural place to store information between events: instance attributes record state. It also allows us to both specialize GUIs by overriding their methods in new subclasses, and attach them to larger GUI structures to reuse them as general components. For instance, a GUI text editor implemented as a Frame subclass can be attached to and configured by any number of other GUIs; if done well, we can plug such a text editor into any user interface that needs text editing tools. We'll meet such a text editor component in Chapter 9. For now, Example 6-20 is a simple example to illustrate the concept. Script gui6.py produces the window in Figure 6-22. Example 6-20. PP2E\Gui\Intro\gui6.pyfrom Tkinter import * class Hello(Frame): # an extended Frame def __init__(self, parent=None): Frame.__init__(self, parent) # do superclass init self.pack() self.data = 42 self.make_widgets() # attach widgets to self def make_widgets(self): widget = Button(self, text='Hello frame world!', command=self.message) widget.pack(side=LEFT) def message(self): self.data = self.data + 1 print 'Hello frame world %s!' % self.data if __name__ == '__main__': Hello().mainloop() Figure 6-22. A custom Frame in actionThis example pops up a single button window. When pressed, the button triggers the self.message bound method to print to stdout again. Here is the output after pressing this button four times; notice how self.data (a simple counter here) retains its state between presses: C:\...\PP2E\Gui\Intro>python gui6.py Hello frame world 43! Hello frame world 44! Hello frame world 45! Hello frame world 46! This may seem like a roundabout way to show a Button (we did it in fewer lines in Examples Example 6-10, Example 6-11, and Example 6-12). But the Hello class provides an enclosing organizational structure for building GUIs. In the examples prior to the last section, we made GUIs using a function-like approach: we called widget constructors as though they were functions and hooked widgets together manually by passing in parents to widget construction calls. There was no notion of an enclosing context, apart from the global scope of the module file containing the widget calls. This works for simple GUIs, but can make for brittle code when building up larger GUI structures. But by subclassing Frame as we've done here, the class becomes an enclosing context for the GUI:
In a sense, entire GUIs become specialized Frame objects, with extensions for an application. Classes can also provide protocols for building widgets (e.g., the make_widgets method here), handle standard configuration chores (like setting window manager options), and so on. In short, Frame subclasses provide a simple way to organize collections of other widget-class objects. <IP_ADDRESS> Attaching class componentsPerhaps more important, subclasses of Frame are true widgets: they can be further extended and customized by subclassing, and can be attached to enclosing widgets. For instance, to attach the entire package of widgets that a class builds to something else, simply create an instance of the class with a real parent widget passed in. To illustrate, running the script in Example 6-21 creates the window shown in Figure 6-23. Example 6-21. PP2E\Gui\Intro\gui6b.pyfrom sys import exit from Tkinter import * # get Tk widget classes from gui6 import Hello # get the subframe class parent = Frame(None) # make a container widget parent.pack() Hello(parent).pack(side=RIGHT) # attach Hello instead of running it Button(parent, text='Attach', command=exit).pack(side=LEFT) parent.mainloop() Figure 6-23. An attached class component on the rightThis script just adds Hello's button to the right side of parent -- a container Frame. In fact, the button on the right in this window represents an embedded component: its button really represents an attached Python class object. Pressing the embedded class's button on the right prints a message as before; pressing the new button exits the GUI by a sys.exit call: C:\...\PP2E\Gui\Intro>python gui6b.py Hello frame world 43! Hello frame world 44! Hello frame world 45! Hello frame world 46! In more complex GUIs, we might instead attach large Frame subclasses to other container components and develop each independently. For instance, Example 6-22 is yet another specialized Frame itself, but attaches an instance of the original Hello class in a more OO fashion. When run as a top-level program, it creates a window identical to the one shown in Figure 6-23. Example 6-22. PP2E\Gui\Intro\gui6c.pyfrom Tkinter import * # get Tk widget classes from gui6 import Hello # get the subframe class class HelloContainer(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) self.pack() self.makeWidgets() def makeWidgets(self): Hello(self).pack(side=RIGHT) # attach a Hello to me Button(self, text='Attach', command=self.quit).pack(side=LEFT) if __name__ == '__main__': HelloContainer().mainloop() This looks and works exactly like gui6b, but registers the added button's callback handler as self.quit, which is just the standard quit widget method this class inherits from Frame. The window this time represents two Python classes at work -- the embedded component's widgets on the right (the original Hello button), and the container's widgets on the left. Naturally, this is a simple example (we only attached a single button here, after all). But in more practical user interfaces, the set of widget class objects attached in this way can be much larger. Imagine replacing the Hello call in this script with a call to attach an already-coded and fully debugged calculator object, and you'll begin to better understand the power of this paradigm. If we code all of our GUI components as classes, they automatically become a library of reusable widgets, which we can combine in other applications as often as we like. <IP_ADDRESS> Extending class componentsWhen GUIs are built with classes, there are a variety of ways to reuse their code in other displays. To extend Hello instead of attaching it, we just override some of its methods in a new subclass (which itself becomes a specialized Frame widget). This technique is shown in Example 6-23. Example 6-23. PP2E\Gui\Intro\gui6d.pyfrom Tkinter import * from gui6 import Hello class HelloExtender(Hello): def make_widgets(self): # extend method here Hello.make_widgets(self) Button(self, text='Extend', command=self.quit).pack(side=RIGHT) def message(self): print 'hello', self.data # redefine method here if __name__ == '__main__': HelloExtender().mainloop() This subclass's make_widgets method here first builds the superclass's widgets, then adds a second Extend button on the right, as shown in Figure 6-24. Figure 6-24. A customized class's widgets, on the leftBecause it redefines the message method, pressing the original superclass's button on the left now prints a different string to stdout (when searching up from self, the message attribute is found first in this subclass, not the superclass): C:\...\PP2E\Gui\Intro>python gui6d.py hello 42 hello 42 hello 42 hello 42 But pressing the new Extend button on the right, added by this subclass, exits immediately, since the quit method (inherited from Hello, which inherits it from Frame) is the added button's callback handler. The net effect is that this class customizes the original, to add a new button and change message's behavior. Although this example is simple, it demonstrates a technique that can be powerful in practice -- to change a GUI's behavior, we can write a new class that customizes its parts, rather than changing the existing GUI code in place. The main code need be debugged only once, and customized with subclasses as unique needs arise. The moral of this story is that Tkinter GUIs can be coded without ever writing a single new class, but using classes to structure your GUI code makes it much more reusable in the long run. If done well, you can both attach already-debugged components to new interfaces, and specialize their behavior in new external subclasses as needed for custom requirements. Either way, the initial up-front investment to use classes is bound to save coding time in the end. <IP_ADDRESS> Standalone container classesBefore we move on, I want to point out that it's possible to reap most of the benefits previously mentioned by creating standalone classes not derived from Tkinter Frames or other widgets. For instance, the class in Example 6-24 generates the window shown in Figure 6-25. Example 6-24. PP2E\Gui\Intro\gui7.pyfrom Tkinter import * class HelloPackage: # not a widget subbclass def __init__(self, parent=None): self.top = Frame(parent) # embed a Frame self.top.pack() self.data = 0 self.make_widgets() # attach widgets to self.top def make_widgets(self): Button(self.top, text='Bye', command=self.top.quit).pack(side=LEFT) Button(self.top, text='Hye', command=self.message).pack(side=RIGHT) def message(self)): self.data = self.data + 1 print 'Hello number', self.data if __name__ == '__main__': HelloPackage().top.mainloop() Figure 6-25. A standalone class package in actionWhen run, the Hye button here prints to stdout, and Bye closes and exits the GUI, much as before: C:\...\PP2E\Gui\Intro>python gui7.py Hello number 1 Hello number 2 Hello number 3 Hello number 4 Also as before, self.data retains state between events, and callbacks are routed to the self.message method within this class. Unlike before, the HelloPackage class is not itself a kind of Frame widget. In fact, it's not a kind of anything -- it only serves as a generator of namespaces for storing away real widget objects and state. Because of that, widgets are attached to a self.top (an embedded Frame), not self. Moreover, all references to the object as widget must descend to the embedded frame -- as in the top.mainloop call to start the GUI. This makes for a bit more coding within the class, but avoids potential name clashes with both attributes added to self by the Tkinter framework, and existing Tkinter widget methods. For instance, if you define a config method in your class, it will hide the config call exported by Tkinter. With the standalone class package in this example, you only get the methods and instance attributes that your class defines. In practice, Tkinter doesn't use very many names, so this is not generally a big concern.[12] It can happen, of course; but frankly, I've never seen a real Tkinter name clash in widget subclasses in some eight years of Python coding. Moreover, using standalone classes is not without other downsides. Although they can generally be attached and subclassed as before, they are not quite plug-and-play compatible with real widget objects. For instance, the configuration calls made in Example 6-21for the Frame subclass fail in Example 6-25.
Example 6-25. PP2E\Gui\Intro\gui7b.pyfrom Tkinter import * from gui7 import HelloPackage # or get from gui7c--__getattr__ added frm = Frame() frm.pack() Label(frm, text='hello').pack() part = HelloPackage(frm) part.pack(side=RIGHT) # fails!--need part.top.pack(side=RIGHT) frm.mainloop() This won't quite work, because part isn't really a widget. To treat it as such, you must descend to part.top before making GUI configurations, and hope that the name top never changes. The class could make this better by defining a method that always routes unknown attribute fetches to the embedded Frame, as in Example 6-26. Example 6-26. PP2E\Gui\Intro\gui7c.pyimport gui7 from Tkinter import * class HelloPackage(gui7.HelloPackage): def __getattr__(self, name): return getattr(self.top, name) # pass off to a real widget if __name__ == '__main__': HelloPackage().top.mainloop() But that then requires even more extra coding in standalone package classes. As usual, though, the significance of all these trade-offs varies per application. |
| I l@ve RuBoard |


/sattracks
Returns line geometries
Parameters
- f : Format (json, ndjson, geojson, txt (default))
- names: Comma separated list of Satellite Names. You can end with * to get Satellites staring with prefix (e.g. GPS*).
- nums: Comma separated list of Satellite Nums. If Nums is specified Names are ignored.
- st: Epoch Time to start default to current time in seconds or milliseconds
- td: Length of time for the line returned in seconds.
- ts: Time step seconds.
Formats
- json: JSON Array
- ndjson: Newline Delimited JSON. Each line is a valid JSON object
- geojson: Valid GeoJSON
- txt: Pipe delimited values. Each event is new line delimited
Fields in Order Returned
- name: Satellite Name
- num: Satellite Number
- geometry: Line
Examples
- Delimited
- JSON
- NDJSON
- GEOJSON


Calculates the tremor (parameters that modulate the pitch period and amplitude of the voice pitch). It is like if the disturbances of the pitch period and the pitch amplitude are due to two modulating signals that modulate the period of average pitch and the average pitch amplitude respectively. In this manner the periodicity and intensity of the disturbance is calculated The algorithm followed by Kay is used for the calculation. Input parameters: vSignal: is the voice section to analyze iFs: is the sample rate of the voice signal. Output parameters: rFftr: frequency of the low-frequency component of higher intensity that modulates the pitch period. rFatr: frequency of the low-frequency component of higher intensity that modulates the pitch amplitude. rFTRI: (Fo Tremor Intensity Index) rATRI: (Amplitude Tremor Intensity Index)


?n
6
7
8
9
10
T
M
v
The
New
York
copyright
reserved
Botanical
Garden
GUANA
ISLAND
TORTOLA,
BVI
Bumella
obovata
(Lam.)
A*DC*
v0^s
BOTANICAL
GARDEN
NEW
YORK
BOTANICAL
GARDEN
Just
inland
fron
North
Beach,
elev.
5-10
ft.
Tree
10
m*
tall
in
sandy
woodland*
coll:
Gaorg*
R.
Proctor,
No,
44911
Fecha:
July
10,
1988
0144363
FLORA
DE
LAS
ISLAS
VIRGENES
Ospartamento
de
Recursos
Naturales
San
Juan,
Puerto
Rico
01443631
Legend -
Level of confidence that token is an accurately-transcribed word
extremely low
very low
low
undetermined
medium
high
very high


1.32 BTC
Payable to
14Z1mazY4HfysZyMaKudFr63EwHqQT2njz
Converted from
:
8 USD
Exchange rate used
:
10.3241 USD
Exchange rate source
:
MtGox.com
Payment received. Thank you!
Debug:
show_idle()
show_payment_info()
show_payment_received()


If this checkbox is selected, the modules without mutual dependencies are compiled simultaneously. This might require increased heap size configs by Build process heap size (Mbytes).


A simple flowchart component made with Vue. Requires a graph-like data structure as an input and renders it as a flowchart.
npm install --save vue-flowter
Import in your component (and the CSS as well):
import 'vue-flowter/flowter.css'
import Flowter from 'vue-flowter'
Vue.component('Flowter', Flowter)
<template>
<flowter :nodes="nodes" :edges="edges">
</template>
<script>
export default {
data () {
return {
nodes: {
a: { text: 'Node A' },
b: { text: 'Node B' },
c: { text: 'Node C' }
},
edges: [
{ from: 'a', to: 'b', text: 'To B' },
{ from: 'a', to: 'c', text: 'To C' }
]
}
}
}
</script>
It would render something like this:
All of the nodes and edges are being positioned and shaped by default, although you can customize it if you want to (but not now, see TODO). The goal is to make creating flowcharts as simple as possible.
If you need more visual customizations, of course you can add your own styling with CSS.
Please see the docs for more details on the props.
npm run install && npm run serve
This will serve the component along with the example of the flowchart data.
npm run test
This will run all the tests using Jest.
This component is not complete. Several things before the first major release:
MIT
Generated using TypeDoc


Singaporean activist leads anti-immigration rally as vote looms
SINGAPORE (Reuters) - Some 300 to 400 Singaporeans on Sunday held a rare rally in a park against the government’s immigration policies, a hot button issue likely to figure in a parliamentary election expected in the first half of next year.
The People’s Action Party (PAP), which has ruled since independence in 1965, suffered its worst showing ever in the 2011 elections, in part due to voter concern over immigration.
Around 40% of the 5.7 million people living on the small city-state are foreign and some Singaporeans are frustrated with the number of immigrants in the city-state, who they accuse of competing for jobs, housing and schooling.
“Singaporeans, it is time to stand up for your rights to a reasonably good job in our own country - we must always adhere to the Singaporean-first slogan and that employment must be given to a local first before we ever consider a foreigner,” Gilbert Goh, the organizer of Sunday’s protest, said in a Facebook post for the event.
Posters reading messages including “We want a Singapore first labor policy” were placed around Speakers’ Corner, a designated site for people to air their views in Singapore.
Many protesters listened to speeches from plastic chairs, some sipping cups of malted milk, while a few waved the Singapore flag.
Public dissent is rare in Singapore where a licence is required to hold a demonstration.
The government has been tightening the inflow of foreign labor over the last few years.
Sunday’s protest followed a viral video showing a man of Indian descent swearing at an elderly local security guard at his condominium complex late last month. Local media reported the man was a naturalized Singapore citizen.
Singapore’s trade and manpower ministries did not respond to emailed requests for comment outside business hours.


Field Edge¶
The field edges are defined at the first point from the centre of the profile where the profile reaches a value of:
\[\cfrac {max-min} {2} + min\]
Where max is the value of the profile on the central axis (CAX) and min is the image or array minimum. If the detector is zeroed to background then min = 0 and we get \(\cfrac {max} {2}\) or the 50% value.
The algorithm searches symmetrically out from the profile centre on both sides of the profile to these points. The value reported is the linear distance from the profile centre to the field edge. The left and right field edge of the profile is given.
Noisy data can lead to a reduced field edge value being reported.
The max and min are affected by the set window levels.


This app serves as an example of using angular 2.0 with webpack. All the modules you see are written in TypeScript. Check out our repo to learn more!
Learn more


---
layout: null
section-type: notes
title: Notes
---
### © Credits
**[Machine-learning]**
[Tensorflow RNN](https://www.tensorflow.org/tutorials/text/text_generation) **|**
[gpt-2-simple](https://github.com/minimaxir/gpt-2-simple) **|**
[aitextgen](https://github.com/minimaxir/aitextgen) **|**
**[Website]**
[personal-jekyll-theme](https://github.com/le4ker/personal-jekyll-theme) **|**
[typewriter image](https://unsplash.com/photos/-m88z7ily-w) **|**
[fav-ico](https://www.flaticon.com/free-icon/robotic_2728279)
**[Timeline images]**
[bacteria-author](https://www.flaticon.com/authors/smashicons) **|**
[messages-author](https://www.flaticon.com/authors/freepik) **|**
[python-author](https://www.flaticon.com/authors/freepik) **|**
[connections (nn)-author](https://www.flaticon.com/authors/becris) **|**
[web ball-author](https://www.flaticon.com/authors/freepik) **|**
[brain with book-author](https://www.flaticon.com/authors/smashicons) **|**
[magic ball-author](https://www.flaticon.com/authors/freepik) **|**


As is traditional at Hooting Yard, on the first of January we bring you the resounding words of Peter Hitchens, first uttered in the Year of Our Lord MMX but ever worth recalling:
I am actively hostile to the ‘New Year’.


The T5.Marker class represents a generic marker for annotating an underlying view. Originally the marker class did very little, and in most instances a T5.ImageMarker was used instead to generate a marker that looked more visually appealing, however, with the introduction of different rendering backends the standard marker class is the recommended option for annotating maps and views as it allows the renderer to implement suitable rendering behaviour which looks good regardless of the context.
In addition to the standard T5.Drawable initialization parameters, a Marker can accept the following:
markerType
- (default = simple)The style of marker that will be displayed for the marker. This is interpreted by each renderer individually.


flibs/strings(n) 1.1 "flibs"
flibs/strings - Tokenizing strings
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
INTERFACE
COPYRIGHT
The tokenize module provides a method to split a string
into parts according to some simple rules:
-
A string can be split into "words" by considering spaces and commas and
such as separating the words. Two or more such characters are treated as
a single such separator. In the terminology of the module they represent
gaps of varying width. As a consequence there are no zero-length words.
-
A string can be split into "words" by considering each individual comma
as a separator. A string like "One,,two" would then be split into three
fields: "One", an empty field and "two".
-
Just like Fortran's list-directed input, the module handles strings with
delimiters: "Just say 'Hello, world!'" would be split in "Just", "say"
and "Hello, world!".
The module is meant to help analyse input data where list-directed
input can not be used: for instance because the data are not separated
by the standard characters or you need a finer control over the handling
of the data.
The module contains three routines and it defines a single derived type
and a few convenient parameters.
The data type is type(tokenizer), a derived type that holds all
the information needed for parsing the string. It is initialised via the
set_tokenizer subroutine and it is meant for the string passed to
the first_token() function. If you want to reuse it for a
different string, but the same definition, simply use
first_token() on the new string.
- use tokenize
-
To import the definitions, use this module.
- call set_tokenizer( token, gaps, separators, delimiters )
-
Initialise the tokenizer "token" with various sets of characters
controlling the splitting process.
otherwise.
- type(tokenizer) token
-
The tokenizer to be initialised
- character(len=*) gaps
-
The string of characters that are to be treated as "gaps". They take
precedence over the "separators". Use "token_empty" if there are none.
- character(len=*) separators
-
The string of characters that are to be treated as "separators".
Use "token_empty" if there are none.
- character(len=*) delimiters
-
The string of characters that are to be treated as
"delimiters". Use "token_empty" if there are none.
- part = first_token( token, string, length)
-
Find the first token of the string (also initialises the tokenisation
for this string). Returns a string of the same length as the original
one.
- type(tokenizer) token
-
The tokenizer to be used
- character(len=*) string
-
The string to be split into tokens.
- integer, intent(out) length
-
The length of the token. If the length is -1, no token was found.
- part = next_token( token, string, length)
-
Find the first token of the string (also initialises the tokenisation
for this string). Returns a string of the same length as the original
one.
- type(tokenizer) token
-
The tokenizer to be used
- character(len=*) string
-
The string to be split into tokens.
- integer, intent(out) length
-
The length of the token. If the length is -1, no token was found.
Convenient parameters:
-
token_whitespace - whitespace (a single character)
-
token_tsv - tab, useful for tab-separated values files
-
token_csv - comma, useful for comma-separated values files
-
token_quotes - single and double quotes, commonly used delimiters
-
token_empty - empty string, useful to suppress any of the
arguments in the set_tokenizer routine.
Copyright © 2008 Arjen Markus <arjenmarkus@sourceforge.net>


StatusService
class StatusService implements StatusService (View source)
Class StatusService.
Status service. Allows registering different \App\Contracts\Services\Status\StatusServiceProvider and will return statuses from those providers.
Properties
| protected | $cache | Application cache store. |
|
| protected | $isCacheEnabled | Whether to cache statuses as they are obtained. |
|
| protected | $cacheTtl | How long to cache the status for. |
|
| protected | $cacheKey | Cache key. |
|
| protected | $providers | Associative array of 'name' => \App\Contracts\Services\Status\StatusServiceProvider. |
Methods
Construct a new status service.
Adds a \App\Contracts\Services\Status\StatusServiceProvider to the service.
Removes the named provider from the service.
Get array of providers registered. Returns an array of \App\Contracts\Services\Status\StatusServiceProvider.
Get array of registered providers names.
Get the status for a provider (or all providers if string 'all' or no param is passed in) or list of providers.
Get the status for an array of provider names.
Resolve statuses of an array of provider names.
Resolves a status for a specific provider.
Check the cache for the given key and return it if it exists, otherwise return null.
Resolve cached status from cache. If no cache entry is found or cannot be resolve, null will be returned.
Saves status in cache.
Details
void
__construct(CacheInterface|null $cache = null, StatusOptions|null $options = null, array $providers = [])
Construct a new status service.
bool
addProvider(string $providerName, StatusServiceProvider $provider)
Adds a \App\Contracts\Services\Status\StatusServiceProvider to the service.
bool
removeProvider(string $providerName)
Removes the named provider from the service.
array
getProviders()
Get array of providers registered. Returns an array of \App\Contracts\Services\Status\StatusServiceProvider.
array
getProviderNames()
Get array of registered providers names.
array
getStatus(string|null $providerName = 'all')
Get the status for a provider (or all providers if string 'all' or no param is passed in) or list of providers.
array
getStatusByArray(array $providers)
Get the status for an array of provider names.
protected array
resolveProviderArray(array $providerNames, string $cacheKey)
Resolve statuses of an array of provider names.
protected array
resolveStatus(string $providerName)
Resolves a status for a specific provider.
protected array|null
checkCache(string $cacheKey)
Check the cache for the given key and return it if it exists, otherwise return null.
protected array|null
resolveCachedStatus(string $cacheKey)
Resolve cached status from cache. If no cache entry is found or cannot be resolve, null will be returned.
protected void
saveInCache(string $cacheKey, array $status)
Saves status in cache.


Projects include the Richland Avenue Pedestrian Passageway, the chemistry building on South Green and a new Heritage College of Osteopathic Medicine building.
Construction for the Richland Avenue Pedestrian Passageway started toward the beginning of the pandemic before students disbanded from campus.
The project is a coordination between the city of Athens and Ohio University. OU is contributing $767,000 to the project, which links West Green to the sidewalk leading to Baker Center and allows cars to pass under it, Jon Cozad, executive director of design and construction, said.
Construction for the chemistry building on South Green also continued and is expected to be complete in September.
The project is budgeted at $42.6 million. Once the equipment is moved from Clippinger Hall into the new chemistry building, renovations will begin on Clippinger Hall at an estimated cost of $33.6 million.
The existing roadway between Race Street and South Green Drive will be demolished, and a new one will be built further from the Chemistry Building with an adjusted elevation. That project will cost approximately $1.87 million.
One of the largest projects that has been worked on over the summer is the new HCOM building, which is scheduled to be complete in November 2020. The building, called Heritage Hall, will hold medical education activities, faculty offices and several HCOM administrative units at 191 W. Union Street.
“The facility will enable the Heritage College to achieve parity in state-of-the-art learning environments across its Athens, Dublin and Cleveland academic campuses, including the technology integration necessary for medical education and research collaborations across the campuses, and will bolster recruitment of outstanding, diverse faculty and students,” Cozad said in an email.
The cost of the project is approximated at $65 million.
Additionally, the current Human Resources Training Center, located on 169 West Union St., will be repurposed for use by the Heritage College and has a budget of $1.1 million. Construction will begin in August.
Other projects around the campus that have been worked on during the summer include the chilled water plant, which was built in anticipation of more HVAC needs on campus, and will provide central air conditioning to Washington Hall and James Hall. The project is estimated to cost $31.5 million. The chiller is located near the intramural fields and is anticipated to be completed in November 2020, Cozad said.
Located a couple houses down from Baker Center, the old presidential residence at 29 Park Place is currently being converted into the Academic Engagement Center. It will house the Center for Campus and Community Engagement, the Ohio Honors Program, and academic programs like the Cutler Scholars Program and the Ohio Fellows Program. The renovation is anticipated to be complete by August 2020.