Updating Element style via Karax (noobish?)

2020-03-18 Thread hrm
Hi, I'm newbie. Nice to meet all of you. I'd like to **updating element 's 
style by event handler** set by Karax. So I wrote like this, but it doesn't 
work. (With click, text changes but style doesn't update. )


var mystyle = newJSeq[cstring]()
mystyle.add cstring"transform"
mystyle.add cstring"translateX(0px)"
var t: string = "For many years, computer programmers have been"

proc mainHtml(): VNode =
  result = buildHtml(main(id="main", class="main", style = mystyle )):
text t
proc onclick(ev: Event, n: VNode) =
  t = "callback is triggered well"
  mystyle.setAttr(transform, "translateX(150px")

proc main(): VNode =
  return buildHtml(tdiv):mainHtml()
setRenderer main



Run

May be the code around `setAttr` is wrong, so I read Vstyles.nim but couldnt 
make my understand where is wrong. Anybody could help?


Help prlm this Time

2020-03-18 Thread JPLRouge
hello : help

work sql 


type
  Date* = ref object of RootObj
Data*   : DateTime
Null*   : bool
  
  Temps* = ref object of RootObj
Data*   : DateTime
Null*   : bool

proc sql*(a: Date): string =
  if a.Data.format("-MM-dd") == "0001-01-01" and a.Null == true : 
return "null"
  else : return fmt""" "{a.Data.format("-MM-dd")}" """
proc sql*(a: Temps): string =
  if a.Data.format("HH:mm:ss") == "00:00:00" and a.Null == true : return 
"null"
  else :
return fmt""" "{a.Data.format("HH:mm:ss")}" """ 

Run


  a.Data =parse("20:10:05","HH:mm:ss")

Run


 : return fmt""" "{a.Data.format("HH:mm:ss")}" """

Run


/home/soleil/.choosenim/toolchains/nim-1.0.6/lib/pure/strformat.nim(562, 
18) &
/home/soleil/NIMGUI/GUISQL/var.nim(105, 15) Error: could not parse 
`a.Data.format("HH`.
/home/soleil/.choosenim/toolchains/nim-1.0.6/lib/core/macros.nim(557, 15) 
Error: closing " expected

Run

is good DATE 


 : return fmt""" "{a.Data.format("-MM-dd")}" """   = "2020-03-18"

Run

other


 sql*(a: Temps): string =
  if a.Data.format("HH:mm:ss") == "00:00:00" and a.Null == true : return 
"null"
  else :
var h : string = a.Data.format("HH:mm:ss")
return fmt""" "{h}" """ 

Run

this ok



 this  a.Data =parse("20:10:05","HH:mm:ss")

Run

can you explain to me why please


Re: Help prlm this Time

2020-03-18 Thread treeform
I think the problem is that the strformat's fmt macro is not good enough to 
realize that date format is not part of it's format. So it gets confused. That 
is why you get the error:


: could not parse `a.Data.format("HH`.

Run

I recommend doing what you already done:


""" "{h}" """

Run

Format your date into a string variable, include the string in your final 
format. 


Nimble raiseOSError: cannot install a package

2020-03-18 Thread JazzPlayer
Greetings, everyone! I'm new to the Nim programming language.

I'm trying to use nimble to install a package, but every time I get an error. 
For example, when I'm trying to install the package _arraymancer_ , the 
following error is output:


Downloading https://github.com/mratsim/Arraymancer using git
oserr.nim(94)raiseOSError
Error: unhandled exception: O sistema não pode encontrar o arquivo 
especificado.
Additional info: "Requested command not found: \'git ls-remote --tags 
https://github.com/mratsim/Arraymancer\'. OS error:" [OSError]

I don't know if there is something wrong with my git, but I couldn't fix the 
error. Could someone help me?


Re: Recommended GUI library?

2020-03-18 Thread Lachu
Python have TCL in standard library (in reference implementation).


Re: Type inference as proc return value

2020-03-18 Thread cmc
Thanks for letting me know! Reported the error message (or the behavior) as a 
bug  because I thought it too 
hard to get confirmation of what's going on, fingers crossed.

As a followup, is it correct that when there are several generic types, and at 
least one of them is the return type, that all types must be specified to the 
generic, even if the information would be available to infer both?


type
  Foo = object
foo: int
bar: int
  
  Fuz = object
fuz: float
buz: float

proc init[T, U](o: T): U =
  discard o
  result = U()

# works
let foo = Foo()
let fuz = init[Foo, Fuz](foo)

# fails with "cannot instantiate U" (expected)
# let foo = Foo()
# let fuz:Fuz = init(foo)

# fails with "Error: cannot instantiate: 'init[Fuz]'; got 1 type(s) but 
expected 2"
# Can this be made to work with a different syntax?
# let foo = Foo()
# let fuz:Fuz = init[Fuz](foo)

echo foo
echo fuz


Run


Re: Recommended GUI library?

2020-03-18 Thread oyster
the choice depends on your desire heavily. if you just need some button, 
dialogue box, most of the gui lib maybe work. but if you need grid/cell, web 
browser and math/latex, only maybe the famous wxdigets/qt, and not so famous 
iup can work.


Re: Nim lang for Raspberry Pi devices

2020-03-18 Thread lucian
> The device pluged work on 250k bod : "Unsupported baudrate..."

What value are you using exactly for "250K"? That error comes straight from the 
setSpeed of the posix driver. There is a list of standard baud rates supported. 
Try lowering or setting explicitly to 115200 , ex:


#Section: Reading from/writing to a serial port (echoing data)

# use 9600bps, no parity, 8 data bits and 1 stop bit
port.open(9600, Parity.None, 8, StopBits.One)

# You can modify the baud rate, parity, databits, etc. after opening the 
port
port.baudRate = 115200


Run

Make sure the RPi UART is set to support whatever speed you want (it seems to 
depend on Pi version ; ref: 
[https://www.raspberrypi.org/documentation/configuration/uart.md](https://www.raspberrypi.org/documentation/configuration/uart.md)
 with further links to the UART can be found in the SoC peripherals at the 
bottom of that page); 115200 is pretty standard and a good start value. 


Re: Recommended GUI library?

2020-03-18 Thread oyster
there is a C interface to fltk by D. J. Peters for freebasic language. But 
since dynamic library is supplied, we can use FLTK-C in other language. As a 
result, I translate the rich freebasic examples into nim. You can check it at 
[https://github.com/retsyo/FLTK_nim](https://github.com/retsyo/FLTK_nim)

However, I use windows, maybe you have to adjust the code to make it runs on 
Linux.

BTW, is it possible to change the theme in FLTK? The default looking is too 
nostalgic. 


Re: Module Introspection

2020-03-18 Thread Lomar
Appreciate the explanation. I apologize for my previous criticism. 


Re: Module Introspection

2020-03-18 Thread Araq
> I quite don't understand why this is bad. I mean how is python achieving it 
> through OOP and not a "meta" concept like macros? It's just a private 
> function in each object and some external functions belonging in the standard 
> library.

It's bad because depending on how it's implemented it means I cannot rename 
private symbols to something else because thanks to introspection the name 
could have leaked into the outside world. 


Re: Nim lang for Raspberry Pi devices

2020-03-18 Thread PMunch
How are you trying to read from the serial in Nim?


Re: Is this a gc:arc memory leak bug or not?

2020-03-18 Thread Araq
Fixed with Nim devel.


Re: Type inference as proc return value

2020-03-18 Thread Hlaaftana
Return value type inference like this does not exist in Nim unfortunately


Re: How to start a Jester server?

2020-03-18 Thread adnan
I removed the entire project and started from the scratch and it works now. I 
think there was something wrong with my nimcache.


Re: How to start a Jester server?

2020-03-18 Thread enthus1ast
That's a weird issue Indeed! Can you check if you have saved your file. Or that 
you are compiling the correct one? (maybe "cat twitter.nim" reveals the issue?).

Also check your imports if there is anything fishy going on.

Then if you have triple checked and it's still not working, I would consider 
cleaning the nim cache, just remove everything that's in there, and recompile 
with "nim c -f -r twitter.com"


Re: Module Introspection

2020-03-18 Thread Lomar
Lol, now I get why nim is fighting so many years to convince for its value and 
get some proper funding.

You're the benevolent, no one can force anyone to do something that they don't 
agree to, yet still the lack of a serious explanation, results in less 
confidence, at least to a part of the community.

Consider how low penetration the language has to businesses and you realize the 
origins & identity of the above group.

Esoteric course/goals/mission, lack of proper explanation to long term 
decisions & arrogance. The irc channel community shares the same 
communicational toxicity.

Its cool. Not the 1st, neither the last stalled tool. 


Re: How to start a Jester server?

2020-03-18 Thread juancarlospaco
`nim c -r file.nim` _" Works on my machine"_ :)


Type inference as proc return value

2020-03-18 Thread cmc
Hi everyone!

I'm working on getting a better hang of generics. I found generics can use type 
inference if the object is passed as a parameter, but needs to be explicitly 
stated if it is a return value.


type
  Foo = object
foo: int
bar: int

proc init[T](): T =
  result = T()

proc stringify[T](o: T):string =
  return $o

# fails with "cannot instantiate"
# let t:Foo = init()

# works
let t = init[Foo]()

# works
echo stringify(t)




Run

Is this how it's supposed to work or did I miss something?


Type Inference

2020-03-18 Thread cmc
Hi everyone!

I'm working on getting a better hang of generics. I found generics can use type 
inference if the object is passed as a parameter, but needs to be explicitly 
stated if it is a return value.


type
  Foo = object
foo: int
bar: int

proc init[T](): T =
  result = T()

proc stringify[T](o: T):string =
  return $o

# fails with "cannot instantiate"
# let t:Foo = init()

# works
let t = init[Foo]()

# works
echo stringify(t)




Run

Is this how it's supposed to work or did I miss something?