Is it possible to use the Sublime Text 3 quick panel to retrieve user input as the goto_line command does?
When I hit CTRL+G, a quick panel appears and I can hit enter with any value. I cannot do this when I use this panel manually
If I use the quickpanel without values, I cannot validate it and therefore cannot retrieve the value inserted by the user.
I'm trying to do a plugin to create a Lua addon skeleton for a game, and I need to retrieve multiple user inputs as follows:
Is it possible to use the quick panel or I must use the show_input_panel multiple times ?
AFAIK there is no way to accept arbitrary input from a quick panel. Input is simply used to fuzzy filter the list.
For your plugin, here's a crazy idea: maybe you can create a snippet with text and fields for the input you want. Your plugin can have a command which when run creates a new scratch buffer where you insert this snippet. Once the user has filled out the fields, they can either run another command, or simply close the view (your plugin should have a listener for that event) to execute and do whatever.
Related
I am working on a mini-project where I take a simple python function from the user using Tkinter(textbox widget) and then execute it and plot its time taken to execute with change in input value. How can I execute the code taken as input from the textbox widget?
Or should I go with some predefined functions based on general algorithms.
Get the text from the whole TextBox with:
text = self.my_text_box.get("1.0", tk.END)
And then run the code with:
exec(text)
But be aware than this allows the user to run ANY CODE he wants.
I am automating the creation of a new product with a Python script and have run into a problem with the interactive events getting stuck at the "Part Number" dialog. This does not occur when creating a new part, just a new product. Here is the applicable portion of the script (CATIA is open):
import win32com.client.dynamic
CATIA = win32com.client.Dispatch("CATIA.Application")
catDocs = CATIA.Documents
# Create a new product
newProductDoc = catDocs.Add("Product")
# "Part Number" window appears, requesting a name for the product
# Interactive processes will not proceed
newProduct = newProductDoc.Product
newProductSet = newProduct.Products
newPart = newProductSet.AddNewComponent("Part", "dummyPart")
...
The problem is that I am developing a small tool for others to use and it is not very useful if it hangs up.
Clicking on "Cancel" gets rid of the dialog box, but no interactive actions occur afterwards. Clicking on "Ok" resolves the problem, but it would be preferable for the script to be able to prepare the product as a final result without interaction in order to restrict user error and improve ease of use.
I know that I can create a product and manipulate it (i.e. add parts, add new products, etc.), then successfully save it. So the processes are being executed, they just aren't being displayed anymore. I just can't seem to find a way to get past the "Part Number" dialog box. I even tried naming it programmatically, which worked but didn't kill the dialog box.
Opening an existing product works very well, and any scripting processes can continue without problems. However, programmatically creating the product, saving, and closing causes CATIA to lock up... so the option of saving and re-opening as an existing product is out the window.
I also referenced the v5Automation.chm, but I couldn't find a way of interacting with dialog boxes.
I also tried .Update() on the new product and it's parts. Some other assurances were CATIA.Visible = True and CATIA.RefreshDisplay = True.
Disclaimer: I know that VBA can be used and does not pose this problem. I am looking for a solution to this problem using Python (2 or 3, doesn't matter).
This post is old but since I found this page when having the same issue I figured I'll add my solution. I've found a handful of methods in CATIA that behave this way - works fine in CATIA VBA but not through the COM interface. The best solution I've found is to write a mini VBA function in a string and then call it in CATIA through Python. Here is an example:
import random
import win32com.client
CATIA = win32com.client.GetActiveObject('CATIA.Application')
CATVBALanguage = 1
# This should work, but CATIA leaves up the dialog window and it can affect
# the rest of the code execution
# NewProductDocument = CATIA.Documents.Add('Product')
# Instead, write the code in VBA and then have CATIA execute it. You can
# pass in arguments and capture the results as demonstrated below.
CREATE_PRODUCT_VBA_CODE = '''
Public Function create_product(part_number as CATBSTR) as Document
Set create_product = CATIA.Documents.Add("Product")
create_product.Product.PartNumber = part_number
End Function
'''
PART_NUMBER = 'test_product_{}'.format(random.randint(1, 100))
NewProductDocument = CATIA.SystemService.Evaluate(
CREATE_PRODUCT_VBA_CODE, # String with the VBA code to execute
CATVBALanguage, # 1 to indicate this string is VBA code
'create_product', # VBA function to call and return result from
[PART_NUMBER] # Array of arguments, in order for VBA function
)
# Can still interact with this returned object as if we had created it
print(NewProductDocument.Product.PartNumber)
The only way I have found, so far, to circumvent this problem is to create a template product (in this case, just an empty product) and do a catDocs.NewFrom(<templateProductPath>) and add the product structure as necessary.
I was trying to replicate your issue, but I dind't encounter it. Products just created fine using incremental default names.
Then I thought it was something related to Settings since the dialog is simlar to the one that optionally pops up when addin a new part.
I discovered that I had the option Infrastructure > Product Infrastructure > Product structure > Part Number: Manual input unchecked.
I don't know how this was related to using VBA or not, but checking it created the issue and unchecking it removed the issue, while still sending the same command from Python.
Is there any way that I can build an interactive text console using wxPython window application? It will be used to allow user to provide natural language input for the application to parse the grammar based on the language selected. It is not going to be used to run any shell or commands.
You can use a wx.TextCtrl for input and then when the user is done typing, you can have them press a button to do whatever checking you want done. Alternatively, you could use a wx.Timer to watch for idleness so when the user is idle for x seconds, it does the checking you want automatically too.
I've got a wxPython application where I'm using an AuiNotebook, and HyperlinkCtrl widgets, to present the user with an interface sort of like tabbed web browsing.
Currently I open links in new tabs, or the current one, depending on the kind of link, etc. I'd like to let the users control whether or not they get a new window by having them control-click links. I can't find any way of doing that, though.
Thus: In my HyperlinkEvent handler, how can I determine if the user was using any keyboard modifiers while clicking?
use wx.GetKeyState(int id):
(docs)
Get the state of a key (true if pressed or toggled on, false if not.)
This is generally most useful getting the state of the modifier or
toggle keys. On some platforms those may be the only keys that this
function is able to detect.
if wx.GetKeyState(wx.WXK_CONTROL):
# open in new tab
else:
# open in new windows
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