pygtk drawing area not calling expose-event - pygtk

Using glade 3.8 , i created a hbox and I name the object as hboxvideo.
In my program , I add a drawing area to hbox video.
self.hboxvideo = self.builder.get_object("hboxvideo")
self.video_drawing_area=gtk.DrawingArea()
self.hboxvideo.pack_start(self.video_drawing_area,True,True,0)
self.video_drawing_area.connect("expose-event", self.area_expose_cb)
The problem is drawing area never signals "expose-event". Also these statements are called only after the main window is exposed. Any one how can I solve this issue ?
Thanks in advance,
Thothadri

I got the answer. When I imported hbox from glade and if you dynamically add widgets to it you need to show them. But if glade is not used, you just have to do window.show_all() once. In the case of glade everytime i add a dynamic widget using hbox, i need to show them.

Related

Adding custom GTK# widget to Glade catalog

I've created a custom widget (with my own drawing) in C# using GTK# 3 toolkit.
Now i want to use it in Glade designer.
Is it possible to add this widget to Glade palette?
It seems that this documentation:
https://developer.gnome.org/gladeui/unstable/catalogintro.html
can be used to add widgets written in C/C++ to Glade palette, but what is the correct way to get the same result for widgets written in C#?
Thanks.
It may not be possible. The way to approach it would be to write a shim library in C that uses libmono to interoperate with your C# widgets. Here is a link to Mono's documentation on how to do that. The entry point into your shim library would then be listed in the <init-function> element in the Glade catalog.
Alternatively, you can "fake" the widget classes in the Glade catalog; their properties and signals will appear (though you have to manually write them in the catalog file.) If they are container widgets you won't be able to add child widgets to them. They'll just appear as grey boxes in Glade. You do this by adding <glade-widget-class> elements to the catalog as described on this page of Glade's documentation.

Unreal Engine 4 Blueprint

Im new to unreal
I have a problem with the communication from Hud_Blueprint to Level_Blueprint.
I want to have a slider in the Hud which controls the rotation of a cube in the level.
In the Hud_Blueprint i have the slider I made in a Widget_Blueprint.
Works perfect, printline values from 0 to 1.
I tried to use a Interface_Blueprint, like in the following link without success.
https://answers.unrealengine.com/questions/22126/pass-variable-from-hud-blueprint-to-level-blueprin.html
my Blueprints:
https://www.dropbox.com/s/k30ah9fjuwlff6x/zusammen.jpg?dl=0 (404 response)
Seems like i have no connection between the Blueprints.
The function works just in the Hud_Blueprint.
Well, your problem is maybe solved, but someone can find it helpful:
First, create new WidgetBlueprint and name it "Slider".
In Slider editor create Event Dispatcher called "ValueChanged" with float input. In designer, add slider and add it's OnValueChanged. From that node you must call ValueChanged with obtained Value as parameter.
In level blueprint, on EventBeginPlay create SliderWidget and Add (return value) To Viewport. You must promote Slider to variable to use it in next step - Assign ValueChanged with new event which will cover up rotation login in it's execution. See image at Dropbox
If you select your cube in the level outliner and drag that into your HUD_BP you can obtain a reference to the object that way. You can then drag a pin off the object reference and call SetActorRotation

QML Component Screen Rendering

Is it possible to capture the screen rendering of a QML Component and save it to an image file? I would like to drive a Component through several different states, and capture its visual appearance for documentation purposes, without having to do screen/window captures.
Yes, you could set up your state transitions to call QWidget::grab then save it to a file through QPixmap.
If you need an example of how to set up your code to call QWidget::grab take a look at this answer: How to take ScreenShot Qt/QML
It's important to replace QPixmap::grabWidget with QWidget::grab because QPixmap::grabWidget is now obsolete. Once you have the QPixmap from QWidget::grab follow the documentation in QPixmap to save to the format you'd like such as jpeg, png, gif.
Here are some links to the documentation to help you out.
QWidget::grab
QPixmap
QPixmap::save
With Qt 5.4 it is now made easier with grabToImage - this method resides on all QQuickItem objects.
EDIT
It's worth mentioning that the item you call grabToImage() on must be a child of a top-level Window item container

How to set a JavaFX Stage/Frame to Maximized

I'm using JavaFX 2. I want my frame to open maximized but I'm not seeing a way. I searched a bit on the internet without success. For the stage I see setFullScreen() and setIconified() but I don't see anything like setMaximized().
The Java 8 implementation of the Stage class provides a maximized property, which can be set as follows:
primaryStage.setMaximized(true);
When evaluating the sourcecode of the Ensemble.jar provided with the samples of JavaFX 2.0 SDK, the currently valid way to achieve window maximizing is
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
(you find similar code in WindowButtons.java)
The 'maximize' button is still enabled and when clicking it, the windows will grow a bit more (Windows OS). After this the 'maximize 'button is disabled. In the provided example the standard buttons are replaced. Maybe this is still an issue.
Better use Multi-Screen compatible maximize logic:
// Get current screen of the stage
ObservableList<Screen> screens = Screen.getScreensForRectangle(new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()));
// Change stage properties
Rectangle2D bounds = screens.get(0).getVisualBounds();
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
try this simpler code
primaryStage.setMaximized(true);
and it fills up the whole screen
. note that if you remove maximize/minise buttons the application will fill the whole screen as well as remove the taskbar so mnd your initStyles if you have any
Use this to remove the Minimise, Maximise Buttons :
primaryStage.initStyle(StageStyle.UTILITY);
Where primaryStage is your Stage object.

PyGtk: change image after window's main() method?

I'm using a gtk.Image widget to display a picture in a gtk window. I can set the image to be displayed before I call window.main(), but after I've done that the image won't change any more. Basically:
import pygtk
pygtk.require('2.0')
import gtk
(...)
window= Window()
window.canvas= gtk.Image()
window.window.add(sprite.window.canvas)
window.canvas.show()
window.canvas.set_from_file("pic1.gif")
window.main()
window.canvas.set_from_file("pic2.gif")
pic1.gif will be displayed. Is there a proper way of changing the image (I don't care if I have to use a widget other than gtk.Image)? All I can think of is destroying the window and creating a new one.
Edit:
I realized my mistake... I called window.main() for every window and any window's destroy event called gtk.main_quit(). Had to make slight adjustments, but it works now. Even after calling window.main() :)
As Rawing hasn't yet accepted his own answer, I'll post it to get this off the top of the unanswered questions page, and to help out anyone skimming this from a search engine clickthrough by providing a comprehensive answer. (Rawing, feel free to post your answer yourself, all the same.)
In your code, you're declaring window as Window(), as opposed to gtk.Window. If you're building in one window, you should not need to do this every time. Create the window once, add what you need to it. If you need additional windows, declare them separately in this module, and call them from code (instead of from main).
Furthermore, don't name your objects with a "window." at the beginning...that just gets overly confusing. Give it a simple name, add it where you need it. Python will do the rest.
A cleaned up version of your code above would probably look like this:
window = gtk.Window()
#You may need additional arguments above, such as to make it top level.
canvas = gtk.Image()
window.add(canvas)
canvas.show()
canvas.set_from_file("pic1.gif")
Now, just change the image in an event or another "def", like this:
def ChangePicture():
canvas.set_from_file("pic2.gif")
Canvas should update the picture automatically.