I would like to create my own templates to mockup my web applications. Now imagine I had a Panel shape. It consist of a title and a body devided by a line. When I scale the template in its height later on I would not like to see the title bar scaled.
First of all, is that possible? And if so, how?
My panel should look something like that:
-------------------
| Title | -> should not change its height on scaling
-------------------
| Some Text in |
| here.. |
| |
| |
| | |
| ˇ |
| Only the body |
| should scale... |
| |
-------------------
I am using Omnigraffle 5.4.
Related
My Qt app's context menu is displayed in the incorrect position when using multiple monitors on Gnome 3.
It would seem that perhaps the culprit here is Gnome Shell, rather than Qt itself, as I can't replicate the issue described below with Ubuntu Unity, it only happens when running Ubuntu Gnome 14.04.
Symptoms:
I am using QWidget::mapToGlobal(QPoint) from a QWidget::customContextMenuRequested signal in order to find the correct position to display a context menu.
I am then using QMenu::exec(QPoint) to display the menu in that position
void Window::slotOnShowContextMenu(const QPoint& p)
{
_menu->exec(_tree->viewport()->mapToGlobal(p));
}
My problem is that I have the following screen layout:
When my window is on the right hand screen, or on the left hand screen but at a position below the top of the right hand screen, the context menu is shown correctly:
When my window is on the left hand screen, at a level above the top of the right hand screen, even though the Y value of the QPoint returned from mapToGlobal is correct, the context menu is not displayed at that point, but is rather constrained to be at the same level as the right hand screen.
I have confirmed that _tree->viewport()->mapToGlobal(p) returns the correct results (just by logging the resulting QPoint)
QPoint point = _tree->viewport()->mapToGlobal(p);
std::cout << point.x() << ":" << point.y() << '\n';
It would therefore seem that QMenu::exec(QPoint) is the culprit?
How can I correctly display my context menu?
Edit:
I tried running the same app on standard Ubuntu 14.04 (ie: using Unity instead of Gnome), and the incorrect behaviour doesn't present itself, so this would seem to be a Gnome 3 issue?
I have tried changing my primary monitor so that the portrait monitor on the left is primary, and the context menu displays correctly.
Note black launch bar is on the left screen
When using the following layout (primary screen is landscape on the right) the context menu position is constrained to be the top of the primary monitor.
Note black launch bar is on the right screen
So it would seem that the primary monitor's top position is the maximum height that Qt will display it's context menu?
While the technical details may be slightly different, I found with elementary os and two monitors (a laptop and a smart tv), with my built-in display positioned on the right of the external display, the menu is invisible if I have the Qt app (KeePassXC in my case) on my built-in display. If I move it to my external display, the menus are at the top of the display, instead of in the window. There is clearly a bug somewhere, whether in Qt or ubuntu or gnome shell, I can't say.
I can say that switching my displays back to the default positioning, with the built-in on the left of external, the issue is resolved: I can finally access the menus where they should be.
I have tried moving the window location around, and as long as I have my built-in display situated to the left of my external display, it doesn't matter where the window is, it just works like it should.
This solution may not be ideal if your monitors are not physically positioned that way, but in my case, I'm already having to lie about where my monitors are positioned. My built-in is below my external, but when I try to tell elementary that, it stops functioning correctly (all windows are moved to outside the bounds of the screen, all windows launch off screen; deleting .config/monitors.xml fixes it, but I have to be able to get to a command prompt on the screen to do it.)
I ran into this same issue. As I dug into it I realized that it's a conflict between the perceived/"logical" monitor location and the rendering of the screen. In my case, I can see through the output of xrandr and the configuration of ~/.config/monitors.xml that my right most monitor (the equivalent of your Hewlett Packard 27" monitor) that it has a position offset of +360:
$ xrandr
Screen 0: minimum 320 x 200, current 7040 x 1440, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+5120+360 (normal left inverted right x axis y axis) 309mm x 173mm
...
These 360 pixels correspond to the top of the window's "location" as understood by QT.
In my case the menu bar itself is 25 pixels high. Keeping all this in mind(360 + height of title bar + height of menu) actual offset of where perceived drawing of the menu.
+---------+---------------------------------------------+ ^
| | | |
| +-------------------------------------^-------------+ | |
| | | | 25 pixels | | | 360 pixels
| +-------------------------------------v-------------+ | |
| | | | | v
| | | 385 pixels | +---+---------------------------+
| | | | | |
| | +----v+ | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | +-----+ | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| +---------------------------------------------------+ | |
| | |
| | |
| | |
| | |
+-------------------------------------------------------+-------------------------------+
When I re-aligned me screens so that the position offset was zero like in the following setup the problem went away:
$ xrandr
Screen 0: minimum 320 x 200, current 7040 x 1440, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+5120+0 (normal left inverted right x axis y axis) 309mm x 173mm
...
In this case the 360 pixel position offset is now zero and QT renders the menu drop down at the correct location:
+-------------------------------------------------------+-------------------------------+
| | |
| +-------------------------------------^-------------+ | |
| | | 25 pixels | | |
| +--+-----+----------------------------v-------------+ | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | +-----+ | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | +-------------------------------+
| +---------------------------------------------------+ |
| |
| |
| |
| |
+--------------------------------------------------------
I was in the process of filing a bug with QT about this (as I have multiple applications which are affected by this bug), but in the process of collecting the relevant information for the bugs I discovered that it's not just QT/QT5 affected but also Blender. As Blender does not use a graphics framework (e.g. QT/QT5, GTK+, etc) this is almost certainly a bug in one of the components of GNOME3.
I'm running into this with qt applications in fvwm if:
I have a monitor configuration with deadspace
and if qt menu animations are enabled
The menus end up off-screen and not visible at all or in completely the wrong place (depending on the monitor offsets) -
Thus I'm not so sure this is just a gnome shell bug.
I've got a supervised data set with 6836 instances, and I need to know the predictions of my model for all the instances, not only for a test set.
I followed the approach train-test (2/3-1/3) to know about my rates TPR and FPR, and I've got the predictions about my test (1/3), but I need to know the predcitions about all the 6836 instances.
How can I do it?
Thanks!
In the classify tab in Weka Explorer there should be a button that says 'More options...' if you go in there you should be able to output predictions as plain text. If you use cross validation rather than a percentage split you will get predictions for all instances in a table like this:
+-------+--------+-----------+-------+------------+
| inst# | actual | predicted | error | prediction |
+-------+--------+-----------+-------+------------+
| 1 | 2:no | 1:yes | + | 0.926 |
| 2 | 1:yes | 1:yes | | 0.825 |
| 1 | 2:no | 1:yes | + | 0.636 |
| 2 | 1:yes | 1:yes | | 0.808 |
| ... | ... | ... | ... | ... |
+-------+--------+-----------+-------+------------+
If you don't want to do cross validation you also can create a data set containing all your data (training + test) and add it as test data. Then you can go to more options and show the results as Campino already answered.
I have two models, Version and Description.
class Version(models.Model):
version_name = models.CharField(max_length=100)
version_value = models.IntegerField()
url = models.CharField(max_length=240)
class Description(models.Model):
version = models.ForeignKey(Version)
lang = models.CharField(max_length=8)
content = models.TextField()
And a DescriptionSerializer.
class DescriptionSerializer(serializers.ModelSerializer):
version_name = serializers.RelatedField(source='version')
class Meta:
model = Description
fields = ('version_name', 'content')
They stored the descriptions of different versions in different languages.
E.g.
Version
+----+--------------+---------------+---------------------+
| id | version_name | version_value | url |
+----+--------------+---------------+---------------------+
| 1 | 1.0.0 | 1 | http://abc.net.tw/ |
| 2 | 1.0.1 | 2 | http://abc.net.tw/2 |
| 3 | 1.0.2 | 3 | http://abc.net.tw/3 |
| 4 | 1.0.3 | 4 | http://abc.net.tw/4 |
| 7 | 1.1.0 | 5 | http://abc.net.tw/5 |
| 8 | 1.1.1 | 6 | http://abc.net.tw/6 |
+----+--------------+---------------+---------------------+
Description
+------------+-------+---------+
| version_id | lang | content |
+------------+-------+---------+
| 1 | en_US | English |
| 1 | zh_TW | Chinese |
| 1 | es_ES | Spanish |
| 2 | en_US | English |
| 2 | zh_TW | Chinese |
| 2 | es_ES | Spanish |
| 3 | en_US | English |
| 3 | zh_TW | Chinese |
| 3 | es_ES | Spanish |
| 4 | en_US | English |
| 7 | en_US | English |
| 8 | en_US | English |
| 4 | es_ES | Spanish |
| 7 | es_ES | Spanish |
+------------+-------+---------+
I'm using django rest framework to implement a web API that returns the description of each version in certain language. If a description of certain language doesn't exist, use English version instead.
I can use following SQL to retrieve the desired result. I've read DRF's docs on relatedField and reverse relation. But I still can't figure out how to use django's ORM to do the same thing and to use it with django rest framework's serializer.
select
coalesce(d.id, d2.id), coalesce(d.version_id, d2.version_id), coalesce(d.lang, d2.lang), coalesce(d.content, d2.content)
from
version v
left outer join description d on v.id = d.version_id and d.lang='zh_TW'
left outer join description d2 on v.id = d2.version_id and d2.lang='en_US'
Please advise how to do it in django.
You can't use django orm for everything. There are numerous things you can't do with django. For those cases you either use straight up SQL (from django.db import connection, transaction etc...) or if the query results can be worked into objects you have described - then you can use raw queries (link)
I'm using XSL-FO to generate an account statement print out. The PDF is actually just a simple table with a simple header on every page. The difficulty is that I have to display transaction volumes per page, e.g.
Page 1
+------------------------------+-----------+-----------+---------------------+
| Text | Credit | Debit | Balance |
+------------------------------+-----------+-----------+---------------------+
| Previous month | | | (*1) 1000 |
| abc | 1000 | | 2000 |
| abc | | 500 | 1500 |
| abc | | 200 | 1300 |
| ... | | | |
| Carry over | (*2) 1000 | (*3) 700 | (*4) 1300 |
+------------------------------+-----------+-----------+---------------------+
Page 2
+------------------------------+-----------+-----------+---------------------+
| Text | Credit | Debit | Balance |
+------------------------------+-----------+-----------+---------------------+
| Previous page | (*2) 1000 | (*3) 700 | (*4) 1300 |
| abc | 1000 | | 2300 |
| abc | | 500 | 1800 |
| abc | | 200 | 1600 |
| ... | | | |
| Carry over | (*2) 2000 | (*3) 1400 | (*4) 1600 |
+------------------------------+-----------+-----------+---------------------+
Here are some explanations:
This is the previous month's balance. It's pre-calculated and well-known as an XSL variable. No problem with that, that's a regular header (only on the first page)
This value is calculated on a per-page basis. It sums up all credit amounts on the same page. I can't calculate that myself, as I don't know when XSL-FO will do the page break. So I imagine XSL-FO must do the calculation for me. The sum at the bottom of a page is the same as the value at the top of the subsequent page.
This value is the same as 2, only for debit amounts.
This value is just the last transaction's balance at the bottom of a page. That value is repeated at the top of the next page.
How can I do these calculations with XSL-FO?
See also this related question: How to display one or the other information depending on the page number in XSL-FO?
Try "table markers": http://www.w3.org/TR/xsl/#fo_retrieve-table-marker.
In XSLT for each row inject a marker with the sum. Then let the engine select a marker to substitute for the fo:retrieve-table-marker in table header or footer. The idea is that proper marker will be selected at rendering time depending on the marker's position on the page and #retrieve-position and #retrieve-boundary on the fo:retrieve-table-marker.
Unfortunately, (at the time when I answered this question, it's no longer true) fop doesn't implement <fo:retrieve-table-marker/> from what I have found out. Instead, this solution here worked for me:
How to display one or the other information depending on the page number in XSL-FO?
It involves creating a separate table outside of the <fo:flow/> that displays the table header using <fo:retrieve-marker/> elements.
I'm using WTL to create a window containing many splitted panes. The following will be the result.
---------------------------
| | | |
| | | |
| | | |
| |--------------------
| | | |
| | | |
---------------------------
There will be 4 splitters, three vertical ones and a horizontal one.
I followed the great article : http://www.codeproject.com/KB/wtl/wtl4mfc7.aspx.
But I only can add 3 splitters as below.
---------------------------
| | | |
| | | |
| | | |
| |--------------------
| | |
| | |
---------------------------
I tried a lot of ways but still cannot add the last one.
Is is a bug of WTL? Can anybody help me?
Best regards,
Zach#Shine
What is your problem? Is it a compile error, a runtime ASSERT, something else?
I strongly suggest that you derive your CMainFrame from CSplitFrameWindowImpl<>.
---------------------------
| | | |
| | 2TL | 2TR |
| 1L | | |
| |--------------------
| | 2BL | 2BR |
| | | |
---------------------------
The right pane (including all '2' panes) should derive from CSplitterWindowImpl<CPane2, false>, the right top pane (including all '2T' panes) should derive from CSplitterWindowImpl<CPane2T, true> as well as the right bottom one.
Each split pane should be created in the OnCreate() handler of it's parent and create it's children in it's own OnCreate().