Changing text with Labview Toggle switch? - labview

I'm new to Labview and was wondering if the following was possible:
Can you switch the same text box using a toggle switch? I have tinkered around and figured that I need the selector when displaying output but can't seem to get anywhere.
ex. When toggle switch is true = show a text on front panel that says on
When toggle switch is false = change the SAME text to off.

While I reckon there is more to your question, without any constraints, this is this the easiest way: use a string indicator and give it a new value when the toggle switch changes position.
Example
VI Snippet

The previous answer is good, but to be more precise consider using select instead of case structure. The select works lighter in LabVIEW.
In situations when you just have to pass this or that data (your case), not perform code (ex: Popup something in true case and enable a counter in false case) you should consider using selector, as in case structure you create additional tunnel, which can be avoided using Select.

If you just want some text next to the switch that changes to show the state of the switch, you can do this without any code:
Right-click on the toggle switch and choose Show > Boolean Text.
You should now see the word ON or OFF in the middle of the switch.
Right-click on it again and choose Advanced > Customize….
LabVIEW will now open the control editor window. The first button in this window's toolbar looks like a spanner (wrench); click it and it should change to a pair of tweezers.
Select the ON or OFF text and move it to where you would like it to be, relative to the switch itself.
Close the control editor window. You can save the control as a separate file if you want to reuse it elsewhere, but if you don't it will still be saved as part of your VI.
You can edit the Boolean Text on your VI's front panel in the normal way. Note that clicking on the boolean text when the VI is running will operate the switch - you may or may not want that to happen. You could get round this by placing a transparent decoration box on top of the text.
All Boolean controls (I think) have a Boolean Text property, but not all of them have it visible by default.

Related

Best way to edit long text in a QTableWidget cell?

What I want to achieve: an easier way to edit longer text (one or two paragraphs) in a QTableWidget cell.
The problem: resizeRows wraps the text in the cell when the table is displayed. However, if I try to edit the cell, all the text appears on one line which makes it awkward to edit.
What I've tried: I tried implementing a QTextEdit widget for editing:
class EditDelegate(QStyledItemDelegate):
def createEditor(self, parent, option, index):
editor = super().createEditor(parent, option, index)
if isinstance(editor, QLineEdit):
textedit = QTextEdit(parent)
textedit.setPlainText(editor.text())
return textedit
That fixed the editing problem, although I have to rely on the edit box losing focus to save the text. However, after editing, the default QTableWidgetItem now shows HTML in the edited cell. I had thought that using setPlainText() would prevent this. The only text entered was "THE NOTE TEXT", seen in the middle of this screenshot:
If I then try to edit the cell again, the HTML is stripped out and just the original text ("THE NOTE TEXT") remains in the QTextEdit box until again I exit the editor.
Questions:
Is my approach a good way to implement multiline editing in a
QTableWidget?
If so, how can I get rid of the HTML markup that the
QTableWidgetItem is now displaying?
Since you only need a multiple line editor and no formatting (colors, text style, etc.) then use QPlainTextEdit.
The reason behind the returned HTML is that the default property (see the USER attribute) of QTextEdit is html: item delegates use the USER property as default to set the value of the editor and then set it back on the model, meaning that setEditorData() will behave like using setHtml() and setModelData() like toHtml().
The user property for QPlainTextEdit is just plainText, so there will be no conversion in either case.
Also note that your implementation of createEditor() will potentially raise an exception if the default editor is not a QLineEdit (if the data uses numbers or Qt dates/times), since textexit is only declared in the if, but that's a bad way to do so anyway (you're creating a widget that won't be used).
Besides, calling textedit.setPlainText(editor.text()) is useless, because at that point the editor is still empty and it will be filled only by setEditorData() (which would overwrite its contents anyway).
A more correct approach would check the data type and return the editor accordingly, then let the delegate fill the widget in its own.
def createEditor(self, parent, option, index):
if isinstance(index.data(), str):
return QTextEdit(parent)
return super().createEditor(parent, option, index)
Finally, be aware that many have tried to implement multiple line editors in item views, and very few attempts actually achieve a valid result. Many issues are related with the available item geometry, cursor navigation, UX aspects and focus management, and almost any solution has to accept some level of compromise that many users might find annoying. The most common acceptable (and less "hated") solution is to use an external editor, either shown in another part of the UI or through a dialog window.

In IntelliJ IDEA, how do I use the keyboard to highlight an arbitrary checkbox?

For example, if I press Ctrl-Alt-P to extract a parameter, pressing Tab on the resulting dialog box moves directly from "Name" to "Refactor". I know I can work around this by using Alt+key to select a checkbox (e.g., Alt+a for replace all), but as AltGr doesn't work I have to contort my left hand to hit this combination. How do I, using the keyboard, select the first checkbox, so I can use space to change it?
The only way to access the checkboxes in this dialog is via mnemonics (Alt+underlined letter).
There is also an open issue to add tabstops for checkboxes and radio buttons in the refactoring dialogs so that they can be accessed not only by the mnemonics, but also by cycling the components using Tab:
IDEA-154127 Extract refactorings: navigation and mnemonics problems
There is really nothing you can do about it until tabstops are explicitly implemented for these dialogs.

Assign value to property node

I starting using LabVIEW about 1 week ago. In a tutorial I watched this picture
I am wondering how can I assign the value "Disabled and Grayed out" to disabled property value of the button?
There are a couple of ways to create property nodes in LabVIEW. This method is the quickest and easiest and matches your picture.
Add the button to your front panel.
Right-Click and go to Create >> Property Node >> Disabled in the menus. Click on this.
LabVIEW will automatically switch to the block diagram and let you drop the property node.
By default it is a read node. Right-Click on the block where it says "Disabled" and select Change To Write in the menu (There is also Change All To Write if you have multiple properties.
Hover over the input so you get the wiring symbol. Right-Click and select Create Constant to create the correct Enum constant to write to it.
That is the basics and the way most people start out - a couple of extra tips:
The node is expandable hover at the bottom and you get the resize block, drag this down and you can set more than one property on the same node. These are set in order from top to bottom.
Left click on each property to change which property it is.
Right-Click and go to Link To... in the menu to change which button it applies to.

In RealStudio, how can I intercept pasting of rich text?

I'm trying to create a simple text field for WYSIWYG editing. However, I only want to allow certain types of formatting (e.g. Bold, Italic, Underline and a single heading type but no colors or different fonts.)
The issue is if I use an editor that can accept formatting, someone can create or copy formatted text in another program, then simply paste it into the text field and all that formatting goes with it, allowing things I'm not interested in, such as different fonts, colors, etc. I don't want to allow that.
At best, I want to automatically strip out any formatting that I don't support. At worst, I want to simply paste whatever as plain text making them have to reformat it. But in no case do I want to just dump the clipboard to the text area.
Any thoughts on how to do this?
I would recommend creating a new text field/text area class and creating an EditPaste menu handler that (a) does what you're looking for in terms of handling the clipboard's text and (b) returns true to prevent the default pasting from happening. This is safer than using the Key down events because the user might manually select paste from the edit menu.
You can access the text on the clipboard by creating a Clipboard object.
To subclass the textfield and intercept the paste menu command:
With your Project open, go to Project Menu > Add > Class
Select the new class in the project's tab and in the properties panel set the super to TextField
Double-click on the class to edit it
Click the "Add Menu Handler" mid-toolbar button in your class
Change the menu item name to "EditPaste". Put your code in before the "return true" and be sure to leave the return true in there.
Your code can then format and paste the text manually and override the default paste function.
Any command-V or control-V in that text field will cause that menu handler to fire. Any contextual menus would be added by you anyway since real basic does not create the default contextual menus, so you'd have control over that as well.
To add the text field to a window, just change the filter above the objects list to Project controls, and drag the class in from there.
You could intercept the paste yourself by intercepting it in the KeyDown events. Then, you could look to parse it yourself. That could be kind of tricky but I think that's about the only way you could do it.
It might just be easier to parse the resulting StyleRun after the paste and strip out formatting you don't want.
Alternately, you could look at the Formatted Text Control from True North Software and override the paste methods of the control (you get all the source) and just handle it yourself.
Either way, I think it will be a fair amount of work.

Is it possible to make a statusbar like notepad in VB?

I made a notepad using vb 2008 and I am facing a problem who I'd make the Statusbar.
any idea will be great.
Note: I am using the Textbox to read and write text
Thank you
You need to add a StatusStrip control to your form.
To find it, open the Toolbox, expand the "Menus & Toolbars" section, and double-click on the one named "StatusStrip".
Double-clicking on the control in the Toolbox will automatically add it to your form, and dock it along the bottom, just like it is in Notepad.
Once the control is there, you can customize it by changing properties in the Properties window. If you want to add information to the status bar, you do that by adding sub-controls inside of it. Click the drop-down arrow next to the "new" icon, and you'll see a list of possible choices:
"StatusLabel" — displays static text
"ProgressBar" — displays a progress bar, indicating the progress of a background operation
"DropDownButton" — displays a drop-down button, to allow a choice of multiple options
"SplitButton" — displays a drop-down button that allows a choice of multiple options, but also invokes the default option by a single click on the button.