How to place widgets like labels & buttons with `.pack()`? - eclipse

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.

Related

Ionic show ion-refresher programmatically

i want to display the ion-refresher programmatically. e.g on the first page load i load the data and want to show the ion-refresher. i've not found any build in function only _beginRefresh. this function will fire the refresher, however it will not set the style attribute TOP on the refresher element. therefore it is hidden behind the NAV.
currently i've created a dirty workaround.
let scrollcontent = document.getElementsByClassName('ion-page')[0].getElementsByTagName('ion-content')[0].getElementsByClassName('scroll-content')[0]
let rect = scrollcontent.getBoundingClientRect()
document.getElementById('refresher').style.top = rect.top.toString() + 'px'
this.myRefresher._beginRefresh()
i'm wondering if there is a better aproach.
thanks
ok i've found a better approach...
#ViewChild(Content) ContentDashboard: Content;
this.RefresherDashboard._top = this.ContentDashboard.contentTop.toString() + 'px'
this.RefresherDashboard._beginRefresh()

Press, hide button in ChartContainerContent in UI5 fiori

Hi all SAP UI5 and FIORI positive,
I have ChartContainer with button for graph and button for table. It is defined in xml file as:
<suite:ChartContainerContent id="idButtonChart"
icon = "sap-icon://bar-chart"
title = "Chart"
>
<suite:ChartContainerContent id="idButtonTable"
icon = "sap-icon://table-view"
title = "{i18n>table}">
<suite:content>
Let's say I want to hide some of these buttons which are placed inside ChartContainer. I have tried (in controller.js part):
this.getView().byId("idButtonChart").setVisible(false);
or
this.getView().byId("idButtonChart").setVisible(false);
But this code, hided graph but not button. Please, do you have any idea how to hide button? Or to trigger click event on button idButtonTable?
Thanks for any advices.
Have you found any good solution for this issue? I've been checking the SDK and I can't find a way to get those buttons in an straight way.
Anyway, you could do it using the following code -
var chartContainerContent = this.getView().byId('your chart id');
var chartContainer = chartContainerContent.getParent();
var aToolbarButtons = chartContainer._oToolBar.getContent();
var segmentedButton;
for(var i=0; i<aToolbarButtons.length; i++){
var button = aToolbarButtons[i];
if(button.getMetadata()._sClassName === "sap.m.SegmentedButton"){
segmentedButton = button;
break;
}
}
//segmentedButton.getButtons()
Once you get the buttons you can setVisible(false) to the one you want.
Of course this is not the best, but the chartContainer doesn't provide any public function to get the buttons of the chart.
I try to understand the issue. You define 2 charts in your example.
The buttons are usually used to switch the display to the corresponding chart.
How are you going to switch between the 2 charts if you hide the corresponding button?
A little late but I guess an .updateChartContainer() after the .setVisible should do the trick:
this.getView().byId("idButtonChart").setVisible(false);
this.getView().byId("<NAME OF THE CONTENT CONTAINER>").updateChartContainer();

Changing colours for button which have got a focus

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?

Label on HeaderIcon in HeaderControls

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.

Hiding cursor in Text component in Eclipse RCP application

In my eclipse RCP application there are a few buttons & few input boxes & this below Text component. My problem is as soon as I press one of the buttons a cursor starts blinking in the below test component. Can you please let me know how to solve this.
I tried:
setting focus to false for Text.
SWT.READ_ONLY for Text .
Code:
Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_NO);
protocolFilterDescription.setCursor(cursor);
Nothing seems to get rid of this unnecessary cursor.
protocolFilterDescription = new Text(parent, SWT.NONE | SWT.READ_ONLY );
FormData protocolFilterDescriptionLData = new FormData();
protocolFilterDescriptionLData.left = new FormAttachment(0, 1000, 650);
protocolFilterDescriptionLData.top = new FormAttachment(0, 1000, 290);
protocolFilterDescriptionLData.width = 450;
protocolFilterDescriptionLData.height = 12;
protocolFilterDescription.setLayoutData(protocolFilterDescriptionLData);
protocolFilterDescription.setForeground(new Color(parent.getDisplay(),
204, 153, 0));
protocolFilterDescription.setBackground(Display.getCurrent()
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
protocolFilterDescription.setFont(new Font(parent.getDisplay(),"Verdana",
6, 1));
protocolFilterDescription
.setText("captured");
You have to set the focus of some other SWT component to true to remove the focus from the Text component.
You'll probably have to do this in an ActionListener.
If you want to completely remove the cursor from the Text control (which implies inability to perform a selection there, etc), try calling setEnabled(false) on it.
Also, such requirement suggests that you maybe don't need Text component at all, and could use Label instead.