How to enable autorefresh of structure view in Pycharm? - python

How can I force refresh in structure view or enable autorefresh in Pycharm. After any code update clicking on function does not work anymore (should jump to function code). Only possibility is to hide and show view but it loose context and I need search function name again what is bad idea with larger code.

Related

How to put Bokeh interactive maps on a Website?

How to do upload my interactive bokeh maps I created on a website? I read the documentation and used the file_html function to create the html code, but all the functionality does not work like the select drop down, and sliders. What is the best way to share it on a website?
This is the warning I received.
This is the Warning I received. WARNING:bokeh.embed.util: You are generating
standalone HTML/JS output, but trying to use real Python callbacks (i.e.
with on_change or on_event). This combination cannot work. Only JavaScript
callbacks may be used with standalone output. For more information on
JavaScript callbacks with Bokeh , see:
http://bokeh.pydata.org/en/latest/docs/user_guide/interaction/callbacks.html
I tried to make that error message as self-contained as possible. I am not sure what else can be added to it, but suggestions are welcome. There are two scenarios:
Standalone output
This is purely HTML and JS content, that has no connection with any running python process. It is most often generated with output_file and show (or save), but it's also what you get if you use the lower level file_html function. Since there is no Python process anywhere after the output is created, there is no possible way for "real" Python callbacks to function, at all. In this case, the only possible callbacks that can work are JavaScript ones, e.g. CustomJS added with js_on_change or js_on_event. That's because the browser viewing the (purely HTML and JS) content does not know anything about Python, it only knows about JavaScript.
Bokeh Server Applications
This is a continuously running Bokeh server that serves Bokeh content, and,
most crucially: maintains an active connection to that content. That means that when some event happens, e.g. a slider changes, the Bokeh server can run real Python callback code in response. That is, in fact, the primary reason the Bokeh server exists: to be the thing that runs real Python code for an on_change or on_event callbacks. If you want to run real Python code (e.g. Numpy or Pandas or whatever) in response to events, you must run a Bokeh server.
Right click on the generated site in a web browser and select "Inspect". Then open the "console" tab and you list of errors will be detailed there. My guess is that you are not referencing a javascript file correctly.

Change auto_zooming parameter at runtime on cefpython

I have a Flask app that render some page on localhost:3000. To display correctly this page on every computer i use chromium browser (Basically WXpython example from cefpython3 with minor changes: https://github.com/cztomczak/cefpython/blob/master/examples/wxpython.py). However on some computers that have a different resolution/zoom level i have to re-run the code with a different value of parameter 'auto_zooming' in order to display correctly the page:
...
zoom = '0'
settings = {'debug': False, 'auto_zooming': zoom}
cef.Initialize(settings=settings)
...
My question is: There is any way to change the zoom level of Cefpython browser without have to rerun the code everytime i want to change the zoom? I was thinking on something like 'ctrl - +' or 'ctrl - -'.
Thanks in advance,
Ricardo
Can't you detect zoom level before initializing CEF?
The auto_zooming option will call SetBrowserDpiSettings C++ function. It sets zoom level constantly in a 50 ms timer. You can implement similar functionality in pure Python. It uses four functions and their Python equivalents are: Browser.SetZoomLevel, Browser.GetZoomLevel, cef.DpiAware.GetSystemDpi and cef.PostDelayedTask.
See the C++ function source code here:
https://github.com/cztomczak/cefpython/blob/6f5bf081fec19647e1860bb3e0f3638c02bb9d11/src/client_handler/dpi_aware.cpp#L163

PyQt: Basic example of accessing and adding a submenu to an existing context menu?

Note: I have very little python and PyQt experience...
Given a context menu already created, I'm looking for a functional example of how I would gain access to that context menu, so it can be extended for a plugin which is doing the python equivalent of a javascript greasemonkey script. Then I'm also looking for a functional example of how I could add a submenu to that context menu. Thanks!
The customContextMenuRequested signal would be connected to a method/function (called a slot in Qt), look for a line of code that resembles this to get an idea of what method/function you need to adjust:
self.centralwidget.customContextMenuRequested.connect(self.context_menu_method)
so for that example you would need to adjust self.context_menu_method, that is what is actually creating the menu
and for a code example of how to add a submenu:
menu = QtGui.QMenu()
submenu = QtGui.QMenu(menu)
submenu.setTitle("Submenu")
menu.addMenu(submenu)
Avaris' comments basically answered this question the best. I can't select it, though, because it's comments, rather than an answer. So I'm summarizing that answer here, so this Q can be answered:
"If you are given a context menu (QMenu to be specific) you can access it." - Avaris
"You can't do this without modifying that file [the one containing the context menu creation code]. It assumes it has given a list of QActions (see line 301) and it wouldn't be expecting QMenu. Though, if you can get to the plugin_menu reference in your plugin, that's a different story." - Avaris
So either you can access to manipulate the menu in the same file (and same place in that file) where the menu creation/definition code is, or you can gain access to do so via that file (in the same place) exposing the menu via an API. On the flip side, if you don't have such API access, and/or modify that file/function, then there's no way to do this.

How to make PowerBuilder UI testing application?

I'm not familiar with PowerBuilder but I have a task to create Automatic UI Test Application for PB. We've decided to do it in Python with pywinauto and iaccesible libraries. The problem is that some UI elements like newly added lists record can not be accesed from it (even inspect32 can't get it).
Any ideas how to reach this elements and make them testable?
I'm experimenting with code for a tool for automating PowerBuilder-based GUIs as well. From what I can see, your best bet would be to use the PowerBuilder Native Interface (PBNI), and call PowerScript code from within your NVO.
If you like, feel free to send me an email (see my profile for my email address), I'd be interested in exchanging ideas about how to do this.
I didn't use PowerBuilder for a while but I guess that the problem that you are trying to solve is similar to the one I am trying to address for people making projects with SCADA systems like Wonderware Intouch.
The problem with such an application is that there is no API to get or set the value of a control. So a pywinauto approach can't work.
I've made a small tool to simulate the user events and to get the results from a screencapture. I am usig PIL and pytesser ORM for the analysis of the screen captures. It is not the easiest way but it works OK.
The tool is open-source and free of charge and can be downloaded from my website (Sorry in french). You just need an account but it's free as well. Just ask.
If you can read french, here is one article about testing Intouch-based applications
Sorry for the self promotion, but I was facing a similar problem with no solution so I've written my own. Anyway, that's free and open-source...
I've seen in AutomatedQa support that they a recipe recommending using msaa and setting some properties on the controls. I do not know if it works.
If you are testing DataWindows (the class is pbdwxxx, e.g. pbdw110) you will have to use a combination of clicking at specific coordinates and sending Tab keys to get to the control you want. Of course you can also send up and down arrow keys to move among rows. The easiest thing to do is to start with a normal control like an SLE and tab into the DataWindow. The problem is that the DataWindow is essentially just an image. There is no control for a given field until you move the focus there by clicking or tabbing. I've also found that the DataWindow's iAccessible interface is a bit strange. If you ask the DataWindow for the object with focus, you don't get the right answer. If you enumerate through all of the children you can find the one that has focus. If you can modify the source I also advise that you set AccessibleName for your DataWindow controls, otherwise you probably won't be able to identify the controls except by position (by DataWindow controls I mean the ones inside the DataWindow, not the DataWindow itself). If it's an MDI application, you may also find it useful to locate the MicroHelp window (class fnhelpxxx, e.g. fnhelp110, find from the main application window) to help determine your current context.
Edited to add:
Sikuli looks very promising for testing PowerBuilder. It works by recognizing objects on the screen from a saved fragment of screenshot. That is, you take a screenshot of the part of the screen you want it to find.

How to interact through vim?

I am writing an editor which has lot of parameters that could be easily interacted with through text. I find it inconvenient to implement a separate text-editor or lots of UI code for every little parameter. Usual buttons, boxes and gadgets would be burdensome and clumsy. I'd much rather let user interact with those parameters through vim.
The preferable way for me would be to get editor open vim with my text buffer. Then, when one would save the text buffer in vim, my editor would get notified from that and update it's view.
Write your intermediate results (what you want the user to edit) to a temp file. Then use the $EDITOR environment variable in a system call to make the user edit the temp file, and read the results when the process finishes.
This lets users configure which editor they want to use in a pseudo-standard fashion.
Check out It's All Text!. It's a Firefox add-in that does something similar for textareas on web pages, except the editor in question is configurable.
You can also think about integrating VIM in to your app. Pida does this

Categories