-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
creating sample hbox output IP result #9
Comments
Dialog is visual control and container (displays window and it can contain one control or container) If you meant to have button with IP, you can add it directly to dialog: Dialog(Button("x.x.x.x")) Common usage is to put another container into Dialog, one that can contain multiple controls, e.g. Vbox, Hbox, etc. let btn = Button( "x.x.x.x")
let dlg = Dialog(
Vbox(
btn)) Or if it is input use Text(), and Label("some text") if you are displaying static text. let btn = Button( "Exit")
let txt = Text()
txt.value = "x.x.x.x"
let dlg = Dialog(
Vbox(
txt,
btn)) Take look at niup/text.nim |
Its not a static IP though.
|
Here is slightly modified file Added missing niup import import std/[httpclient, strutils, strformat]
import niup
var textLabel: Text_T # global, so it can be accessed from callbacksi, init later, after IUP Open()
# Create an exit button proc
proc button_exit_callback(ih: PIhandle):cint {.cdecl} =
# exists the main loop
return IUP_CLOSE
const src = "https://icanhazip.com"
proc Ip*(): string =
var client = newHttpClient()
try:
let response = client.getContent(src)
result = response.strip()
except:
let
e = getCurrentException()
msg = getCurrentExceptionMsg()
echo "Got exception ", repr(e), " with message ", msg
result = ""
finally:
client.close()
return result # there was recursive call to Ip()
proc button_show_ip(ih: PIhandle): cint {.cdecl.} = # every callback has cint as return value
textLabel.value = Ip()
return IUP_DEFAULT
# create main proc and open UIP application
proc mainProc =
Open()
# create 3 variables (label, button, vbox)
# var
# label = Label("Hello, IUP from nim.")
# button = Button("Hit me to close")
# vbox = Vbox(label, button) # add button and label to vertical box
# # add attributes to variables
# vbox.alignment = IUP_ACENTER
# vbox.gap(10)
# vbox.margin(30, 60)
textLabel = Text("IP address") # declared globally so it can be accessed from callback
textLabel.readonly = true
var
button_h = Button("Show Ip Address")
#textLabel_output = Label(Ip)
hbox = Hbox(textLabel, button_h)
# add dialog box to show title of UIP application
hbox.alignment = IUP_ACENTER
hbox.gap(20)
hbox.margin(20, 70)
var dlg_h = Dialog(hbox)
dlg_h.title = "Hello horizonal window"
#button_h.action = button_show_ip
opacity(dlg_h, 115) # horizonal box now has opacity
# call backs
button_h.action = button_exit_callback
button_h.action = button_show_ip
# show UIP application
#ShowXY(dlg, IUP_CENTER, IUP_CENTER)
ShowXY(dlg_h , IUP_CENTER, IUP_CENTER)
MainLoop()
Close()
if isMainModule: # if main module than call mainProc()
mainProc()
I recommend to go through IUP tutorial (left side navigator: Tutorial) To learn IUP basics, philosophy behind it. |
So I went through UIP tutorial and more and started to drill into NUIP , playing around with a lot of the attributes.
|
Don't have experience with design, try: In theory dynamic destroy/create of Label control could work, but I haven't tested it or seen examples of it. |
Its weird , if you put border = "yes" , you can really see it , but if you put to "no" then its just faded but still can see it. |
For IUP details best bet is to ask on mailing list. subscribe to mailing list: or browse mailing list archive: https://webserver2.tecgraf.puc-rio.br/iup/en/prod.html#suporte |
Unable to find a way to remove the border from a textbox , moving on. |
Trying to figure out what to use for an output, do I use a dialog box or show or something else?
I would like to create a box with a button that shows your own IP address. Also opacity works great I was able to use opacity on a full window.
The text was updated successfully, but these errors were encountered: