I want to put a label next to an icon so user can better understand what is this clickable icon for.
This icon appear in the HeaderControl of a com.smartgwt.client.widgets.Window
String promptNewThing = "Add some thing";
String imgNewThingText = "../servlet/servletOperation?cmd=Icon&time=" + System.currentTimeMillis() + "&text=" + promptNewThing;
HeaderIcon iconNewThing = new HeaderIcon("buttons/new.png");
HeaderIcon iconNewThingLabel = new HeaderIcon(imgNewThingText);
newThing = new HeaderControl(iconNewThing, clickHandlerNewThing);
newThing.setPrompt(promptNewThing);
newThingLabel = new HeaderControl(iconNewThingLabel, clickHandlerNewThing);
newThingLabel.setPrompt(promptNewThing);
setHeaderControls(HeaderControls.HEADER_LABEL, NewThing, NewThingLabel, HeaderControls.MINIMIZE_BUTTON, HeaderControls.MAXIMIZE_BUTTON, HeaderControls.CLOSE_BUTTON);
For information : In this code, Servlet URL return an image made from the text promptNewThing
But iconNewThingLabel is an Icon which has the width of an Icon, too small.
The result of this code :
The small white square we can see between first Icon is newThingLabel.
Is there a way to add a label at the right of an HeaderIcon ?
For example I would to have something like :
Hello Manu I have done the same thing as you have done. The only change is instead of adding HeaderIcon (iconNewThingLabel in your case - if it's representing the text), I have used a com.smartgwt.client.widgets.Label & added that as a headerControl. Code snippet is as follows:
Label label = new Label("test header");
setHeaderControls(HeaderControls.HEADER_LABEL, NewThing, label, HeaderControls.MINIMIZE_BUTTON, HeaderControls.MAXIMIZE_BUTTON, HeaderControls.CLOSE_BUTTON);
Let me know if this helps you.
Related
I use DotNetBar controls. I can change colours for buttons with:
Office2007ColorTable table = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
Office2007ButtonItemColorTable bt = table.ButtonItemColors[6];
bt.Default.Background = new LinearGradientColorTable(Color.White);
bt.MouseOver.Background = new LinearGradientColorTable(Color.Green);
Unfortunate I cannot find how I can change colour for a focused button.
Is it possible?
Hello i am asking for help on a PyDev Eclipse problem i cold not find a solution on at this forum. My example below show that i have a window with a couple of labels and buttons etc. But the ting is that when i searched earlier i found posts on how to place widgets using .grid() and .place() but not any for .pack() which i am using. Therefor i want to know what would be the best way for me to place these widgets for example in the center of the parent window.
Thanks in advance. :D
window.title("PTF Pydev Eclipse")
window.geometry("500x500")
window.config(bg="blue")
frame = tk.Frame(window, bg="blue")
lbl = tk.Label(frame, text= "secret")
lbl.config(background="blue", width="500")
ent = tk.Entry(frame)
lbl1 = tk.Label(frame, text= "secret", bg="blue")
ent1 = tk.Entry(frame)
lbl2 = tk.Label(frame, text= "secret", bg="blue")
btn = tk.Button(frame, text="secret", command= lambda: validation())
btn2 = tk.Button(frame, text="secret", command=lambda: page1())
lbl3 = tk.Label(frame, bg="blue", text="secret")
ent2 = tk.Entry(frame) #these 3 are packed in a function (not included).
lbl.pack()
ent.pack()
lbl1.pack()
ent1.pack()
lbl2.pack()
btn.pack()
frame.pack()
window.mainloop()
Do not use pack if you want to control the exact position of each widget.
Your window is 500x500, right ?
So for example if you want to place a widget at the top left of your window, you could to
Yourwidget.place(x=10, y=10)
Hope It helps, good luck.
I'm designing a UI with Enthought's TraitsUI, and I can't figure out how to get done what I want...
Here's what I want:
I have Items() in the view that I want to display as either English or SI units. I can change the value in the 'edit' box based on a SI/English button, but I can't figure out how to change the text of the label. For example, if I have an item 'Length, ft [ 3.28]' and convert it to SI, I'd like it to show 'Length, m [ 1.00]'. I can handle the 3.28->1.00 conversion, but can't figure out how to change the 'ft' to 'm'.
Any suggestions?
One thing I've tried is to define a string which holds the units name (like 'm' or 'ft')...then, in the item, I set the label like this:
label = 'Top, '+lengthUnits
This works fine when the view is first built, but it doesn't update the label when I change the units control. Is there some way to force the view to update with all the new values?
Here's a small py program that shows what I'm trying to do (feel free to critique my style :)). I'll also try and add in a couple of images that shows what happens:
# NOTE: This version of the code has been modified so that it works as I want it to :)
# Example trying to change text on a View...
from traits.api \
import HasTraits, Enum, CFloat, String
from traitsui.api \
import View, Group, HGroup, Item, spring
class TestDialog ( HasTraits ):
length = CFloat(1.0)
choose_units = Enum('English', 'SI')
current_units = 'English'
unit_name = String('ft')
ft_to_m = CFloat(3.28)
view = View(
Group(
HGroup(
spring,
Item(name = "length", label = 'Test length'),
Item(name = 'unit_name', style = 'readonly', show_label = False),
spring
),
HGroup(
spring,
Item(name = "choose_units"),
spring
)
),
title = 'Test Changing View Test'
)
def _choose_units_changed(self):
if self.current_units != self.choose_units:
if self.choose_units == 'SI':
self.length /= self.ft_to_m
self.unit_name = 'm'
else:
self.length *= self.ft_to_m
self.unit_name = 'ft'
self.current_units = self.choose_units
# Run the program (if invoked from the command line):
if __name__ == '__main__':
# Create the dialog:
TestIt = TestDialog()
# put the actual dialog up...
TestIt.configure_traits()
Use a notification as described here: http://code.enthought.com/projects/traits/docs/html/traits_user_manual/notification.html
Update in response to updated question:
Right, labels are not dynamically updated. Instead, make a text field that looks like a label, e.g. with:
label_text = String('Test length, English:')
Then display it in your View with something like:
Item("label_text", style='readonly', show_label=False),
You'll probably also want to use an HGroup nested inside your (V)Group, to position it to the left of your "length" display.
Then modify label_text inside your listener.
I have a Database with this fields: Firstname, Lastname, picture.
I have a gtk.Label named infoLabel.
I would like to update the label a way like this:
Label.set_markup("<img src='pix/1.png'>\nName" + Firstname + " " + Lastname)
But it isn't works, because img isn't allowed in Pango markup. How I can do this?
Here is an example of a "Home" label.
label_with_icon = gtk.HBox()
icon = gtk.image_new_from_stock(gtk.STOCK_HOME, gtk.ICON_SIZE_MENU)
label_with_icon.pack_start(icon)
label_with_icon.pack_start(gtk.Label('Home'))
label_with_icon.show_all()
I wouldn't expect to be able to have an image in label, no.
But you should be able to replace any label with a container holding a GtkImage and the label, and solve it that way.
Of course you will have to have the image in local memory, first.
This is based on John La Rooy's answer, but I had to make some adjustments. Don't know why, maybe due to a different version of the library or something.
label_with_icon = gtk.HBox()
icon = Gtk.Image.new_from_file("/path/to/file.png") # not .image_new_from_file
label_with_icon.pack_start(icon, False, False, 0) # this method takes five args
label_with_icon.pack_start(gtk.Label('a caption'))
label_with_icon.show_all()
Using iTextSharp i'm trying to align an image so that it gets embedded in a paragraph. I can do it like this:
iTextSharp.text.Image image;
image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP;
document.Add(image);
document.Add(new Paragraph("Large string of text goes here"));
But the image comes out on the top right with the text surrounding it (kind of like an L)
What I want is the text to be a few paragraphs then the image with text below it (kind of like a C). Does anyone know how I would do this VIA iTextSharp?
Edit:
I also tried
iTextSharp.text.Image image;
image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP | Image.ALIGN_MIDDLE;
document.Add(image);
document.Add(new Paragraph("Large string of text goes here"));
But it was displayed with the image at the top and the text below it. There was no textwrap in effect.
The Phrase and the Paragraph objects do behave differently. Try changing to:
image.Alignment = 6;
document.Add(image);
document.Add(new Phrase("Large string of text goes here"));
This worked for me in VB. ( I had to change the image alignment to the sum of the integer values for ALIGN_RIGHT and TEXTWRAP to get this to work properly).
ALIGN_RIGHT = 2
TEXTWRAP = 4
Your image was displayed at the top of the page because it was the first thing added to the document, and the text was added after it.
You can move the image down by either setting its absolute position, or by adding some of your text to the document, then adding the image, then adding the rest of your text.
The easiest way to embed image into paragraph is to use InlineImage from PDFFlow library.
InlineImage was created exactly for this purpose.
Example of adding an inline image with margins:
var imagePath = "imageFile.png";
DocumentBuilder.New()
.AddSection()
.AddParagraph()
.AddTextToParagraph("Inline image")
.AddInlineImage(imagePath, new XSize(16, 16), ScalingMode.UserDefined)
.SetMarginLeft(8)
.SetMarginRight(8)
.ToParagraph()
.AddText("in paragraph.")
.ToDocument()
.Build("Result.pdf");
The above code will generate the following:
Here are business documents examples with source code: Examples.
Hope, this will help.