Issue with GTK and D - macos

OK, so I'm trying to experiment a bit with D and Gtk.
On OSX, I download the sources and did the typical make, sudo make install.
Now the Gtk sources are installed here :
/usr/local/include/d/gktd-2
However, when I'm trying to build one of the demos included (e.g. /demos/gtk/HelloWorld.d), with :
dmd -I/usr/local/include/d/gktd-2 HelloWorld.d
The compiler still complains :
HelloWorld.d(24): Error: module MainWindow is in file 'gtk/MainWindow.d' which cannot be read
import path[0] = /usr/local/include/d/gktd-2
import path[1] = /usr/share/dmd/src/phobos
import path[2] = /usr/share/dmd/src/druntime/import
What am I missing?
UPDATE :
I think I got it to work, but it's one of those cases where I simply don't know how that happened... lol

To me it seems like a typo - /usr/local/include/d/gktd-2 seems incorrect. It should be something like /usr/local/include/d/gtkd-2 . Following should work: dmd -I/usr/local/include/d/gtkd-2 HelloWorld.d (note the change from "gktd" to "gtkd").

Related

Writing out document in GUI executable using cx_freeze not working

I made an executable gui (with tkinter) file using cx_freeze. The executable has several buttons. When the user click the button, the calculation should work and then it will write out an xlsx file.
Everything went good when I make the executable, there was no error. But when I click the button, it seems like the calculation works (since it was loading), but then it does not write out the xlsx file.
I don't know what went wrong. Anyone can help me?
Here's the setup.py file:
import sys
from cx_Freeze import setup, Executable
import os
import tkinter
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [Executable("gui.py", base=base)]
packages = ["tkinter", 'xlsxwriter', 'matplotlib']
options = {
'build_exe': {
'includes': ["os", "tkinter", 'numpy.core._methods', 'numpy.lib.format', 'xlrd', 'scipy', 'pandas'],
'include_files': [r"C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\DLLs\tcl86t.dll",
r"C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\DLLs\tk86t.dll"]
},
}
os.environ['TCL_LIBRARY'] = r'C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'
setup(
name="Tool",
version="1.0",
description="Tool prototype for calculating",
options=options,
executables=executables
)
I've solved the problem.
What i did was to change the base in setup.py to : base = None
and I installed the xlsxwriter by following this thread: ImportError: No module named 'xlsxwriter': Error in bamboo
After this, I encountered another problem:
No module named: scipy.sparse.csgraph._validation
but I simply add this to the 'includes': ['scipy.sparse.csgraph._validation', ...]
now everything works perfectly.
I hope this helps anyone who has the same problem.

Go install exclude file

I have created a go script that compiles, starts, checks the status, and ends a web service I created (that is also in go). However, I have come to a road block.
With the compile feature I run the following command:
go install .
Which gives the following error:
./script.go:55: main redeclared in this block
previous declaration at ./hello.go:8
Which makes sense as I have two different files, both with the main func and main package. I also tried moving the script to another folder and then changing the command ran to:
go install {path}
Where {path} is equal to the path I want installed/compiled. Which I then got the following error:
exit status 1: can't load package: package /var/www/test.com/go: import "/var/www/test.com/go": cannot import absolute path
So in conclusion I have thought of only one solution (and I am up to hear others if mine isn't the best approach). My idea is to exclude the script file from compiling with the rest of the files, but I am unsure how to.
I did some research and couldn't find an easy way to do it (such as an --exclude flag with the go install command). Does anybody know how to accomplish what I am trying to achieve?
Thank you.
you could give the hello.go a different package name, that should work. Or i am missing something?
Regards
Tim

"go get golang.org/x/tools/go/gcimporter15" fails on undefined identifiers

I'm trying to make a program dependent upon gcimporter15 for Go, and so I'm using the command "go get golang.org/x/tools/go/gcimporter15", but it fails with the error:
# golang.org/x/tools/go/gcimporter15
../../go/src/golang.org/x/tools/go/gcimporter15/bexport.go:557: undefined: constant.ToFloat
../../go/src/golang.org/x/tools/go/gcimporter15/gcimporter.go:396: pkg.SetName undefined (type *types.Package has no field or method SetName)
That appears to me that there is an error within gcimporter itself, but that doesn't make sense that I would get this when it doesn't appear that others are. Why isn't it working?
I'm using Go 1.5.3.
The godoc.org/golang.org/x/tools/go/gcimporter15 tells that the package gcimporter is deprecated and this package will be deleted in October 2017. And this new code should be used: golang.org/x/tools/go/gcexportdata instead of gcimporter .
So, what you have to do is:
$ go get godoc.org/golang.org/x/tools/go/gcexportdata
PS: Tested within Ubuntu 16.04 64bit and go version go1.6.2 linux/amd64 without any issues.
Test:
package main
import (
"fmt"
gcexportdata "golang.org/x/tools/go/gcexportdata"
)
func main() {
filename, path := gcexportdata.Find("fmt", "")
fmt.Println(filename, path)
}
Output:
/usr/lib/go-1.6/pkg/linux_amd64/fmt.a fmt
Its bad but seems there is a mismatch between the gcimporter15 and go-1.5. I faced the same problem and looked at go-1.5 code in file src/go/constant/value.go and there is no ToFloat() function in the constant package.
As #nexus66 says, the gcimporter is deprecated. So, I don't expect them to fix this. If you are using this package directly, its better to move on to the recommended gcexportdata package. If you are using a third party library which is in turn using gcimporter, may be you should upgrade to go-1.7. That's what I did and things worked fine.

.exe doesn't launch after making it with py2exe

So I have been working for 2 months on a project in python (it is the first time I'm using python).
The project is basically:
- 1 main file,
- 1 GUI file using PyQt4
- and a few classes for the calculation functions.
Here is my setup.py file:
from distutils.core import setup
import py2exe
from glob import glob
import matplotlib
dataf = [
(r'mpl-data',
[r'C:\Python27\Lib\site-packages\matplotlib-1.4.3-py2.7-win32.egg\matplotlib\mpl-data\matplotlibrc']),
(r'mpl-data\stylelib',
glob(r'C:\Python27\Lib\site-packages\matplotlib-1.4.3-py2.7-win32.egg\matplotlib\mpl-data\stylelib\*.*')),
(r'mpl-data\images',
glob(r'C:\Python27\Lib\site-packages\matplotlib-1.4.3-py2.7-win32.egg\matplotlib\mpl-data\images\*.*')),
(r'mpl-data\fonts',
glob(r'C:\Python27\Lib\site-packages\matplotlib\mpl-data\fonts\*.*')),
(r'Qt\imageformats',
glob(r'C:\Python27\Lib\site-packages\PyQt4\plugins\imageformats\*.*')),
(r'Resource',
glob(r'C:\PythonWS\Lince5M\*.png')),
]
includes = ['sip', 'PyQt4.QtCore', 'PyQt4.Qt', 'PyQt4.QtGui', 'PyQt4.QtNetwork',]
pack = ['numpy.core', 'matplotlib.backends', 'matplotlib.axes', 'zmq', 'PyQt4.QtCore', 'PyQt4.Qt',
'PyQt4.QtGui', 'PyQt4.QtNetwork', 'CaptureImage', 'ClusterDetectionIterative', 'DisplayPanel',
'ImageProcessAvg', 'WriteOutputFiles',
]
excludes = ['_gtkagg', '_agg2', '_cairo', '_cocoaagg', '_fltkagg', '_gtk', '_gtkcairo', '_thread',
'_macosx',
]
#I admit not understand really much those excludes, that's why I don't put them in the setup
opts={
'py2exe': {
'compressed': 2,
'optimize': 2,
'includes':includes,
'packages':pack,
#'excludes':excludes,
'bundle_files': 1,
}
}
win = [{
'script': 'Application.py',
'icon_resourses': [(1,'icone\icone.png')]
}
]
setup(
version = "0.1",
console=win,
options=opts,
data_files=dataf,
)
My programs works fine when launched with Eclipse.
The making of the executable seems to be done fine too, except for the list of missing modules there is no error, and my .exe is created...
But when I start it nothing happens... I have been looking for a few days now and I really have no idea on what is wrong since nothing gives me a notice on the problem..
If it could be of any use, my project uses those imports:
PyQt4, os, decimal, time, numpy, sys, clr, matplotlib, cv2, and a dll we made in the company.
So here is my question:
Anyone ever got this kind of error?
Does any one know how to get an output, or anything that could tell me where is the problem?
There should be a [.exe name].log file in the "dist" folder that py2exe created.
Try looking to see if that can glean some information on your problem.

Why does command "tsc file.ts" give no output and not produce a js file?

I have just started work on a project with some typescript code, and I'm trying to compile the .ts files to .js files from within Linux Mint, but it's not working as I'd expect.
There is a Makefile, but it's not working. Running make returns an error:
tsc --noImplicitAny --noEmitOnError --out client/welcome.js client/welcome.ts
make: *** [client/welcome.js] Error 1
I have also tried creating an example typescript file greeter.ts (as per this official tutorial) containing:
function greeter(person) {
return "Hello, " + person;
}
var user = "Jane User";
document.body.innerHTML = greeter(user);
and tried compiling the ts file to javascript with the command (as per the same tutorial) tsc greeter.ts however the command completes with no output, and no .js file has been created.
I haven't previously worked with typescript at all, and though I've used Makefile's before I don't know much about them either, so I'm hoping it's something really obvious!
I encountered this problem because I had the following line in my tsconfig.json:
"noEmit": true
It worked after removing it.
--noEmitOnError
This means that if there is an error detected no js will be generated. I highly recommend not using this option (Changes a major benefit of why typescript)
More
Check your tsc version. The code you provided works fine with 1.6:
Update
The --version command should work at the very least. See below:

Resources