ImageMenuItem and textview - pygtk

I have menu on my form and gtktextview:
I create imageitemmenu:
self.file_new = gtk.ImageMenuItem(gtk.STOCK_NEW, agr)
key,mod = gtk.accelerator_parse("N")
self.file_new.add_accelerator("activate", agr, key, mod,gtk.ACCEL_VISIBLE)
But when i press n in textview at this time triggered file_new menu
activate... How can i resolve it? And how can i make hot keys for
example CTRL + W + S?
Thank you.

I resolved it!
key,mod = gtk.accelerator_parse("<Control>n")

Related

Selenium not clicking on LIKE button on Instagram

For some reason, the Instagram bot seems to work but selenium is not clicking on the Like button. What may be the issue? Thank you.
unique_photos = len(pic_hrefs)
for pic_href in pic_hrefs:
driver.get(pic_href)
time.sleep(2)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
try:
time.sleep(random.randint(2, 4))
like_button = lambda: driver.find_element_by_xpath('//span[#aria-label="Like"]').click()
like_button().click()
print('Liked!')
for second in reversed(range(0, random.randint(18, 28))):
print_same_line("#" + hashtag + ': unique photos left: ' + str(unique_photos)
+ " | Sleeping " + str(second))
time.sleep(1)
except Exception as e:
time.sleep(2)
unique_photos -= 1
try this :
//article[1]//div[2]//section[1]//span[1]//button[1]//*[local-name()='svg']
and if you want to click on all like button then you need to use below xpath undoubtedly you need list to handle it ::
//article[*]//div[2]//section[1]//span[1]//button[1]//*[local-name()='svg']

Selenium Bot: Irregular Switching of Windows

Once I'm clicking the element More Information, the link is getting clicked and then the window is jumping back to it's previous window and a TimeoutException is being shown.
Code:
self.driver.window_handles
base = "https://outlook.office.com/mail/inbox/id/AAQkADQ0ZmY1YmRkLWExNDEtNGNlYS1iOTZmLTVmNzNjMzhkNjUyMgAQAJmE%2FyrhD0supMphUUSGrmQ%3D"
window_set = {self.driver.window_handles[0], self.driver.window_handles[1]}
for x in window_set:
if(base != x):
self.driver.maximize_window()
wait = WebDriverWait(self.driver, 10)
self.driver.switch_to.window(x)
frame = wait.until(EC.presence_of_element_located((By.NAME, "mainFrame")))
self.driver.switch_to.frame(frame)
element = wait.until(EC.element_to_be_clickable((By.ID, "mc-lnk-moreInfo")))
element.click()
Please HELP!
WebPage Image:(contains both the tabs)
In this image More Information has been clicked and has changed to Less Information
This did the job!
self.driver.window_handles
wait = WebDriverWait(self.driver, 10)
base = self.driver.window_handles[0]
child = self.driver.window_handles[1]
windows = {self.driver.window_handles[0], self.driver.window_handles[1]}
for x in windows:
if(base != x):
self.driver.switch_to.window(x)
frame = wait.until(EC.presence_of_element_located((By.NAME, "mainFrame")))
self.driver.switch_to.frame(frame)
element = wait.until(EC.element_to_be_clickable((By.ID, "mc-lnk-moreInfo")))
element.click()

Set width of toolbar button defined in cl_gui_toolbar

I've got a toolbar defined with class cl_gui_toolbar which is displayed in a container (which got created via class cl_gui_custom_container). I've added some buttons and button groups into it.
Now my user wants one of those button groups to be bigger, because the user might not recognize that the button is there. Is there any method to set the width of the button-group?
Here is my current code:
METHOD init_toolbar.
DATA: lt_buttons_data TYPE ttb_button,
ls_button_data TYPE LINE OF ttb_button.
go_toolbar_container = NEW cl_gui_custom_container( container_name = 'TOOLBAR_1000' ).
go_toolbar = NEW cl_gui_toolbar( parent = go_toolbar_container ).
" Some other buttons
" ...
" ...
CLEAR ls_button_data.
CLEAR lt_buttons_data.
ls_button_data-function = 'DBFILTER'.
ls_button_data-icon = '#EX#'.
ls_button_data-quickinfo = 'Quickinfo'.
ls_button_data-text = 'SmallText'.
ls_button_data-butn_type = cntb_btype_menu.
APPEND ls_button_data TO lt_buttons_data.
go_toolbar->add_button_group( data_table = lt_buttons_data ).
CLEAR ct_expand.
ct_expand = NEW cl_ctmenu( ).
ct_expand->add_function( fcode = '1' text = '1' checked = abap_false ).
ct_expand->add_function( fcode = '2' text = '2' checked = abap_false ).
ct_expand->add_function( fcode = '3' text = '3' checked = abap_false ).
CLEAR wa_ctxmenu.
wa_ctxmenu-function = 'DBFILTER'.
wa_ctxmenu-ctmenu = ct_expand.
APPEND wa_ctxmenu TO table_ctxmenu.
go_toolbar->assign_static_ctxmenu_table( table_ctxmenu = table_ctxmenu ).
ENDMETHOD.
Do you know a way how to set the width of this button-group?
PS: I just got the info, that the text of the button ( e. g. "smallText" ) can be replaced if a longer text, if there is no other way .
It's not possible to customize the width of a button in class CL_GUI_TOOLBAR as a number of pixels.
As a workaround:
Enter a longer text. Maybe enter "non-breaking spaces" at the end of your text. This is the Unicode character U+00A0 (CL_ABAP_CONV_IN_CE=>UCCP( '00A0' )).
Instead of CL_GUI_TOOLBAR, use the class CL_GUI_HTML_VIEWER to define the buttons with HTML code and CSS styles. But I doubt it's worth spending time for that.

Update plot according to updated slider value wit Gtk

In Julia, I'd like to update a plot upon the change of value in a Gtk Slider. I understand that this has to do with the "change-value" signal in https://developer.gnome.org/gtk2/2.24/GtkRange.html#GtkRange-value-changed. However, as a beginner, I do not know how to implement the code
The “change-value” signal
gboolean
user_function (GtkRange *range,
GtkScrollType scroll,
gdouble value,
gpointer user_data)
to achieve what I wanted to do. Could anyone kindly provide an example how to use the "change-value" signal?
I know how to set up a window for the slider
sl = slider(1:11)
win = Window("Testing") |> (bx = Box(:v))
push!(bx, sl)
Gtk.showall(win)
I also know what kind of function I need to update the plot
function update(val)
int_val = int(val)
if Signal(sl) != int_val
x = range(0., 2*pi, step=0.01)
y = map(sin, x)
PyPlot.plot(x,Signal(sl)*y)
end
end
However, I don't know how or where I can trigger the "update" function to take actual action.
Thanks!
Thanks, liberforce for your advice!
Here is my minimal working example:
'''
using Gtk
# Set up scale (slider) and window
sl = GtkScale(false, 0:10)
win = Gtk.Window("Gain Selection") |> (bx = Gtk.Box(:v))
push!(bx, sl)
Gtk.showall(win)
# Connect with value-changed signal
id = signal_connect(sl, "value-changed") do widget
# Get scale value
sub = Gtk.GAccessor.adjustment(widget)
val = Gtk.get_gtk_property(sub,"value",Int64)
# Perform function related to the scale value.
println("Gain is changed to ", val)
end
push!(bx, sl)
Gtk.showall(win);
'''
Reference:
signal connect: http://juliagraphics.github.io/Gtk.jl/latest/manual/signals.html
GtkScale: https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Scale.html
Extract scale value: https://discourse.julialang.org/t/how-to-get-the-current-value-of-a-gtk-scale-widget/15680
Julia Do-block: https://www.juliabloggers.com/julia-do-block-vs-python-with-statement/

How to get an outline view in sublime texteditor?

How do I get an outline view in sublime text editor for Windows?
The minimap is helpful but I miss a traditional outline (a klickable list of all the functions in my code in the order they appear for quick navigation and orientation)
Maybe there is a plugin, addon or similar? It would also be nice if you can shortly name which steps are neccesary to make it work.
There is a duplicate of this question on the sublime text forums.
Hit CTRL+R, or CMD+R for Mac, for the function list. This works in Sublime Text 1.3 or above.
A plugin named Outline is available in package control, try it!
https://packagecontrol.io/packages/Outline
Note: it does not work in multi rows/columns mode.
For multiple rows/columns work use this fork:
https://github.com/vlad-wonderkidstudio/SublimeOutline
I use the fold all action. It will minimize everything to the declaration, I can see all the methods/functions, and then expand the one I'm interested in.
I briefly look at SublimeText 3 api and view.find_by_selector(selector) seems to be able to return a list of regions.
So I guess that a plugin that would display the outline/structure of your file is possible.
A plugin that would display something like this:
Note: the function name display plugin could be used as an inspiration to extract the class/methods names or ClassHierarchy to extract the outline structure
If you want to be able to printout or save the outline the ctr / command + r is not very useful.
One can do a simple find all on the following grep ^[^\n]*function[^{]+{ or some variant of it to suit the language and situation you are working in.
Once you do the find all you can copy and paste the result to a new document and depending on the number of functions should not take long to tidy up.
The answer is far from perfect, particularly for cases when the comments have the word function (or it's equivalent) in them, but I do think it's a helpful answer.
With a very quick edit this is the result I got on what I'm working on now.
PathMaker.prototype.start = PathMaker.prototype.initiate = function(point){};
PathMaker.prototype.path = function(thePath){};
PathMaker.prototype.add = function(point){};
PathMaker.prototype.addPath = function(path){};
PathMaker.prototype.go = function(distance, angle){};
PathMaker.prototype.goE = function(distance, angle){};
PathMaker.prototype.turn = function(angle, distance){};
PathMaker.prototype.continue = function(distance, a){};
PathMaker.prototype.curve = function(angle, radiusX, radiusY){};
PathMaker.prototype.up = PathMaker.prototype.north = function(distance){};
PathMaker.prototype.down = PathMaker.prototype.south = function(distance){};
PathMaker.prototype.east = function(distance){};
PathMaker.prototype.west = function(distance){};
PathMaker.prototype.getAngle = function(point){};
PathMaker.prototype.toBezierPoints = function(PathMakerPoints, toSource){};
PathMaker.prototype.extremities = function(points){};
PathMaker.prototype.bounds = function(path){};
PathMaker.prototype.tangent = function(t, points){};
PathMaker.prototype.roundErrors = function(n, acurracy){};
PathMaker.prototype.bezierTangent = function(path, t){};
PathMaker.prototype.splitBezier = function(points, t){};
PathMaker.prototype.arc = function(start, end){};
PathMaker.prototype.getKappa = function(angle, start){};
PathMaker.prototype.circle = function(radius, start, end, x, y, reverse){};
PathMaker.prototype.ellipse = function(radiusX, radiusY, start, end, x, y , reverse/*, anchorPoint, reverse*/ ){};
PathMaker.prototype.rotateArc = function(path /*array*/ , angle){};
PathMaker.prototype.rotatePoint = function(point, origin, r){};
PathMaker.prototype.roundErrors = function(n, acurracy){};
PathMaker.prototype.rotate = function(path /*object or array*/ , R){};
PathMaker.prototype.moveTo = function(path /*object or array*/ , x, y){};
PathMaker.prototype.scale = function(path, x, y /* number X scale i.e. 1.2 for 120% */ ){};
PathMaker.prototype.reverse = function(path){};
PathMaker.prototype.pathItemPath = function(pathItem, toSource){};
PathMaker.prototype.merge = function(path){};
PathMaker.prototype.draw = function(item, properties){};