Create link without line or word numbers - livecode

Is there a way to create a link without giving specifications with location?
For example:
I have an xml url that I have loaded into a variable "tLink" which occurs within multiple nodes (using a repeat function). I want to have text such as "Click here to find out more" to be a clickable link which takes the user to the specified url for that node. I can't seem to get textStyle etc to work with variables. How can I do this?

I think Scott got it almost right but I suggest that you set the linkText to the actual link:
set the linkText of word 1 to 2 of field "myLinkField" to "http://livecode.com/
Now you can use that in your linkClicked:
on linkClicked pLink
launch url pLink
end linkClicked

See if the following gets you close to the behavior you want.
Create a new field -- "myLinkField" -- and put the text "Click here to find out more" in the field. Select the first two words ("Click here") and set the text style of the words to link. Lock the text of the field and set the autoHilite of the field to false. Now execute this the message box:
set the linkText of word 1 to 2 of fld "myLinkField" to "tLink"
Now edit the script of the field object to read like this:
on linkClicked pLink
put "http://www.google.com" into tLink
launch url value(pLink)
end linkClicked
Now when clicking the link text of the field, you should see the Google home page launch in your browser.
If you only want to test the value of the clicked text, you can use:
put value(pLink)
... to place the link text in the message box.

Related

Converting a string automatically into a link to a pdf document

I've done some looking around in here and on the internet and it doesnt seem super obvious, but my question is can python using tkinter be used to automatically convert a text string into a link that loads a pdf from a certain direction
e.g. data '12345 Issue A' pops up in a text widget and is automatically converted to a link that when clicked opens up a pdf document.
Can this or can it not be done ?
In this case I'm wanting to be able to click 1931-125, 699-126 and 1851-127 and have each open up a pdf file of the same name. This is being used in a manufacturing environment and allows an assembler to click the fields and have all the documents they need to build a certain item
First off to apply formatting to parts of a Text widget you will need to understand about tags, in most cases you can probably just use the phrase of the link (ABC123) just remember that:
The name of a tag can be any string that does not contain white space or periods.
once you have a tag for the link there are two parts:
Formatting the tag to look and react like a link.
Applying the tag to the phrases in text.
The first one is really simple if you just want it to be blue and underlined and respond to being clicked:
def format_link(text_widget,tag,command):
text_widget.tag_config(tag,foreground="blue",underline=1)
text_widget.tag_bind(tag,"<Button-1>",command)#remember that the command will need to take an event argument
Although this could get more complicated if you want the cursor to change when hovering over or colour to change after clicking etc.
The second part is to apply this tag to the text automatically which I'm assuming means parse the text after it is inserted into the widget. This is also very simple by putting this answer in a loop so that it checks for every occurrence of the phrase:
def apply_tag(text_widget,phrase,tag,regexp=False):
countVar = tk.IntVar(text_widge)
idx = "1.0"
while idx:
idx = text_widget.search(phrase,idx, stopindex = "end",
count = countVar, regexp = regexp)
if idx:
end_idx = "%s + %sc" %(idx, countVar.get())
text_widget.tag_add(tag, idx, end_idx)
idx = end_idx
Then all that is left is defining the way to open the file in another program and then calling the two above functions, using os.system("open"...) to open files it could be as simple as:
def make_link(text,phrase,file_to_open):
def callback(event=None):
os.system("open %r"%file_to_open)#there are better ways of handling this
apply_tag(text,phrase,phrase)#uses phrase as tag
format_link(text,phrase,callback)
Although you might want to look at answers here or it's duplicate for alternatives for opening files.
after inserting the text into the widget, assuming you have some sort of list of phrases to turn into links, you can just loop over the phrases and call make_link for each one:
phrases = {"1931-125", "699-126", "1851-127"}
for s in phrases:
make_link(TEXT_W, s, s+".pdf") #make a link to same name with .pdf added to end.

netsuite - inline html

I am trying to use a custom column as a hyperlink to a external site. Meaning,
In PO detail page, I want to add a custom column and I want the value of it to have the following HTML content.
Try Google
So when I go to the PO detail page I want to have a link to google.com.
How can I do this? I tried this as Inline HTML, Free-form Text and Rich text. none of them gave me a link.
I found 1 way of doing this using .
1. I added a Inline HTML field.
2. I added the default value for that as a <iframe> block which sends data to my service point.
3. In the service point I created the link (<a>) neede for that PO and print it.
That worked for me.
I had this same problem and finally found the answer. You need to create a field as Inline HTML and then enclose the link and the url in single quotes, concatenating with double pipes:
'Search Google'
More help can be found here:
http://www.netsuiterp.com/2019/06/highlighting-url-link-custom-field.html

OpenWrt luci web interface logo picture and modify strings

I am trying to modify the web interface of bootstrap theme in OpenWrt's luci web interface and i managed to change colors and some simple things but i cannot find how to change the names of the tabs (for example instead of "status" to write "status11111"). Also i wanted to add a logo picture on the top of the page and i managed to add it for the login page and also it appears on the default main page after the login but then if I swap to any tab the picture appears like crashed or missing (see the image bellow) and the link becomes like this "/cgi-bin/luci/;stok=96c966ea63a7913b6c02fc09c7862d77/admin/status/overview".
My 2 questions are: how can I change the names of the tabs and how can I add a logo picture on the top of the page so it can appear to every tab? What files do I have to modify?
For question #1 "how to change the names of the tabs", you want to look in /usr/lib/lua/luci/controllers/admin
There will be a number of files including "index.lua", "status.lua", "network.lua", etc. If, for example, you wanted to change the name of the status tab from "Status" to "New Status Tab Name", you would go into status.lua and find the line:
entry({"admin", "status"}, alias("admin", "status", "overview"), _("Status"), 20).index = true
and replace it with:
entry({"admin", "status"}, alias("admin", "status", "overview"), _("New Status Tab Name"), 20).index = true
For question #2, what exactly did you edit when you added the image?

PySide/PyQt Text in QTextBrowser disappears after clicking on a link in it

I have the following variable appended to 'QTextBrowser'. It does appear as a link, but when I click on it all the text in the 'QTextBrowser' disappears. All the function the 'anchorClicked' signal is connected to does is print something in the shell so that I know that the signal was received.
word = '<a href>' + '<span style="background-color:#C0C0C0">' + word + '</span>' +'</a>'
self.textBrowser.anchorClicked.connect(self.test)
def test(self,argv_1):
print('!!!')
Probably what's happening is that the text browser is attempting navigate to the href specified in the anchor. But since the href is empty, it just shows a blank page.
If you want to stop automatic link navigation, try this:
self.textBrowser.setOpenLinks(False)
(NB: the anchorClicked signal will still be sent when the link is clicked).
You can also prevent this behaviour by calling self.textBrowser.setSource(QtCore.QUrl()) in the function connected to the anchorClicked signal (in your case test()).
For an example, see what I did in my answer to your other question here: https://stackoverflow.com/a/19475367/1994235
This allows you to still have some links that take you to other pages, and some that don't (you call the above line of code to prevent the page change, only when certain urls are passed to your function)
Use html2text to download the URL to matching directory for every link on the page. Reformat as HTML, adding headers and rewiring the links. Then do this recursively every time you click on a link and you effectively have a working web browser. The links will actually work. I would like to see someone do it in less than 3 pages if they can.

CKEditor 3.x add text to dialog

I disabled the advanced & target tabs from the link dialog, and only left the URL input box.
Actually what I did is exactly explained here: http://peterpetrik.com/blog/remove-tabs-and-elements-from-ckeditor-dialog-window
My question is, is it possible to add a text string to the dialog (as my supplement hints for users.) ?
Yes, you can use " add(elementDefinition, nextSiblingId) ", to add elements to the dialog.
From the code on the page in your link, I added "infoTab.add" before the "infoTab.remove" entries:
infoTab.add(
{
type : 'html',
html : '<div id="myDiv">Supplemental <b>hint</b>.</div><br />'
},
'linkType'
);
// Remove unnecessary widgets from the 'Link Info' tab.
infoTab.remove( 'linkType');
infoTab.remove( 'protocol');
The nextSiblingId is used to place the new element above an existing element.
I assigned "linkType" as nextSiblingId to place the new element above the url input box.
To place the new element between the url input box and the browse button, replace 'linkType' with 'browse' ( 'browse' is the id assigned to the browse button in the definition for the link dialog ).
To place the new element below the button, just remove ( , 'linkType' ).
Between this information and that found on the page you linked to, you should be able to accomplish your goal.
If you want to get a better understanding of your options, you can look at the following files:
The source files for the link dialog:
http://docs.cksource.com/ckeditor_api/symbols/src/plugins_link_plugin.js.html
http://docs.cksource.com/ckeditor_api/symbols/src/plugins_link_dialogs_link.js.html
http://docs.cksource.com/ckeditor_api/symbols/src/plugins_link_dialogs_anchor.js.html
The source files are also in your CKEditor directory:
ckecitor/_source/plugins/link/
The CKEditor documentation is located here:
http://docs.cksource.com/
Some relevant info from the CKEditor API:
CKEDITOR.dialog
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.html
CKEDITOR.dialog.definition.html
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.html.html
CKEDITOR.dialog.definitionObject
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definitionObject.html
CKEDITOR.dialog.definition.contentObject
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.contentObject.html
Be Well,
Joe

Resources